主页

· · 个人记录

O2优化:

#pragma GCC optimize(2)
//神奇的主函数
#include<bits/stdc++.h>
using namespace std;
int n;
bool zt=true;
int main(int i){
    if(zt){
        cout<<"请输入一个不大于50000的正整数:"; 
        cin>>n;
        zt=false;
    }
    if(i==n){
        cout<<i<<" ";
        return i-1;
    }
    cout<<i<<" ";
    cout << main(++i) <<" ";
    return i-2;
}
#include<bits/stdc++.h>
using namespace std;
long long pow3(int a, int b);
int main(int a){
    int n,m;
    if(a!=1){
        cout<<a<<endl;
    }
    cin>>n>>m;
    cout<<pow3(n,m)<<endl;
    return main(a+1);
}
long long pow3(int a,int b)
{
    long long r=1;
    while(b>0){
    if(b%2==1) r*=a;
        a*=a;
        b/=2;
    }
    return main(r);
}
//快速幂
int ksm(int k, int n){
    if(n==0){
        return 1;
    }else if(n==1){
        return k;
    }else{
        long long p = ksm(k,n/2);
        if(n%2){
            return k*p*p;
        }else{
            return p*p;
        }
    } 
}

快读快写

std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
#include<iostream>  
#include<cstdio>   
#include<cstring>  
#include<windows.h>  
using namespace std;

char a[17][17];  
int sfw = 0;
void dy(){  
    cout << endl << "0 1 2 3 4 5 6 7 8 91011121314151617"<<endl;  
    for( int i = 0; i <= 16; i++){
        cout << i+1; 
        if( i+1 <= 9){ 
            cout <<" "; 
        } 
        for( int j = 0; j <= 16; j ++){
            cout << a[i][j] << " " ; 
        } 
        cout << endl; 
    }
    int x=0, y=0;
    for(int i = 0; i < 17; i++){
        for(int j = 0;j<17;j++){
            if(a[i][j] == '+'){
                x = 0;
                y = 0;
            }else if( a[i][j] == 'O'){
                x++;
                y = 0;
                if( x == 5){
                    cout<<"O Win!"<<endl;
                    sfw = 1;
                    return;
                }
            }else if( a[i][j] == 'X'){
                y++;
                x = 0;
                if( y == 5){
                    cout<<"X Win!"<<endl;
                    sfw = 2;
                    return;
                }               
            }
        }
    }
    x = 0;
    y = 0;
    for(int j = 0; j < 17; j++){
        for(int i = 0;i<17;i++){
            if(a[i][j] == '+'){
                x = 0;
                y = 0;
            }else if( a[i][j] == 'O'){
                x++;
                y = 0;
                if( x == 5){
                    cout<<"O Win!"<<endl;
                    sfw = 1;
                    return;
                }
            }else if( a[i][j] == 'X'){
                y++;
                x = 0;
                if( y == 5){
                    cout<<"X Win!"<<endl;
                    sfw = 2;
                    return;
                }               
            }
        }
    }
    x = 0;
    y = 0;
    for(int i = 0; i < 17; i++){
        for(int j = 0, k = i;j<17,k<17;k++,j++){
            if(a[i][k] == '+'){
                x = 0;
                y = 0;
            }else if( a[i][k] == 'O'){
                x++;
                y = 0;
                if( x == 5){
                    cout<<"O Win!"<<endl;
                    sfw = 1;
                    return;
                }
            }else if( a[i][k] == 'X'){
                y++;
                x = 0;
                if( y == 5){
                    cout<<"X Win!"<<endl;
                    sfw = 2;
                    return;
                }               
            }
        }
    }
    x = 0;
    y = 0;
    for(int j = 0; j < 17; j++){
        for(int i = 0, k = j;i<17,k<17;k++,i++){
            if(a[i][k] == '+'){
                x = 0;
                y = 0;
            }else if( a[i][k] == 'O'){
                x++;
                y = 0;
                if( x == 5){
                    cout<<"O Win!"<<endl;
                    sfw = 1;
                    return;
                }
            }else if( a[i][k] == 'X'){
                y++;
                x = 0;
                if( y == 5){
                    cout<<"X Win!"<<endl;
                    sfw = 2;
                    return;
                }               
            }
        }
    }
    x = 0;
    y = 0;
    for(int i = 16; i >= 0; i--){
        for(int j = 16, k = i;j>=0,k>=0;k--,j--){
            if(a[i][k] == '+'){
                x = 0;
                y = 0;
            }else if( a[i][k] == 'O'){
                x++;
                y = 0;
                if( x == 5){
                    cout<<"O Win!"<<endl;
                    sfw = 1;
                    return;
                }
            }else if( a[i][k] == 'X'){
                y++;
                x = 0;
                if( y == 5){
                    cout<<"X Win!"<<endl;
                    sfw = 2;
                    return;
                }               
            }
        }
    }
    x = 0;
    y = 0;
    for(int j = 16; j >=0; j--){
        for(int i = 16, k = j;i>=0,k>=0;k--,i--){
            if(a[i][k] == '+'){
                x = 0;
                y = 0;
            }else if( a[i][k] == 'O'){
                x++;
                y = 0;
                if( x == 5){
                    cout<<"O Win!"<<endl;
                    sfw = 1;
                    return;
                }
            }else if( a[i][k] == 'X'){
                y++;
                x = 0;
                if( y == 5){
                    cout<<"X Win!"<<endl;
                    sfw = 2;
                    return;
                }               
            }
        }
    }
} 

