标签:print 根据 == break oid code main 日期 class
hdu 6108
1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 5 int main(){ 6 int t; 7 cin>>t; 8 while(t--){ 9 ll x; 10 scanf("%I64d",&x); 11 ll ans=0; 12 for(int i=1;i*i<=x;i++){ 13 if((x-1)%i==0) { 14 ans+=2; 15 if(i*i==(x-1)) ans--; 16 } 17 } 18 printf("%I64d\n",ans); 19 } 20 }
hdu 6112
1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 5 char s[30]; 6 int r[13]={0,31,29,31,30,31,30,31,31,30,31,30,31}; 7 int p[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; 8 9 int hh(int y){ 10 if((y%4==0&&y%100!=0)||(y%400==0)) return 1; 11 else return 0; 12 } 13 14 int Change(int year,int month,int day)//根据日期判断出星期几 15 { 16 if(month==1||month==2) 17 { 18 month+=12; 19 year--; 20 } 21 int c=year/100; 22 int y=year%100; 23 int m=month; 24 int d=day; 25 int W=c/4-2*c+y+y/4+26*(m+1)/10+d-1; 26 if(W<0) 27 return (W+(-W/7+1)*7)%7; 28 return W%7; 29 } 30 31 int cc(int y,int m,int d){ 32 if(hh(y)){ 33 if(r[m]>=d) return 1; 34 else return 0; 35 } 36 else { 37 if(p[m]>=d) return 1; 38 else return 0; 39 } 40 } 41 int main(){ 42 int t; 43 cin>>t; 44 while(t--){ 45 scanf("%s",s); 46 int y=(s[0]-‘0‘)*1000+(s[1]-‘0‘)*100+(s[2]-‘0‘)*10+(s[3]-‘0‘); 47 int m=(s[5]-‘0‘)*10+(s[6]-‘0‘); 48 int d=(s[8]-‘0‘)*10+(s[9]-‘0‘); 49 int t=0; 50 int day=Change(y,m,d); 51 for(int i=1+y;i<=9999;i++){ 52 if(day==Change(i,m,d)&&cc(i,m,d)){ 53 printf("%d\n",i);break; 54 } 55 } 56 } 57 }
hdu 6113
思路:把外围的0的联通快去掉,再判断1的联通快个数,和0的联通快个数
1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N=1e5+10; 4 5 int fa[N]; 6 char s[102][102]; 7 int n,m; 8 int b[4][2]={{1,0},{-1,0},{0,1},{0,-1}}; 9 int vis[N],a[N]; 10 11 int check(int x,int y){ 12 if(x<=0|x>n||y<=0||y>m) return 0; 13 return 1; 14 } 15 int jj(int x,int y) 16 { 17 return (x-1)*m+y; 18 } 19 20 int Find(int x){ 21 if(fa[x]==x) return x; 22 return fa[x]=Find(fa[x]); 23 } 24 void hh(int x,int y){ 25 int xx=Find(x); 26 int yy=Find(y); 27 if(xx!=yy) 28 fa[xx]=yy; 29 } 30 31 int main(){ 32 while(scanf("%d%d",&n,&m)!=EOF){ 33 memset(vis,0,sizeof(vis)); 34 memset(a,0,sizeof(a)); 35 for(int i=1;i<=N;i++) fa[i]=i; 36 for(int i=1;i<=n;i++) 37 scanf("%s",s[i]+1); 38 for(int i=1;i<=n;i++){ 39 for(int j=1;j<=m;j++){ 40 for(int k=0;k<4;k++){ 41 int xx=i+b[k][0]; 42 int yy=j+b[k][1]; 43 if(check(xx,yy)&&s[i][j]==s[xx][yy]){ 44 hh(jj(i,j),jj(xx,yy)); 45 } 46 } 47 } 48 } 49 50 for(int i=1;i<=n;i++){ 51 for(int j=1;j<=m;j++){ 52 int zz=Find(jj(i,j)); 53 for(int k=0;k<4;k++){ 54 int xx=i+b[k][0]; 55 int yy=j+b[k][1]; 56 if(check(xx,yy)==0) 57 vis[zz]=1; 58 } 59 } 60 } 61 int on=0,ze=0; 62 for(int i=1;i<=n;i++){ 63 for(int j=1;j<=m;j++){ 64 if(s[i][j]==‘1‘){ 65 int xx=Find(jj(i,j)); 66 if(!a[xx]) on++; 67 a[xx]=1; 68 } 69 else { 70 int xx=Find(jj(i,j)); 71 if(!vis[xx]&&!a[xx]) ze++; 72 a[xx]=1; 73 } 74 } 75 } 76 // cout<<on<<" "<<ze<<endl; 77 if(on!=1) cout<<-1<<endl; 78 else { 79 if(ze==1) cout<<0<<endl; 80 else if(ze==0) cout<<1<<endl; 81 else cout<<-1<<endl; 82 } 83 } 84 }
标签:print 根据 == break oid code main 日期 class
原文地址:http://www.cnblogs.com/hhxj/p/7352547.html