ACM题解源代码(hdoj)
WuchangI
An optimistic Nobita fond of coding~~
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
hdoj 1090
#includeusing namespace std;int main(void){ int a, b, sum, times; cin>>times; while(times --) { cin>>a>>b; cout } return 0;}原创 2017-06-15 19:29:11 · 327 阅读 · 0 评论 -
hdoj 1002 (A + B Problem II)
//大数相加#include#includeusing namespace std;int main(void){ string add(string str1, string str2); int n, i, j; cin>>n; string str1, str2, tstr1, tstr2; for(i = 1; i原创 2017-06-15 13:58:55 · 445 阅读 · 0 评论 -
hdoj 1800 (Flying to the Mars)
// 如果不用scanf,用cout,就会TLE,1000MS变成了421MS//贪心,实质求连续多次求最长严格上升子序列,循环次数就是所求的最少broomstick#include#include#includeusing namespace std;int bs[3000];int main(void){ int n,cur,m; w原创 2017-06-16 14:55:49 · 365 阅读 · 0 评论 -
hdoj 4146(Flip Game)
注意输入方式,和多操作的处理(利用规律简化操作次数)以防TLE//超时版本(虽然结果正确)#include#include#includeusing namespace std;char str[1001][1001];//把棋盘str中的每个棋子的黑白状态相应地表示在整型数组flag中int flag[1001][1001]; int main(void){ int T原创 2017-07-01 09:42:03 · 431 阅读 · 0 评论 -
hdoj 2188(选拔志愿者)
//巴什博弈#includeusing namespace std;int main(void){ int C, n, m; cin >> C; while (C--) { cin >> n >> m; cout 0 ? "Grass" : "Rabbit") } return 0;原创 2017-06-18 09:19:28 · 428 阅读 · 0 评论 -
hdoj 2187
//简单贪心#include#include#includeusing namespace std;struct Rice{ int p, h;}r[1000];bool cmp(Rice&a, Rice &b){ return a.p }int main(void){ int C, n, m; doubl原创 2017-06-18 09:18:01 · 397 阅读 · 0 评论 -
hdoj 2186
#includeusing namespace std;int main(void){ int C, a, b, c, n; cin >> C; while (C--) { cin >> n; a = n / 2; b = (n - (n / 2)) * 2 / 3; c =原创 2017-06-18 09:16:27 · 317 阅读 · 0 评论 -
hdoj 2124
#include#includeusing namespace std;int main(void){ int length, n, count, b[600]; while (cin >> length) { cin >> n; for (int i = 0; i {原创 2017-06-18 09:15:33 · 367 阅读 · 0 评论 -
hdoj 2037
#includeusing namespace std;const int MAXN = 105;typedef struct{ int s, e;}T;T ti[MAXN];int cmp(const void *_p, const void*_q){ T *p = (T *)_p; T *q = (T *)_q; retu原创 2017-06-18 00:12:34 · 460 阅读 · 0 评论 -
hdoj 2111
//经典贪心#include#includeusing namespace std;struct Bao{ int p, m;}b[100];bool cmp(Bao&a, Bao&b){ return(a.p > b.p);}int main(void){ int v, n, get; while原创 2017-06-18 00:16:52 · 340 阅读 · 0 评论 -
hdoj 2051
//使用递归实现,而不是数组#includeusing namespace std;int main(void){ void zz(int); int num; while (cin >> num) { zz(num); cout } return 0;}void zz(i原创 2017-06-18 00:14:14 · 437 阅读 · 0 评论 -
hdoj 2027
#includeusing namespace std;int main(void){ int n; char s[100]; cin >> n; getchar(); for (int j = 0; j { if (j > 0) cout int a[5] = { 0, 0, 0, 0原创 2017-06-17 18:34:02 · 386 阅读 · 0 评论 -
hdoj 2023
#include#includeusing namespace std;struct Student{ int score[50]; double avr;};int main(void){ int n, m; while (cin >> n >> m) { int i, j; Stu原创 2017-06-17 18:29:54 · 362 阅读 · 0 评论 -
hdoj 2026
#include#includeusing namespace std;int main(void){ char s[100]; int len; int count; while (gets(s)) { len = strlen(s); for (int i = 0; i {原创 2017-06-17 18:33:15 · 297 阅读 · 0 评论 -
hdoj 2025
#include#includeusing namespace std;int main(void){ char s[100]; int len; int max_char; while (cin >> s) { len = strlen(s); max_char = s[0];原创 2017-06-17 18:32:14 · 303 阅读 · 0 评论 -
hdoj 1318(Palindromes)
回文字符串配对问题#include#include#includeusing namespace std;const char *rev = "A 3 HIL JM O 2TUVWXY51SE Z 8 "; //使用常量数组”打表“比较简单const char *msg[] = { "not a palindrome.", "a regular palindrome.",原创 2017-06-25 19:26:20 · 424 阅读 · 0 评论 -
hdoj 1000
#includeusing namespace std;int main(void){ int a, b; while(cin>>a>>b) { cout } return 0;}原创 2017-06-14 21:15:30 · 491 阅读 · 0 评论 -
hdoj 1001
#includeusing namespace std;int main(void){ int a, sum; while(cin>>a) { sum = 0; for(int i = 1; i cout } return 0;}原创 2017-06-15 13:55:15 · 333 阅读 · 0 评论 -
hdoj 1089
#includeusing namespace std;int main(void){ int a, b, sum; while(cin>>a>>b) { cout } return 0;}原创 2017-06-15 19:26:07 · 322 阅读 · 0 评论 -
hdoj 1051
#include#include#includestruct Wood{ int l, w; bool processed;};int n, m;using namespace std;bool cmp(Wood &a, Wood&b){ if (a.l == b.l) return a.w else return原创 2017-06-15 19:23:49 · 318 阅读 · 0 评论 -
hdoj 1050
//找出几个搬动区间的重叠部分重叠次数最多的次数即为整个搬动任务的最少搬动次数(可以同时)//房间是两侧的,注意处理奇偶性#includeusing namespace std;int a[401];int main(void){ int T, s, e,t,n,max; cin >> T; while (T--) {原创 2017-06-15 19:22:27 · 350 阅读 · 0 评论 -
hdoj 1049
#include#includeusing namespace std;int main(void){ int n, u, d, time; while (cin >> n >> u >> d&&n) { time = ceil((n - u) / (double)(u - d)) * 2 + 1; cout原创 2017-06-15 14:24:08 · 280 阅读 · 0 评论 -
hdoj 1039
#include#includeusing namespace std;bool is_fu(char c){ if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') return false; else return true;}const char *msg[] = {" is acc原创 2017-06-15 14:22:35 · 243 阅读 · 0 评论 -
hdoj 1020
#include#include#includeusing namespace std;char code[10000];char count_[10];int main(void){ int clen, dlen, count_len, count; int k; int n; cin>>n; while(n--)原创 2017-06-15 14:20:55 · 310 阅读 · 0 评论 -
hdoj 1017
//注意格式问题#includeusing namespace std;bool f(int a, int b,int m){ return ((a*a + b*b + m) % (a*b) == 0);}int main(void){ int nn, m, n, tot,Case; cin >> nn; for(int k=原创 2017-06-15 14:19:34 · 268 阅读 · 0 评论 -
hdoj 1014
//AC 1#include#includeusing namespace std;int main(void){ int step, mod,cur,n; const char*a[] = { "Good Choice","Bad Choice" }; while (cin >> step >> mod) { n原创 2017-06-15 14:18:09 · 326 阅读 · 0 评论 -
hdoj 1013
#include#includeusing namespace std;int main(void){ string num; int i, sum; while(cin>>num && num[0] != '0') { sum = 0; for(i = 0; i if(sum % 9原创 2017-06-15 14:14:41 · 260 阅读 · 0 评论 -
hdoj 1012
#include#includeusing namespace std;int main(void){ double E(int); cout cout for(int i = 0; i { if(i else cout } return 0;}double E(i原创 2017-06-15 14:13:12 · 307 阅读 · 0 评论 -
hdoj 1009
//简单贪心#include#include#includeusing namespace std;typedef struct{ int j, f; double rate;}Trade;bool cmp(Trade &a, Trade &b){ return a.rate > b.rate;}Trade fat[10原创 2017-06-15 14:11:25 · 305 阅读 · 0 评论 -
hdoj 1008
#includeusing namespace std;int main(void){ int up = 6, down = 4, stop = 5, total; while (cin >> total && total != 0) { int time = 0, cur = 0, aim = 0; while (to原创 2017-06-15 14:05:42 · 326 阅读 · 0 评论 -
hdoj 1005
#includeusing namespace std;int main(void){ int a, b, n, i, s[49] = {1,1}; while(cin>>a>>b>>n && (a || b || n)) { for(i = 2; i cout } return 0;}原创 2017-06-15 14:03:41 · 245 阅读 · 0 评论 -
hdoj 1004
#include#includeusing namespace std;struct bal_col{ string color; int amount;};int main(){ void reset(bal_col a[]); //重置存储气球颜色的数组 int pop_bal_index(bal_col a[],原创 2017-06-15 14:00:39 · 342 阅读 · 0 评论 -
hdoj 2024
#include#include#includeusing namespace std;int main(void){ int n, len; char s[50]; bool legal; cin>>n; getchar(); for(int i = 0; i { legal = tru原创 2017-06-17 18:31:09 · 432 阅读 · 0 评论 -
hdoj 2022
#include#includeusing namespace std;int main(void){ int a[100][100]; int m, n; while (cin >> m >> n) { int i, j, maxi = 0, maxj = 0; for (i = 0; i原创 2017-06-17 18:29:05 · 384 阅读 · 0 评论 -
hdoj 2021
#includeusing namespace std;int main(void){ int count(int); int money, total; int n; while (cin >> n && n) { total = 0; while (n--) {原创 2017-06-17 18:28:18 · 315 阅读 · 0 评论 -
hdoj 2003
#include#include#includeusing namespace std;int main(void){ double num; while (cin >> num) { cout } return 0;}原创 2017-06-16 15:00:47 · 346 阅读 · 0 评论 -
hdoj 2002
#include#includeusing namespace std;const double pi = 3.1415927;int main(void){ double r, V; while (cin >> r) { V = (4 * pi * r * r * r) / 3; cout }原创 2017-06-16 14:59:37 · 324 阅读 · 0 评论 -
hdoj 2001
#include#include#includeusing namespace std;int main(void){ double x1, x2, y1, y2, d; while (cin >> x1 >> y1 >> x2 >> y2) { d = sqrt(double((x1 - x2) * (x1 - x2) + (y原创 2017-06-16 14:58:48 · 340 阅读 · 0 评论 -
hdoj 2000
#includeusing namespace std;int main(){ char x, y, z, t; while (cin >> x >> y >> z) { if (x > y) { t = x; x = y; y = t; } if (x > z) { t = x; x = z; z = t; }原创 2017-06-16 14:57:55 · 318 阅读 · 0 评论 -
hdoj 1846
//巴什博弈#includeusing namespace std;int main(void){ int C, n, m; cin >> C; while (C--) { cin >> n >> m; cout 0 ? "first" : "second") } retur原创 2017-06-16 14:56:56 · 324 阅读 · 0 评论
分享