题解

26 条题解

  • -1
    @ 2017-02-16 09:49:14

    #include <bits/stdc++.h>

    using namespace std;

    int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

    int main()
    {
    int n,m;
    int sum=0;
    cin>>n>>m;
    n/=10000;
    m/=10000;
    int i;
    for(i=n;i<=m;i++)
    {
    int s=i%10*1000+i%100/10*100+i%1000/100*10+i/1000;
    if(s/100<=12&&s%100<=a[s/100])
    {
    sum++;
    }
    if(i=9220)
    {
    sum++;
    }

    }
    cout<<sum<<endl;
    return 0;
    }

  • -1
    @ 2017-02-16 09:27:34

    foo.cpp: In function 'int main()':
    foo.cpp:17:9: warning: unused variable 'i' [-Wunused-variable]
    int i,j,k,l=0,n,m;
    ^
    foo.cpp:17:11: warning: unused variable 'j' [-Wunused-variable]
    int i,j,k,l=0,n,m;
    ^
    测试数据 #0: Accepted, time = 0 ms, mem = 732 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 732 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 732 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 732 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 732 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 736 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 732 KiB, score = 10
    测试数据 #7: Accepted, time = 15 ms, mem = 732 KiB, score = 10
    测试数据 #8: Accepted, time = 93 ms, mem = 732 KiB, score = 10
    测试数据 #9: Accepted, time = 156 ms, mem = 732 KiB, score = 10
    Accepted, time = 264 ms, mem = 736 KiB, score = 100
    代码
    #include <bits/stdc++.h>
    using namespace std;

    bool hw(int a)
    {
    int x[11];
    for(int i=0;i<8;a/=10,i++) {
    x[i]=a%10;
    }
    for(int i=0,j=7;i<4;i++,j--) {
    if(x[i]!=x[j]) return 0;
    }
    return 1;
    }
    int main()
    {
    int i,j,k,l=0,n,m;
    cin>>n>>m;
    int x=n;
    for(;x<=m;) {
    bool run=false;
    if(x/10000%400==0||(x/10000%100!=0&&x/10000%4==0)) run=true;
    short flag;
    k=x/100%100;
    if(k==1||k==3||k==5||k==7||k==8||k==10||k==12) flag=2;
    else if(k==2) {
    if(run) flag=0;
    else {
    flag=-1;
    }
    }
    else flag=1;
    if(flag==2&&x%100==32) x+=69;
    else if(flag==1&&x%100==31) x+=70;
    else if(flag==0&&x%100==30) x+=71;
    else if(flag==-1&&x%100==29) x+=72;
    k=x/100%100;
    if(k==13) x=x+8800;
    if(hw(x)) l++;
    x++;
    }
    cout<<l<<endl;
    return 0;
    }

  • -1
    @ 2017-02-16 09:25:11

    #include <bits/stdc++.h>
    using namespace std;

    bool hw(int a)
    {
    int x[11];
    for(int i=0;i<8;a/=10,i++) {
    x[i]=a%10;
    }
    for(int i=0,j=7;i<4;i++,j--) {
    if(x[i]!=x[j]) return 0;
    }
    return 1;
    }
    int main()
    {
    int i,j,k,l=0,n,m;
    cin>>n>>m;
    int x=n;
    for(;x<=m;) {
    bool run=false;
    if(x/10000%400==0||(x/10000%100!=0&&x/10000%4==0)) run=true;
    short flag;
    k=x/100%100;
    if(k==1||k==3||k==5||k==7||k==8||k==10||k==12) flag=2;
    else if(k==2) {
    if(run) flag=0;
    else {
    flag=-1;
    }
    }
    else flag=1;
    if(flag==2&&x%100==32) x+=69;
    else if(flag==1&&x%100==31) x+=70;
    else if(flag==0&&x%100==30) x+=71;
    else if(flag==-1&&x%100==29) x+=72;
    k=x/100%100;
    if(k==13) x=x+8800;
    if(hw(x)) l++;
    x++;
    }
    cout<<l<<endl;
    return 0;
    }

  • -2
    @ 2017-09-17 10:48:16

    渣渣一群/中指

  • -2
    @ 2017-02-28 12:28:05

    #include<stdio.h>
    int r(int x)
    {
    int digit;
    int ret = 0;

    while ( x> 0 ) {
    digit = x%10;
    ret = ret*10 + digit;
    x /= 10;
    }
    return ret;
    }
    int n(int x){
    int y=x/10000;
    int m=(x % 10000)/100;
    x=x % 100;
    int d;
    switch (m){
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12: d=31;break;
    case 4:
    case 6:
    case 9:
    case 11: d=30;break;
    default :
    if ((y%4==0)&&(y%100!=0)||(y%400==0)) d=29;
    else d=28;
    }
    if ((0<m)&&(m<13)&&(x<=d)) return 1;
    else return 0;
    }
    int main(){
    int d1,d2;
    scanf("%d %d",&d1,&d2);
    int s=0;
    for (int i=d1/10000;i<=d2/10000;i++){
    int x=10000*i+r(i);
    if ((n(x))&&(x>=d1)&&(x<=d2)) {
    s++;
    }
    }
    printf("%d",s);
    }

  • -2
    @ 2017-02-16 09:49:09

    重要的事情说三遍!不用枚举!不用枚举!不用枚举!!!!!!
    #include<bits/stdc++.h>
    using namespace std;
    int mon[13]={-1,31,28,31,30,31,30,31,31,30,31,30,31};
    int main()
    {
    int d1,d2,f=0;
    cin>>d1>>d2;
    int y1=d1/10000;
    int y2=d2/10000;
    int sum=0;
    for(int i=y1;i<=y2;i++)
    {
    int d=i*10000+i%10*1000+i%100/10*100+i%1000/100*10+i%10000/1000;
    int m=d%10000/100;
    int day=d%100;
    if(m>=1&&m<=12)
    {
    if(day>=1&&day<=mon[m])sum++;
    }
    if(i==9220)sum++;
    }
    cout<<sum<<endl;
    return 0;
    }

    • @ 2017-02-16 09:53:09

      针对每个年份生成一个唯一的回文日期,然后判断是否符合日期标准即可,绝不会超时

    • @ 2017-02-17 20:21:05

      跟我 去年去比赛 一样的思路

信息

ID
2010
难度
4
分类
(无)
标签
递交数
1321
已通过
328
通过率
25%
被复制
21
上传者