A. Numbers Joke

time limit per test:2 seconds
memory limit per test:64 megabytes
input:standard input
output:standard output

Input

The input contains a single integer a (1 ≤ a ≤ 30).

Output

Output a single integer.

Example
Input
3

Output
27

题目链接:http://codeforces.com/contest/784/problem/A

分析:百度史蒂芬数,直接打表求解!

下面给出AC代码:

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {
 5     int n;
 6     while(cin>>n)
 7     {
 8         if(n==1)
 9         cout<<4<<endl;
10         else if(n==2)
11             cout<<22<<endl;
12             else if(n==3)
13             cout<<27<<endl;
14             else if(n==4)
15             cout<<58<<endl;
16             else if(n==5)
17             cout<<85<<endl;
18             else if(n==6)
19             cout<<94<<endl;
20             else if(n==7)
21             cout<<121<<endl;
22             else if(n==8)
23             cout<<166<<endl;
24             else if(n==9)
25             cout<<202<<endl;
26             else if(n==10)
27             cout<<265<<endl;
28             else if(n==11)
29             cout<<274<<endl;
30             else if(n==12)
31             cout<<319<<endl;
32             else if(n==13)
33             cout<<346<<endl;
34             else if(n==14)
35             cout<<355<<endl;
36             else if(n==15)
37             cout<<378<<endl;
38             else if(n==16)
39             cout<<382<<endl;
40             else if(n==17)
41             cout<<391<<endl;
42             else if(n==18)
43             cout<<438<<endl;
44             else if(n==19)
45             cout<<454<<endl;
46             else if(n==20)
47             cout<<483<<endl;
48              else if(n==21)
49             cout<<517<<endl;
50              else if(n==22)
51             cout<<526<<endl;
52              else if(n==23)
53             cout<<535<<endl;
54              else if(n==24)
55             cout<<562<<endl;
56              else if(n==25)
57             cout<<576<<endl;
58              else if(n==26)
59             cout<<588<<endl;
60              else if(n==27)
61             cout<<627<<endl;
62              else if(n==28)
63             cout<<634<<endl;
64              else if(n==29)
65             cout<<636<<endl;
66              else if(n==30)
67             cout<<645<<endl;
68     }
69     return 0;
70 }

B. Kids' Riddle

time limit per test:2 seconds
memory limit per test:64 megabytes
input:standard input
output:standard output

Programmers' kids solve this riddle in 5-10 minutes. How fast can you do it?

Input

The input contains a single integer n (0 ≤ n ≤ 2000000000).

Output

Output a single integer.

Examples
Input
11

Output
2

Input
14

Output
0

Input
61441

Output
2

Input
571576

Output
10

Input
2128506

Output
3

题目链接:http://codeforces.com/contest/784/problem/B

分析:化成16进制,然后数圈圈(B有两个洞。。。。。)
下面给出AC代码:
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define ll long long
 4 string s;
 5 int a,b,c,d;
 6 int main()
 7 {
 8     int ans;
 9     cin>>ans;
10     if(ans==0)
11     {
12         a++;
13     }
14     while(ans)
15     {
16         if(ans%16==10)
17         {
18             a++;
19         }
20         else if(ans%16==11)
21         {
22             a+=2;
23         }
24         else if(ans%16==13)
25         {
26             a++;
27         }
28         else if(ans%16==6)
29         {
30             a++;
31         }
32         else if(ans%16==8)
33         {
34             a+=2;
35         }
36         else if(ans%16==9)
37         {
38             a++;
39         }
40         else if(ans%16==0)
41         {
42             a++;
43         }
44         else if(ans%16==4)
45         {
46             a++;
47         }
48         ans/=16;
49     }
50     cout<<a<<endl;
51     return 0;
52 }

C. INTERCALC

time limit per test:2 seconds
memory limit per test:64 megabytes
input:standard input
output:standard output

DO YOU EXPECT ME TO FIND THIS OUT?

WHAT BASE AND/XOR LANGUAGE INCLUDES string?

