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

 

C(HDU6298)

#include <bits/stdc++.h>

using namespace std ;

int calc ( int n ) {
    int ret = -1 , k ; 
    for ( int i=1 ; i<=n ; ++i ) {
        for ( int j=1 ; j<=n ; ++j ) {
            k = n - i - j ; 
            if ( k > 0 && (n%i==0) && (n%k==0) && (n%j==0) ) {
                ret = max ( ret , i * j * k ) ; 
            }
        }
    }
    return ret ;
}

int main ( ) {
    int N ;
    cin >> N ; 
    for ( int i=1 ; i<=N ; ++i ) 
        cout << i << '\t' ; 
    cout << endl ; 
    for ( int i=1 ; i<=N ; ++i ) {
        cout << calc ( i ) << '\t' ; 
    }
    return 0 ; 
}
C.list
#include <bits/stdc++.h>

using namespace std ; 
typedef long long ll ; 

ll INPUT ( ) {
    ll 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 ) {
        ll N = INPUT ( ) ; 
        if ( N % 3 == 0 ) {
            cout << ( N / 3 ) * ( N / 3 ) * ( N / 3 ) << endl ;
        }else 
        if ( N % 4 == 0 ) {
            cout << ( N / 4 ) * ( N / 4 ) * ( N / 2 ) << endl ; 
        }else {
            cout << "-1" << endl ; 
        }
    }
    return 0 ; 
}
C

 

D(HDU6300)

#include <bits/stdc++.h>

using namespace std ;
const int maxN = 1010 ;

struct point {
    int x , y , idx ; 
}mp[ maxN * 3 ];

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 ;
}

bool cmp ( point a , point b ) {
    if ( a.x == b.x ) return a.y < b.y ; 
    return a.x < b.x ; 
}

int main ( ) {
    for ( int T = INPUT ( ) ; T ; --T ) {
        int N = INPUT ( ) ; 
        for ( int i=1 ; i<=N * 3 ; ++i ) {
            mp[ i ].x = INPUT ( ) ;
            mp[ i ].y = INPUT ( ) ; 
            mp[ i ].idx = i ; 
        }
        sort ( mp + 1 , mp + N * 3 + 1 , cmp ) ; 
        for ( int i=1 ; i<=N * 3 ; ++i ) {
            printf ( "%d " , mp[ i ].idx ) ; 
            if ( i % 3 == 0 ) putchar ( '\n' ) ;
        }
    }
    return 0 ; 
} 
View Code

一开始题没读懂,排序也没想到。

posted @ 2018-10-30 22:44  SHHHS  阅读(171)  评论(0编辑  收藏  举报