zoukankan      html  css  js  c++  java
  • 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 << '	' ;
        putchar( '
    ' ) ;
        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 << '	' ; 
        }
        
        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 << '	' ; 
        cout << endl ; 
        for ( int i=1 ; i<=N ; ++i ) {
            cout << calc ( i ) << '	' ; 
        }
        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 ( '
    ' ) ;
            }
        }
        return 0 ; 
    } 
    View Code

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

  • 相关阅读:
    趣图:程序员告诉你为什么充钱后速度更快
    金三银四铜五铁六,面试得做好这个准备
    Java中如何模拟真正的同时并发请求?
    趣图:程序员最头疼的原因
    Java并发面试题
    linux内存分配与回收
    7.3 Set集合
    7.2 Java 11新增的Collection和Iterator接口
    7.1 Java集合概念
    6.5 正则表达式
  • 原文地址:https://www.cnblogs.com/shadowland/p/9880163.html
Copyright © 2011-2022 走看看