20181028

A(HDU6124)

#include <bits/stdc++.h>

using namespace std ; 

int INPUT ( ) {
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return x*f ;
}

int main ( ) {
    for ( int T = INPUT ( ) ; T ; --T ) {
        int N = INPUT ( ) ; 
        if ( N & 1 ) cout << ( N / 2 ) + 2 << endl ; 
        else cout << ( N / 2 ) + 1 << endl ; 
    }
    return 0 ;
}
View Code
#include <bits./stdc++.h>

using namespace std ;

int main ( ) {
    int N ; 
    int buc[ 100 ] ; 
    cin >> N ; 
    for ( int i=1 ; i<=N ; ++i ) 
        cout << i << '\t' ;
    putchar( '\n' ) ;
    for ( int i=1 ; i<=N ; ++i ) {
        memset ( buc , 0 , sizeof ( buc ) ) ;
        int _cnt= 0 ; 
        for ( int j=1 ; j<=i + 1 ; ++j ) {
            buc[ i % j ] = true ;  
        }
        for ( int i=0 ; i<=N+1 ; ++i ) {
            if ( buc[ i ] ) ++ _cnt ; 
        }
        cout << _cnt << '\t' ; 
    }
    
    return 0 ; 
}
A.list

猜你喜欢

转载自www.cnblogs.com/shadowland/p/9880163.html