随笔分类 - HDUACM
一些acm题目解答
摘要:#include<iostream> using namespace std; __int64 gcd(__int64 a,__int64 b) { return b?gcd(b,a%b):a; } __int64 lcm(__int64 a,__int64 b) { return a/gcd(a,
阅读全文
摘要:#include <stdio.h> int main() { int k, a, i, flag; while(~scanf("%d", &k)) { for(i=0; i<66; i++) { if((18+k*i)%65==0) break; } if(i<66) printf("%d\n",
阅读全文
摘要:#include <stdio.h> int calc(int a, int b) { if(a==0 || a==1 || a==5 || a==6) return a; if(a==2) { if(b%4==1) return 2; if(b%4==2) return 4; if(b%4==3)
阅读全文
摘要:#include <iostream> using namespace std; int main() { int n,m,a,sum=0; while(cin>>n) { while (n--) { cin>>m; sum=0; while (m--) { cin>>a; sum=sum+a; }
阅读全文
摘要:#include <iostream> using namespace std; int main() { int b,a; while(cin>>a>>b) { cout<<a+b<<endl<<endl; } return 0; }
阅读全文
摘要:#include<iostream>using namespace std;int main(){ int n; while(cin>>n){ int sum=0; int i,m; for(i=1;i<=n;++i){ cin>>m; sum+=m; } cout<<sum<<endl; } re
阅读全文
摘要:#include <iostream> using namespace std; int main() { int n,m,a,sum=0; while(cin>>n) { while (n--) { cin>>m; sum=0; while(m--) { cin>>a; sum=sum+a; }
阅读全文
摘要:#include <iostream> using namespace std; int main() { int n,a,sum=0; while(cin>>n&&n!=0) { while (n--) { cin>>a; sum=sum+a; } cout<<sum<<endl; sum=0;
阅读全文
摘要:#include<stdio.h>int main(){ int a,b; while(scanf("%d%d",&a,&b)==2) { if(a==0&&b==0) break; else printf("%d\n",a+b); } return 0; }
阅读全文
摘要:#include<iostream>using namespace std;int main(){ int n; cin>>n; while(n--){ int a,b; cin>>a>>b; cout<<a+b<<endl; } return 0;}
阅读全文
摘要:#include<iostream> using namespace std; int main() { int n,m,s; while(cin>>n>>m) { s=n+m; cout<<s<<endl; } return 0; }
阅读全文
摘要:#include <stdio.h> #include <string.h> int main() { char s[10000]; int len; int cnt = 0; while(~scanf("%s",s)) { if(!strcmp(s,"<br>")) { cnt = 0; prin
阅读全文
摘要:#include <stdio.h> #include <string.h> int main() { int d[1001], ans[1001]; int n, i, j, flag, rst; while(~scanf("%d", &n) && n) { for(i=0; i<n; i++)
阅读全文
摘要:#include <iostream>#include <stdio.h>#include <string.h>#include <stack>#include <queue>#include <map>#include <set>#include <vector>#include <math.h>
阅读全文
摘要:#include <iostream> #include <cstring> using namespace std; int n[3],a[9000],b[9000],i,j,k,last,last2; int v[3]={1,2,5}; int main() { while ((cin>>n[0
阅读全文
摘要:#include<iostream> #include<algorithm> using namespace std; #define N 101 struct node { int score; //学生分数 int num; //学生做出的题目数目 char time[10]; //花费时间 }
阅读全文
摘要:#include"stdio.h" #include"string.h" #define N 305 int mark[N],link[N],map[N][N],p; int find(int a) //匈牙利算法,二分匹配 { int i; for(i=1;i<=p;i++) { if(!mark
阅读全文
摘要:#include<iostream> #include<stack> #include<string> #include<cctype> using namespace std; #define N 30 struct node { char m; int r,c; } a[N]; string s
阅读全文
摘要:#include<iostream> using namespace std; int GetMaxNum(int a[],int n) //求最大字段和 { int i,sum=0,maxsum=0; maxsum|=1<<31; for(i=1;i<=n;i++) { sum+=a[i]; if
阅读全文
摘要:#include<iostream> using namespace std; char s1[105],s2[105]; int val[5][5]={ {5,-1,-2,-1,-3}, {-1,5,-3,-2,-4}, {-2,-3,5,-2,-2}, {-1,-2,-2,5,-1}, {-3,
阅读全文