头像

ヅ天使ぺ嫙嵂




离线:1天前



题目描述

blablabla

样例

#include<iostream>
#include<cstdio>
using namespace std;

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

bool check_valid(int n)
{
    int year=n/1000;
    int mon=n%10000/100;
    int day=n%100;
    if(mon<0||mon>12) return false;
    if(day<0||day>days[mon]&&mon!=2) return false;
    int x=0;
    if(mon==2)
    {
        x=year%4==0&&year%100==0||year%400==0;
    }
    if(day>days[mon]+x) return false;
    return true;
}


int main()
{
    int date1,date2,res=0;
    cin>>date1>>date2;  
    for(int i=1000;i<10000;i++)
    {
        int x=i,t=i;
        for(int j=0;j<4;j++)
            x=x*10+t%10,t/=10;
        if(date1<=x&&date2>=x&&check_valid(x)) res++;
    }
    cout<<res<<endl;
    return 0;
}



题目描述

blablabla

样例

#include<iostream>

using namespace std;

int day[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};

int main()
{
    int sum,temp=0,data1,data2;
    cin>>data1>>data2;
    for(int mon=1;mon<=12;mon++)
    {
        for(int i=1;i<=day[mon];i++)
        {               //i%10求天数的个位 i/10天数的十位  mon%10月份的个位.... 
            sum=mon*100+i+i%10*10000000+i/10*1000000+ mon%10*100000+mon/10*10000; 
            if(sum<data1 || sum>data2) continue;
            temp ++; 
        }
    }
    cout<<temp;
    return 0; 
} 

-




题目描述

blablabla

样例

#include<iostream>
#include<cstring>
using namespace std;
const int N = 110;
int main()
{
    string s1, s2;
    int sum = 0;
    cin >> s1 >> s2;
    for (int i = 0; i < s1.size() - 1; i++)
    {
        if (s1[i] != s2[i])
        {
            sum++;
            if (s1[i] == '*') 
                s1[i] = 'o';
            else 
                s1[i] = '*';
            if (s1[i+1] == 'o') 
                s1[i+1] = '*';
            else 
                s1[i+1] = 'o';
        }
    }
    cout <<sum;
    return 0;
}




题目描述

blablabla

样例

#include<iostream>
using namespace std;
const int N =110;

int n,m;
int a[N][N],b[N][N];

int main()
{
    cin>>n>>m;
    for(int i = 0;i < n;i ++)
        for(int j = 0;j < m;j ++)
        {
            cin>>a[i][j];

            b[j][n-i-1] = a[i][j]; 
        }

    for(int i = 0;i < m;i ++)
    {
        for(int j = 0;j < n;j ++)
            printf("%d ",b[i][j]);
        puts("");
    }
    return 0;
}






题目描述

blablabla

样例

#include<bits/stdc++.h> 
using namespace std; 
const int N=10010; 
int a[N]; 
int main() 
{ 
    int n; 
    cin>>n; 
    for(int i=0;i<n;i++) 
    { 
        cin>>a[i]; 
    } 
    int temp=0; 
    for(int i=1;i<n;i++)
    { 
        temp=max(temp, abs(a[i] - a[i-1])); 
    } 
    cout << temp << endl; 
    return 0; 
}




题目描述

blablabla

样例

#include <iostream>
using namespace std;
const int N = 10001;
int main()
{
    int l, r;
    cin >> l >> r;
    int res = 0;
    for (int i = l; i <= r; i ++ )
        for (int j = i; j; j /= 10)
            if (j % 10 == 2)
                res ++ ;
    cout << res << endl;
    return 0;
}




题目描述

blablabla

样例

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int a, b, c, i;
    scanf("%d %d %d",&a,&b,&c);
    for(i = 1; ; i ++ )
    {
        if(i % a == 0 && i % b == 0 && i % c == 0)
        {
            cout<<i;
            break;
        }
    }
    return 0;
}




题目描述

blablabla

样例

#include<iostream>
#include<cstdio>
using namespace std;
const int N = 1e4 + 10;
int main()
{
    int n,a[N];
    double sum = 0;
    cin >> n;
    for(int i = 0; i < n; i ++ )
    {
        cin >> a[i];
    }
    int max = a[0], min = a[0];
    for(int i = 0; i < n; i ++ )
    {
        if(max<a[i])
            max = a[i];
    }
    for(int i = 0; i < n; i ++ )
    {
        if(min>a[i])
            min = a[i];
    }
    cout<<max<<endl<<min<<endl;
    for(int i = 0; i < n; i ++ )
    {
        sum+=a[i];
    }
    double ave = sum/n;

    printf("%.2lf",ave);

    return 0;
}




题目描述

blablabla

样例

#include<iostream>
using namespace std;
int main() {
    int x, y;
    int sum = 0;
    cin >> x >> y;
    if(x > y)
    {
        int t=y;
        y=x;
        x=t;
    }
    for(int i=x+1;i<y;i++) 
    {
        if(i%2==1 || i%2==-1 ) 
            sum+=i;
    }
    cout<<sum<<endl;
    return 0;
}



题目描述

blablabla

样例

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(b>c&&d>a&&c+d>a+b&&c>0&&d>0&&a%2==0) cout<<"Valores aceitos"<<endl;
    else cout<<"Valores nao aceitos"<<endl;
    return 0;
}


算法1

(暴力枚举) $O(n^2)$

blablabla

时间复杂度

参考文献

C++ 代码

blablabla

算法2

(暴力枚举) $O(n^2)$

blablabla

时间复杂度

参考文献

C++ 代码

blablabla