摘要:
#include#includeusing namespace std;int a[2000005];int main(){ int n,m; while(scanf("%d",&n)!=EOF) { for(int i=0; i<n; i++) ... 阅读全文
摘要:
#include#include#includeusing namespace std;int main(){ char a[20],b[20]; while(scanf("%s%s",a,b) != EOF) { int na=0; for(int i=0; a[i]!='\0'; i++) { if(a[i]>='0'&&a[i]='0'&&b[i]<='9') nb=nb*10+b[i]-'0'; else continue;... 阅读全文
摘要:
#include#include#includeusing namespace std;int main(){ int p,t,g1,g2,g3,gj; while(scanf("%d %d %d %d %d %d",&p,&t,&g1,&g2,&g3,&gj)!=EOF) { if(abs(g1-g2)=t && abs(g3-g2)=t) { printf("%.1f\n",(g3+g1+0.0)/2); } else if(abs(g3-g1)<=t && a.. 阅读全文
摘要:
http://ac.jobdu.com/problem.php?pid=1553/* 时针和分针位mod12,之和再mod6计算大角度, 时针和分针的位置关系分4种情况讨论 然后加上时针小角度的转动。*/#includeint main(){ int h,m; while(scanf("%d%*c%d",&h,&m)!=EOF) { int a=h%12,b=m%12; float k=(m+0.0)/2; float q=(a+0.0)/12-(m*11.0)/(60*12); if(q>0) { ... 阅读全文
摘要:
1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 string sortString(string s) 7 { 8 for(int i=0; i=s[j])12 {13 char cmp=s[i];14 s[i]=s[j];15 s[j]=cmp;16 }17 }18 return s;19 }20 int main()21 {2... 阅读全文
摘要:
http://codeforces.com/problemset/problem/50/A#include#includeusing namespace std;int main(){int n,m,i;while(cin>>m>>n){if(n%2==0)cout<<m*n/2<<endl;elsecout<<m*(n/2)+m/2<<endl;}return 0;} 阅读全文
摘要:
http://codeforces.com/problemset/problem/118/A 1 #include 2 #include 3 #include 4 using namespace std; 5 string a; 6 queueb; 7 bool is_vowel(char aa) 8 { 9 if(aa=='a' || aa=='e' || aa=='i' || aa=='o' || aa=='u' ||aa=='y'||aa=='A' || aa=='E& 阅读全文
摘要:
http://codeforces.com/problemset/problem/71/A 1 #include 2 #include 3 using namespace std; 4 string a; 5 int main() 6 { 7 int n; 8 cin>>n; 9 for(int i=0;i>a;12 if(a.length()>10)13 cout<<a[0]<<a.length()-2<<a[a.length()-1]<<endl;14 else15 cout<<a<... 阅读全文
摘要:
// hdu 1175#include #include #include #include using namespace std;struct node{ int x , y ; int step ;}s,e;node qu[1100000];int dir[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};int n , m , bx ,by ,ex ,ey;int map[1001][1000];bool f[1001][1000];bool flag;bool is_ok(int x, int y){ if( x >=1 && x = 1 阅读全文
摘要:
#include#include#includeusing namespace std;struct node{ friend bool operatorq; node b[5]; for(int i=0;i<5;i++) { b[i].priority=5-i; b[i].value=i; } for(int i=0;i<5;i++) q.push(b[i]); for(int i=0;i<5;i++) { cout<<q.top().priority<<'\t'<<q.top().value<<endl; . 阅读全文
摘要:
#include#include#includeusing namespace std;#define maxn 11#define maxm 20struct edge{ int u,v,w;}edges[maxm];int father[maxn];int m,n;void ufset(){ for(int i=0; i=0; s=father[s]); while(s!=x) { int tmp=father[x]; father[x]=s; x=tmp; } return x;}void Union(int ... 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1213#include#includeusing namespace std;#define N 1000int father[N];void ufset(){ for(int i=0;i=0;s=father[s]); while(s!=x) { int tmp=father[x]; father[x]=s; x=tmp; } return x;}void Union(int R1,int R2){ int r1=find(R1)... 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1702#include#include#include#includeusing namespace std;int main(){ // freopen("1.txt","r",stdin); int n; scanf("%d",&n); while(n--) { int m,i,x; listli; li.clear(); char s[10],ss[10]; scanf("%d %s",&m,s); ... 阅读全文
摘要:
http://codeforces.com/problemset/problem/330/B题解: 关键在于 m #include#includeusing namespace std;int map[1005];int main(){ // freopen("1.txt","r",stdin); int n,m,a,b; while(~scanf("%d %d",&n,&m)) { int ans=1; memset(map,0,sizeof(map)); for(int i=0; i<m; i++) { .. 阅读全文
摘要:
http://codeforces.com/problemset/problem/330/A#include#include#includeusing namespace std;int row[10][10],col[10][10];char s[10][10];int main(){ // freopen("1.txt","r",stdin); int r,c; while(scanf("%d%d",&r,&c)!=EOF) { memset(row,0,sizeof(row)); memset(col,0,siz 阅读全文
摘要:
hdu 1394http://acm.hdu.edu.cn/showproblem.php?pid=1394用线段树求逆序数,例如要求x的逆序数只需要访问(x+1,n)段有多少个数,就是x的逆序数。还有就是求最小逆序数的时候有个巧妙的想法,当把x放入数组的后面,此时的逆序数应该为x没放入最后面之前的逆序总数加上(n-x)再减去(x-1);sum = sum+(n-x[i])-(x[i]-1)。线段树#include#include#includeusing namespace std;#define lson l , m , rt > 1; build(lson); build(r... 阅读全文
摘要:
#include#include#includeusing namespace std;#define lson l,m,rt>1; build(lson); build(rson); pushup(rt);}void update(int p ,int x, int l,int r,int rt){ if(l==r) { MAX[rt]=x; return; } int m=(l+r)>>1; if(p=r) return MAX[rt]; int m=(r+l)>>1; int ans=0... 阅读全文
摘要:
#include#includeusing namespace std;#define lson l,m,rt>1; build(lson); build(rson); pushup(rt);}void update(int p ,int add, int l,int r,int rt){ if(l==r) { sum[rt]+=add; return; } int m=(l+r)>>1; if(p=r) return sum[rt]; int m=(r+l)>>1; int ans=0; ... 阅读全文
摘要:
In the 2020 grid below, four numbers along a diagonal line have been marked in red.08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 0849 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 0081 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 6552 70 95 23 04 60 11 42 69 24 68 56 01 3 阅读全文
摘要:
#include#includeusing namespace std;int lcm(int a ,int b){ int big=max(a,b); int small=min(a,b); int max=a*b; for(int i=big; i<max; i+=big) { if(i%small==0) return i; } return max;}int main(){ int sum,a=1,b=2; while(b!=20) { sum=lcm(a,b); a... 阅读全文
摘要:
https://projecteuler.net/problem=41、它是回文数2、存在2个三位数乘积等于它。 1 #include 2 #include 3 using namespace std; 4 bool is_ok(int x) 5 { 6 if(x%10!=x/100000 || (x/10)%10!=(x/10000)%10 || (x/100)%10!=(x/1000)%10) 7 return false; 8 return true; 9 }10 bool is_ok1(int x)11 {12 for(int i=100;i=1... 阅读全文
摘要:
http://codeforces.com/problemset/problem/320/AA magic number is a number formed by concatenation of numbers 1, 14 and 144. We can use each of these nu... 阅读全文