zoukankan      html  css  js  c++  java
  • 2017ACM/ICPC广西邀请赛

    A.A Math Problem

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 typedef long long ll;
     4 inline ll read(){
     5     int x=0,f=1;char ch=getchar();
     6     while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
     7     while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
     8     return x*f;
     9 }
    10 
    11 /***********************************************************/
    12 
    13 const int maxn = 1e5+7;
    14 ll a[maxn];
    15 
    16 void init(){
    17     for(ll i = 1;i <= 15;i++){
    18         a[i] = 1;
    19         for(ll j = 1;j <= i;j++){
    20             a[i] *= i;
    21         }
    22         //cout << i << " :" << a[i] << endl;
    23     }
    24 }
    25 
    26 
    27 int main(){
    28     init();
    29     ll n;
    30     while(~scanf("%lld", &n)){
    31         int ans = 0;
    32         for(ll i = 1;i <= 15;i++){
    33             if(n >= a[i])
    34                 ans++;
    35             else break;
    36         }
    37         cout << ans << endl;
    38     }
    39     return 0;
    40 }
    View Code

    G.Duizi and Shunzi

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 typedef long long ll;
     4 inline ll read(){
     5     int x=0,f=1;char ch=getchar();
     6     while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
     7     while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
     8     return x*f;
     9 }
    10 
    11 /***********************************************************/
    12 
    13 const int maxn = 1e6+7;
    14 int a[maxn];
    15 
    16 int main(){
    17     int n;
    18     while(~scanf("%d", &n)){
    19         memset(a, 0, sizeof(a));
    20         for(int i = 1;i <= n;i++){
    21             int x;
    22             x = read();
    23             a[x]++;
    24         }
    25         int ans = 0;
    26         for(int i = 1;i <= n;i++){
    27             ans += a[i]/2;
    28             a[i] %= 2;
    29             if(i+2 <= n){
    30                 if(a[i] && a[i+1]%2 && a[i+2]){
    31                     ans++;
    32                     a[i]--;a[i+1]--;a[i+2]--;
    33                 }
    34             }
    35             
    36         }
    37         printf("%d
    ", ans);
    38     }
    39     return 0;
    40 }
    View Code
  • 相关阅读:
    java使用jacob实现word转pdf
    解决 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
    tp框架基本sql语句查询与链式查询
    id和class的区别
    查找算法
    排序算法
    [转]微信小程序开发:从小白开发出通过自拍预测年龄和颜值的小程序
    [转]天天生鲜,html效果布局
    利用乐观锁及redis解决电商秒杀高并发基本逻辑
    Python3.6.0安装
  • 原文地址:https://www.cnblogs.com/ouyang_wsgwz/p/9774783.html
Copyright © 2011-2022 走看看