博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
April Fools Contest 2017 题解&源码(A,数学 B,数学 C,数学 D,字符串 E,数字逻辑 F,排序,卡时间,G,数学)...
阅读量:6370 次
发布时间:2019-06-23

本文共 10421 字,大约阅读时间需要 34 分钟。

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 
2 using namespace std; 3 int main() 4 { 5 int n; 6 while(cin>>n) 7 { 8 if(n==1) 9 cout<<4<

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
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<
<

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
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
2 #include
3 #include
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

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
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
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<
<<" ";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 () 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 . We use this code to interpret outputs.

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

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

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

下面给出AC代码:

1 #include 
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

 

             

       

           

 

               
       

           

           
       

           

      

           

转载于:https://www.cnblogs.com/ECJTUACM-873284962/p/6659986.html

你可能感兴趣的文章
在.NET Workflo“.NET研究”w 3.5中使用多线程提高工作流性能
查看>>
验证Oracle处理速度
查看>>
自己写一个jquery
查看>>
艾伟:C#中抽象类和接口的区别
查看>>
Flink - NetworkEnvironment
查看>>
BZOJ4374 : Little Elephant and Boxes
查看>>
【.Net Framework 体积大?】不安装.net framework 也能运行!?开篇叙述-1
查看>>
LLDP协议、STP协议 笔记
查看>>
如何使用 GroupBy 计数-Count()
查看>>
jquery之clone()方法详解
查看>>
Delphi 用文件流读取文本文件字符串的方法
查看>>
php中怎么导入自己写的类
查看>>
C# 委托
查看>>
Using Information Fragments to Answer the Questions Developers Ask
查看>>
JVM学习(4)——全面总结Java的GC算法和回收机制---转载自http://www.cnblogs.com/kubixuesheng/p/5208647.html...
查看>>
getParameter和getAttribute的区别
查看>>
自动工作负载库理论与操作(Automatic Workload Repository,AWR)
查看>>
Redis两种方式实现限流
查看>>
CentOS 7 中使用NTP进行时间同步
查看>>
在MongoDB数据库中查询数据(上)
查看>>