• UVA


    113  Power of Cryptography

    1 #include<stdio.h>
    2 #include<math.h>
    3 int main()
    4 {
    5   double n,p;
    6   while(scanf("%lf%lf",&n,&p)!=EOF)
    7     printf("%.0lf
    ",pow(p,1/n));
    8   return 0;
    9 }
    View Code

    253  Cube painting

     1 #include<stdio.h>
     2 int main()
     3 {
     4     char cube1[7], cube2[7], cube[13];
     5     int i, j, found;
     6     while (scanf("%s", cube) != EOF)
     7     {
     8         for (i = 0; i < 6; i++)
     9             cube1[i] = cube[i];
    10         while (i<12)
    11             cube2[i - 6] = cube[i++];
    12             for (i = 0; i<3; i++)
    13             {
    14                 found = 0;
    15                 for (j = 0; j<6; j++)
    16                 {
    17                     if (cube1[i] == cube2[j] && cube1[5 - i] == cube2[5 - j])
    18                     {
    19                         found = 1;
    20                         cube2[j] = '0';
    21                         cube2[5 - j] = '0';
    22                         break;
    23                     }
    24                 }
    25                 if (!found)
    26                     break;
    27             }
    28         if (!found)
    29         {
    30             printf("FALSE
    ");
    31             continue;
    32         }
    33         printf("TRUE
    ");
    34     }
    35     return 0;
    36 }
    View Code

    573  The Snail

     1 #include<iostream>
     2 using namespace std;
     3 int main()
     4 {
     5     int day;
     6     double height,down;
     7     double  H, U, D, F;
     8     while (cin >> H >> U >> D >> F)
     9     {
    10         day =1;
    11         height = 0;
    12         if (H == 0 && U == 0 && D == 0 && F == 0)
    13             break;
    14         down = U*F / 100;
    15         while (1)
    16         {
    17             if (U > 0)
    18                 height += U;
    19             if (height > H)
    20             {
    21                 cout << "success on day " << day << endl;
    22                 break;
    23             }
    24             height -= D;  
    25             if (height <0)
    26             {
    27                 cout << "failure on day " << day << endl;
    28                 break;
    29             }
    30             U -= down;
    31             ++day;
    32         }
    33     }
    34     return 0;
    35 }
    View Code

    591  Box of Bricks

     1 #include<iostream>
     2 using namespace std;
     3 int main()
     4 {
     5     int n,i,sum,average,count,x=1;
     6     int num[50];
     7     while (cin >> n)
     8     {
     9         sum = 0;
    10         count = 0;
    11         if (n == 0)
    12             break;
    13         for (i = 0; i < n; i++)
    14         {
    15             cin >> num[i];
    16             sum += num[i];
    17         }
    18         average = sum / n;
    19         for (i = 0; i < n; i++)
    20             if (num[i]>average)
    21                 count +=  num[i]-average;
    22         cout << "Set #" << x++ << endl;
    23         cout << "The minimum number of moves is " << count <<'.'<< endl << endl;
    24     }
    25     return 0;
    26 }
    View Code

    621  Secret Research

     1 #include<iostream>
     2 #include<string>
     3 using namespace std;
     4 int main()
     5 {
     6     string s;
     7     int n;
     8     cin >> n;
     9     while (n--)
    10     {
    11         cin >> s;
    12         if (s == "1" || s == "4" || s == "78")
    13         {
    14             cout << '+' << endl;
    15             continue;
    16         }
    17         if (s[s.length() - 1] == '5'&&s[s.length() - 2] == '3')
    18         {
    19             cout << '-' << endl;
    20             continue;
    21         }
    22         if (s[0] == '9'&&s[s.length() - 1] == '4')
    23         {
    24             cout << '*' << endl;
    25             continue;
    26         }
    27         if (s[0] == '1'&&s[1] == '9'&&s[2] == '0')
    28         {
    29             cout << '?' << endl;
    30             continue;
    31         }
    32     }
    33     return 0;
    34 }
    View Code

    846  Steps

     1 #include<stdio.h>
     2 int main()
     3 {
     4     double m,n,dis;
     5     int T,step,ans;
     6     bool flag;
     7     scanf("%d", &T);
     8     while (T--)
     9     {
    10         scanf("%lf%lf", &m, &n);
    11         dis = n - m;
    12         step = 1;
    13         flag = 0;
    14         ans = 0;
    15         while (dis > 0)
    16         {
    17             dis -= step;
    18             ans++;
    19             if (flag)
    20                 ++step;
    21             flag = !flag;
    22         }
    23         printf("%d
    ",ans);
    24     }
    25     return 0;
    26 }
    View Code

    10499  The Land of Justice

     1 #include<stdio.h>
     2 int main()
     3 {
     4     double n;
     5     while (scanf("%lf", &n)!=EOF)
     6     {
     7         if (n < 0)
     8             return 0;
     9         if (n == 1)
    10             printf("0%%
    ");
    11         else
    12             printf("%.0lf%%
    ", 25 * n);
    13     }
    14     return 0;
    15 }
    View Code

    10916  Factstone Benchmark

     1 #include<cstdio>
     2 #include<cmath>
     3 #include<iostream>
     4 using namespace std;
     5 int main()
     6 {
     7     long x, y, k,z;
     8     double t,i;
     9     while (scanf("%d", &x) && x != 0)
    10     {
    11         t = 0;
    12         y = (x - 1960) / 10 + 2;
    13         z = pow(2, y);
    14         for (i = 1;; i++)
    15         {
    16             t += log10(i) / log10(2);
    17             if (t>z)
    18             {
    19                 k = i - 1;
    20                 break;
    21             }
    22         }
    23         printf("%d
    ", k);
    24     }
    25     return 0;
    26 }
    View Code

    10970  Big Chocolate

    1 #include<stdio.h>
    2 int main()
    3 {
    4     int m, n;
    5     while (scanf("%d%d", &m, &n) != EOF)
    6         printf("%d
    ",(m-1)+m*(n-1));
    7     return 0;
    8 }
    View Code

    11044  Searching for Nessy

     1 #include<stdio.h>
     2 int main()
     3 {
     4     int T;
     5     int m, n;
     6     scanf("%d", &T);
     7     while (T--)
     8     {
     9         scanf("%d%d", &m, &n);
    10         printf("%d
    ", (m / 3)*(n / 3));
    11     }
    12     return 0;
    13 }
    View Code
  • 相关阅读:
    shell 循环语句
    windows8运行zxing源码 生成与解码二维码 详解(含注释与图解可直接运行)
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    比Redis快5倍的中间件,究竟为什么这么快?
    机器学习——TensorFlow实战手写体识别
    移动通信网络中的 3A 实现
    比Redis快5倍的中间件,为啥这么快?
  • 原文地址:https://www.cnblogs.com/longzu/p/4481226.html
Copyright © 2020-2023  润新知