DON'T BYTE OF MORE THAN YOU CAN CHEW

YOU CAN ONLY DISTORT THE LARGEST OF MATHEMATICS SO FAR

SAYING "ABRACADABRA" WITHOUT A MAGIC AND WON'T DO YOU ANY GOOD

THE LAST STACK RUPTURES. ALL DIE. OH, THE EMBARRASSMENT!

I HAVE NO ARRAY AND I MUST SCREAM

ELEMENTS MAY NOT BE STORED IN WEST HYPERSPACE

Input

The first line of input data contains a single integer n (1 ≤ n ≤ 10).

The second line of input data contains n space-separated integers ai (1 ≤ ai ≤ 11).

Output

Output a single integer.

Example
Input
4 2 5 3 1

Output
4

题目链接:http://codeforces.com/contest/784/problem/C

分析:把每句其中几个字取出来,组合在一起,就是最大值和最后一个数异或
下面给出AC代码:
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define ll long long
 4 int n,x,mx=0;
 5 int main()
 6 {
 7     cin>>n;
 8     for(int i=1;i<=n;i++)
 9         cin>>x,mx=max(mx,x);
10     cout<<(x^mx);
11     return 0;
12 }

D. Touchy-Feely Palindromes

time limit per test:2 seconds
memory limit per test:64 megabytes
input:standard input
output:standard output

Input

The only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.

Output

Output "Yes" or "No".

Examples
Input
373

Output
Yes

Input
121

Output
No

Input
436

Output
Yes

题目链接:http://codeforces.com/contest/784/problem/D

分析:看是不是回文(436中4,6盲文对称,所以s[4]=6)

下面给出AC代码:

 1 #include<cstdio>
 2 #include<iostream>
 3 #include<cstring>
 4 using namespace std;
 5
 6 int s[]={8,-1,-1,-1,6,9,4,-1,0,5};
 7 char st[12313];
 8
 9 int main()
10 {
11     scanf("%s",st+1);int n=strlen(st+1);
12     for(int i=1,j=n;i<j;i++,j--)
13         if(st[i]!=st[j]&&s[st[i]-'0']!=st[j]-'0') return 0*puts("No");
14     if(n&1){if(st[n/2+1]!='3'&&st[n/2+1]!='7')return 0*puts("No");}
15     puts("YES");
16     return 0;
17 }

E. Twisted Circuit

time limit per test:2 seconds
memory limit per test:64 megabytes
input:standard input
output:standard output

Input

The input consists of four lines, each line containing a single digit 0 or 1.

Output

Output a single digit, 0 or 1.

Example
Input
0 1 1 0

Output
0

题目链接:http://codeforces.com/contest/784/problem/E

分析:一个数字电路,不过或门和异或门是反的,所以。。注意下

下面给出AC代码:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define ll long long
 4 string s;
 5 int a,b,c,d;
 6 int main()
 7 {
 8     cin>>a>>b>>c>>d;
 9     printf("%d\n",((a^b)&(c|d))^((b&c)|(a^d)));
10     return 0;
11 }

F. Crunching Numbers Just for You

time limit per test:2 seconds
memory limit per test:64 megabytes
input:standard input
output:standard output

You are developing a new feature for the website which sells airline tickets: being able to sort tickets by price! You have already extracted the tickets' prices, so there's just the last step to be done...

You are given an array of integers. Sort it in non-descending order.

Input

The input consists of a single line of space-separated integers. The first number is n (1 ≤ n ≤ 10) — the size of the array. The following n numbers are the elements of the array (1 ≤ ai ≤ 100).

Output

Output space-separated elements of the sorted array.

Example
Input
3 3 1 2

Output
1 2 3 

Note

Remember, this is a very important feature, and you have to make sure the customers appreciate it!

题目链接:http://codeforces.com/contest/784/problem/F

分析:

排序。不过必须运行时间超过1s,不会怎么控制时间?有个好办法,随便找个代码,反正要运行1s以上的,加进去,然后输出结果就好了,这里我用了网络赛的代码