int main(){ 

    int b, c, d = 0, e = 0; 

    for( int i = 0; i <= 16; i++){

        for( int j = 0; j <= 16; j ++){

            a[i][j] = '+';

        } 

    } 
    for( int i = 0;i + 1 != 0; i += 1){
        system("cls");
        cout << d+1 << " " << e+1;
        dy();
        if( sfw != 0){
            return 0;
        }
        cin >> b >> c;
        b--; 
        c--; 
        if( b == 99 || c == 99){
            a[d][e] = '+'; 
            continue; 
        }else if( b == 999 || c == 999){ 
            for( int i = 0; i <= 16; i++){ 
                for( int j = 0; j <= 16; j ++){ 
                    a[i][j] = '+'; } 
                }   
                continue;   
        }else if( i % 2 == 0 && a[b][c] == '+' &&b < 17&&c<17){
            a[b][c] = 'O'; 
            d = b; 
            e = c; 
        }else if( a[b][c] == '+'&&b < 17&&c<17){ 
            a[b][c] = 'X'; d = b; e = c; 
        }else{ 
            i--; 
        } 
    }   
}
//_____________________________________
#include<iostream>
#include<cstdio>
#include<windows.h>  
int c;
long long p;
long long m;
long long jc;
using namespace std;
long long b(long long);
bool pds(long long s){
    for(long long i = 2; i*i<=s;i++){
        if(s%i==0){
            return false;
        }
    }
    return true;
}
long long a(long long s,long long x){
    jc++;
    if(pds(s)){
        p++;
        if(p==m){
            cout <<s<<endl;
        }
    }           
    return 1;
} 
int main(){
    for(long long i = 1; i%2 == 1; i+=2){
        cin>>m;
        p++;
        jc = 3;
        if(m==1){
            cout << 2<<endl;
        }else{
            c = 3;
            p = 1;
            for(long long i = 0;i<m;i=p){
                a(jc,jc);           
            }
        }
    }
    return 0;
}
//___________________________________
#include<iostream>
#include<cstdio>
#include<windows.h>
using namespace std;
int main(){
    int a[10000], b=-1,jc=0,b1=-1,b2=101;
    for(int i = 0; i<10000;i++){
        if(a[i]<0){
            a[i]=0-a[i];
        }
        a[i]%=100;
        if(a[i]!=0){
            a[i]+=1;
        }else if(i>0){
            a[i]+=a[0];
        }else if(i<9999){
            a[i]+=a[9999];
        }
        a[i]%=100;
        if(a[i]<0){
            a[i]=0-a[i];
        }
    }
    for(int i = 0;i<10000;jc=0,i++,b1=-1,b2=101){
        while(b!=a[i]){
            cout<<b1+1<<"-----"<<b2-1<<endl;    
            cin>>b;
            while(b>=b2||b<=b1){
                cout<<"重新输入"<<endl; 
                cin>>b;
            }
            jc++;
            if(b>a[i]){
                b2=b;
                cout<<"大了"<<endl; 
            }else if(b<a[i]){
                b1=b;
                cout<<"小了"<<endl; 
            }else{
                system("cls");
                cout<<"Bomb,共用了"<<jc<<"次机会\n"; 
                Sleep(1000);
                b=a[i];
            }
        }   
    } 
    return 0;
}

NO