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
  • 相关阅读:
    Tensorflow中张量的数学运算
    TensorFlow2.0中tf.concat和tf.stack的区别
    机器学习之K-Means(聚类分析)
    机器学习之线性回归
    机器学习之随机森林
    机器学习之决策树
    python爬取FTP文件,并批量下载到本地。
    ATOM系列之-atom报错"Cannot load the system dictionary for zh-CN"
    开机出现loading (hd0)/ntldr。。。
    如何制作一张符合上传的照片
  • 原文地址:https://www.cnblogs.com/ouyang_wsgwz/p/9774783.html
Copyright © 2011-2022 走看看