下面给出AC代码:

  1 #include<bits/stdc++.h>
  2 using namespace std;
  3
  4 #define MAXN 100
  5 #define MAXM 10001
  6 #define MAXP 266666
  7 #define MAX 3200001
  8 #define clr(ar) memset(ar, 0, sizeof(ar))
  9 #define read() freopen("lol.txt", "r", stdin)
 10 #define dbg(x) cout << #x << " = " << x << endl
 11 #define chkbit(ar, i) (((ar[(i) >> 6]) & (1 << (((i) >> 1) & 31))))
 12 #define setbit(ar, i) (((ar[(i) >> 6]) |= (1 << (((i) >> 1) & 31))))
 13 #define isprime(x) (( (x) && ((x)&1) && (!chkbit(ar, (x)))) || ((x) == 2))
 14
 15
 16 namespace pcf
 17 {
 18 long long dp[MAXN][MAXM];
 19 unsigned int ar[(MAX >> 6) + 5] = {0};
 20 int len = 0, primes[MAXP], counter[MAX];
 21
 22 void Sieve()
 23 {
 24     setbit(ar, 0), setbit(ar, 1);
 25     for (int i = 3; (i * i) < MAX; i++, i++)
 26     {
 27         if (!chkbit(ar, i))
 28         {
 29             int k = i << 1;
 30             for (int j = (i * i); j < MAX; j += k) setbit(ar, j);
 31         }
 32     }
 33
 34     for (int i = 1; i < MAX; i++)
 35     {
 36         counter[i] = counter[i - 1];
 37         if (isprime(i)) primes[len++] = i, counter[i]++;
 38     }
 39 }
 40
 41 void init()
 42 {
 43     Sieve();
 44     for (int n = 0; n < MAXN; n++)
 45     {
 46         for (int m = 0; m < MAXM; m++)
 47         {
 48             if (!n) dp[n][m] = m;
 49             else dp[n][m] = dp[n - 1][m] - dp[n - 1][m / primes[n - 1]];
 50         }
 51     }
 52 }
 53
 54 long long phi(long long m, int n)
 55 {
 56     if (n == 0) return m;
 57     if (primes[n - 1] >= m) return 1;
 58     if (m < MAXM && n < MAXN) return dp[n][m];
 59     return phi(m, n - 1) - phi(m / primes[n - 1], n - 1);
 60 }
 61
 62 long long Lehmer(long long m)
 63 {
 64     if (m < MAX) return counter[m];
 65
 66     long long w, res = 0;
 67     int i, a, s, c, x, y;
 68     s = sqrt(0.9 + m), y = c = cbrt(0.9 + m);
 69     a = counter[y], res = phi(m, a) + a - 1;
 70     for (i = a; primes[i] <= s; i++) res = res - Lehmer(m / primes[i]) + Lehmer(primes[i]) - 1;
 71     return res;
 72 }
 73 }
 74
 75 long long solve(long long n)
 76 {
 77     int i, j, k, l;
 78     long long x, y, res = 0;
 79
 80     /*for (i = 0; i < pcf::len; i++){
 81          printf("%I64d\n",pcf::Lehmer(n));
 82          x = pcf::primes[i], y = n / x;
 83          if ((x * x) > n) break;
 84          res += (pcf::Lehmer(y) - pcf::Lehmer(x));
 85      }
 86
 87      for (i = 0; i < pcf::len; i++){
 88          x = pcf::primes[i];
 89          if ((x * x * x) > n) break;
 90          res++;
 91      }*/
 92     res=pcf::Lehmer(n);
 93     return res;
 94 }
 95 int xx[100];
 96 int main()
 97 {
 98     pcf::init();
 99     long long n, res;
100     while(cin>>n)
101     {
102         int x=solve(100000000000);
103         for(int i=1; i<=n; i++)
104         {
105             cin>>xx[i];
106         }
107         sort(xx+1,xx+n+1);
108         for(int i=1; i<=n; i++)
109         {
110             cout<<xx[i]<<" ";
111         }
112     }
113     return 0;
114 }

G. BF Calculator

time limit per test:2 seconds
memory limit per test:64 megabytes
input:standard input
output:standard output

In this problem you will write a simple generator of Brainfuck (https://en.wikipedia.org/wiki/Brainfuck) calculators.

You are given an arithmetic expression consisting of integers from 0 to 255 and addition/subtraction signs between them. Output a Brainfuck program which, when executed, will print the result of evaluating this expression.

We use a fairly standard Brainfuck interpreter for checking the programs:

  • 30000 memory cells.
  • memory cells store integers from 0 to 255 with unsigned 8-bit wraparound.
  • console input (, command) is not supported, but it's not needed for this problem.
Input

The only line of input data contains the arithmetic expression. The expression will contain between 2 and 10 operands, separated with arithmetic signs plus and/or minus. Each operand will be an integer between 0 and 255, inclusive. The calculations result is guaranteed to be an integer between 0 and 255, inclusive (results of intermediary calculations might be outside of these boundaries).

Output

Output a Brainfuck program which, when executed, will print the result of evaluating this expression. The program must be at most 5000000 characters long (including the non-command characters), and its execution must be complete in at most 50000000 steps.

Examples
Input
2+3

Output
++> +++> <[<+>-]< ++++++++++++++++++++++++++++++++++++++++++++++++.

Input
9-7

Output
+++++++++> +++++++> <[<->-]< ++++++++++++++++++++++++++++++++++++++++++++++++.

Note

You can download the source code of the Brainfuck interpreter by the link http://assets.codeforces.com/rounds/784/bf.cpp. We use this code to interpret outputs.

题目链接:http://codeforces.com/contest/784/problem/G

分析:

给定一个表达式求值,输出一份BrainFuck语言写的可以算出答案的代码。

先算出答案,然后按照BrainFuck语言的一套理论,+表示计数器+1,-表示计数器-1,.(点)表示输出计数器的asc码对应的字符。所以+48之后随便输出呗!

下面给出AC代码:

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3
 4 char st[1231000];
 5 int op[1231231],num[12313],cnt=0;
 6
 7 int calc(int l,int r)
 8 {
 9     int x=0;
10     for(int i=l;i<=r;i++)
11         x=x*10+st[i]-'0';
12     return x;
13 }
14
15 void work(int&th,int x)
16 {
17     int to=x+48;
18     while(th>to)th--,printf("-");
19     while(th<to)th++,printf("+");
20     printf(".\n");
21 }
22
23 int main()
24 {
25     scanf("%s",st+1);int pre=0;
26     for(int i=1;st[i];i++)
27     {
28         if(st[i]=='+'||st[i]=='-')
29         {
30             op[++cnt]=(st[i]=='+')?1:2;
31             num[cnt]=calc(pre+1,i-1);
32             pre=i;
33         }
34     }
35     num[++cnt]=calc(pre+1,strlen(st+1));
36     int x=num[1];
37     for(int i=1;i<cnt;i++)
38     {
39         if(op[i]==1)x=x+num[i+1];
40         else x=x-num[i+1];
41     }
42     int th=0;cnt=0;
43     if(!x) {work(th,0);return 0;}
44     while(x)
45     {
46         num[++cnt]=x%10;x/=10;
47     }
48     for(int i=cnt;i;i--)
49         work(th,num[i]);
50     return 0;
51 }

April Fools Contest 2017 题解源码(A,数学 B,数学 C,数学 D,字符串 E,数字逻辑 F,排序,卡时间,G,数学)...相关推荐

  1. April Fools Contest 2017 题解

    趁着上课无聊,来补一补-- A. Numbers Joke 直接oeis就好了:http://oeis.org/search?q=numbers+joke&language=english&a ...

  2. ECJTUACM16 Winter vacation training #4 题解源码

    https://vjudge.net/contest/149692#overview 这周一VJ比赛,题解&源码已完成! A.................................. ...

  3. 数据结构源码笔记(C语言):可变长度字符串的快速排序

    //实现可变长度的字符串序列快速排序算法#include<stdio.h> #include<malloc.h> #include<string.h>#define ...

  4. 数据结构源码笔记(C语言):统计字符串中出现的字符及其次数

    //统计一个字符串中出现的字符及其次数 #include<stdio.h> #include<malloc.h> #include<string.h>#define ...

  5. pytorch实现手写数字识别_送源码!人工智能实现:识别图片中的手写数字,值得收藏...

    作者|小林同学 关注<高手杰瑞>,每天有不一样的实用小教程发布哦! 哈喽,大家好我是杰瑞.今天我给大家带来一个用机器学习的方法来实现手写数字识别的教程,就像C语言中输出的那一行" ...

  6. Redis源码阅读笔记(1)——简单动态字符串sds实现原理

    首先,sds即simple dynamic string,redis实现这个的时候使用了一个技巧,并且C99将其收录为标准,即柔性数组成员(flexible array member),参考资料见这里 ...

  7. 2017广东工业大学程序设计竞赛决赛 题解源码(A,数学解方程,B,贪心博弈,C,递归,D,水,E,贪心,面试题,F,贪心,枚举,LCA,G,dp,记忆化搜索,H,思维题)...

    心得: 这比赛真的是不要不要的,pending了一下午,也不知道对错,直接做过去就是了,也没有管太多! Problem A: 两只老虎 Description 来,我们先来放松下,听听儿歌,一起&qu ...

  8. 2017年浙江理工大学程序设计竞赛校赛 题解源码(A.水, D. 简单贪心 ,E.数论,I 暴力)...

    Problem A: 回文 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 1719  Solved: 528 Description 小王想知道一个字 ...

  9. April Fools Contest 2018[cf 愚人节专场题解]

    大家一起打愚人节的比赛还是挺有意思的!~~ 然而没有学弟留下来打比赛真是有点点小遗憾呢~ A:题目不要怕,只要胆子大 %2就好了 B: 给了两只猫,每只猫分为九个部分,有部分相同,有部分不同,你去摸猫 ...

最新文章

  1. php自定义函数出现乱码,php的imagettftext 函数出现乱码的解决方法
  2. Win8.1下Node.js连接oracle
  3. 并发编程中常见的锁机制:乐观锁、悲观锁、CAS、自旋锁、互斥锁、读写锁
  4. php 二维sort,php 二维数组排序
  5. 面试项目 java-服务端2 18h58
  6. [html] 如何动态修改`<title>`的标题名称?
  7. Windows 10 20H2 微软MSDN官方正式版英文ISO镜像下载
  8. Unity Shader 伽马校正详解
  9. 逍遥模拟器安装xposed installer
  10. input range: vue自定义进度条
  11. VS2013打包Windows程序部署教程
  12. hist = np.histogram(image, bins=256, range=(0,255))[0]含义
  13. Rejecting mapping update to [XXx] as the final mapping would have more than 1 type: 报错
  14. midi java_Java程序中添加播放MIDI音乐功能的实现方法详解
  15. Mapbox可视化之填色图
  16. PFO-Ir|PFO-Ir-OXD|D-Ir-Caz|D-Ir-OXD离子型铱配合物共轭聚合物
  17. Prolog系列学习-1
  18. 2021—10—31 上课笔记
  19. 会计基础-会计科目+会计账户+复式记账+会计分录+会计凭证
  20. 回到过去变成猫 读后感

热门文章

  1. Java程序员从笨鸟到菜鸟之(十二)java异常处理机制
  2. Java编程入门(2.1):基础Java应用程序
  3. 几种作图软件使用感言
  4. 快速了解Scala技术栈
  5. 图像检索:基于形状特征的算法
  6. 全能系统监控工具dstat
  7. 疯狂kotlin讲义连载之Kotlin的基础类型--null安全
  8. 关于li标签之间的间隔如何消除!
  9. oracle数据泵导入分区表统计信息报错(一)
  10. Instance and Media Recovery Structures