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代码:

 #include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else if(n==)
cout<<<<endl;
}
return ;
}

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代码:
 #include<bits/stdc++.h>
using namespace std;
#define ll long long
string s;
int a,b,c,d;
int main()
{
int ans;
cin>>ans;
if(ans==)
{
a++;
}
while(ans)
{
if(ans%==)
{
a++;
}
else if(ans%==)
{
a+=;
}
else if(ans%==)
{
a++;
}
else if(ans%==)
{
a++;
}
else if(ans%==)
{
a+=;
}
else if(ans%==)
{
a++;
}
else if(ans%==)
{
a++;
}
else if(ans%==)
{
a++;
}
ans/=;
}
cout<<a<<endl;
return ;
}

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代码:
 #include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,x,mx=;
int main()
{
cin>>n;
for(int i=;i<=n;i++)
cin>>x,mx=max(mx,x);
cout<<(x^mx);
return ;
}

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代码:

 #include<cstdio>
#include<iostream>
#include<cstring>
using namespace std; int s[]={,-,-,-,,,,-,,};
char st[]; int main()
{
scanf("%s",st+);int n=strlen(st+);
for(int i=,j=n;i<j;i++,j--)
if(st[i]!=st[j]&&s[st[i]-'']!=st[j]-'') return *puts("No");
if(n&){if(st[n/+]!=''&&st[n/+]!='')return *puts("No");}
puts("YES");
return ;
}

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代码:

 #include<bits/stdc++.h>
using namespace std;
#define ll long long
string s;
int a,b,c,d;
int main()
{
cin>>a>>b>>c>>d;
printf("%d\n",((a^b)&(c|d))^((b&c)|(a^d)));
return ;
}

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代码:

 #include<bits/stdc++.h>
using namespace std; #define MAXN 100
#define MAXM 10001
#define MAXP 266666
#define MAX 3200001
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)
#define dbg(x) cout << #x << " = " << x << endl
#define chkbit(ar, i) (((ar[(i) >> 6]) & (1 << (((i) >> 1) & 31))))
#define setbit(ar, i) (((ar[(i) >> 6]) |= (1 << (((i) >> 1) & 31))))
#define isprime(x) (( (x) && ((x)&1) && (!chkbit(ar, (x)))) || ((x) == 2)) namespace pcf
{
long long dp[MAXN][MAXM];
unsigned int ar[(MAX >> ) + ] = {};
int len = , primes[MAXP], counter[MAX]; void Sieve()
{
setbit(ar, ), setbit(ar, );
for (int i = ; (i * i) < MAX; i++, i++)
{
if (!chkbit(ar, i))
{
int k = i << ;
for (int j = (i * i); j < MAX; j += k) setbit(ar, j);
}
} for (int i = ; i < MAX; i++)
{
counter[i] = counter[i - ];
if (isprime(i)) primes[len++] = i, counter[i]++;
}
} void init()
{
Sieve();
for (int n = ; n < MAXN; n++)
{
for (int m = ; m < MAXM; m++)
{
if (!n) dp[n][m] = m;
else dp[n][m] = dp[n - ][m] - dp[n - ][m / primes[n - ]];
}
}
} long long phi(long long m, int n)
{
if (n == ) return m;
if (primes[n - ] >= m) return ;
if (m < MAXM && n < MAXN) return dp[n][m];
return phi(m, n - ) - phi(m / primes[n - ], n - );
} long long Lehmer(long long m)
{
if (m < MAX) return counter[m]; long long w, res = ;
int i, a, s, c, x, y;
s = sqrt(0.9 + m), y = c = cbrt(0.9 + m);
a = counter[y], res = phi(m, a) + a - ;
for (i = a; primes[i] <= s; i++) res = res - Lehmer(m / primes[i]) + Lehmer(primes[i]) - ;
return res;
}
} long long solve(long long n)
{
int i, j, k, l;
long long x, y, res = ; /*for (i = 0; i < pcf::len; i++){
printf("%I64d\n",pcf::Lehmer(n));
x = pcf::primes[i], y = n / x;
if ((x * x) > n) break;
res += (pcf::Lehmer(y) - pcf::Lehmer(x));
} for (i = 0; i < pcf::len; i++){
x = pcf::primes[i];
if ((x * x * x) > n) break;
res++;
}*/
res=pcf::Lehmer(n);
return res;
}
int xx[];
int main()
{
pcf::init();
long long n, res;
while(cin>>n)
{
int x=solve();
for(int i=; i<=n; i++)
{
cin>>xx[i];
}
sort(xx+,xx+n+);
for(int i=; i<=n; i++)
{
cout<<xx[i]<<" ";
}
}
return ;
}

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代码:

 #include <bits/stdc++.h>
using namespace std; char st[];
int op[],num[],cnt=; int calc(int l,int r)
{
int x=;
for(int i=l;i<=r;i++)
x=x*+st[i]-'';
return x;
} void work(int&th,int x)
{
int to=x+;
while(th>to)th--,printf("-");
while(th<to)th++,printf("+");
printf(".\n");
} int main()
{
scanf("%s",st+);int pre=;
for(int i=;st[i];i++)
{
if(st[i]=='+'||st[i]=='-')
{
op[++cnt]=(st[i]=='+')?:;
num[cnt]=calc(pre+,i-);
pre=i;
}
}
num[++cnt]=calc(pre+,strlen(st+));
int x=num[];
for(int i=;i<cnt;i++)
{
if(op[i]==)x=x+num[i+];
else x=x-num[i+];
}
int th=;cnt=;
if(!x) {work(th,);return ;}
while(x)
{
num[++cnt]=x%;x/=;
}
for(int i=cnt;i;i--)
work(th,num[i]);
return ;
}

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. Codeforces April Fools Contest 2017

    都是神题,我一题都不会,全程听学长题解打代码,我代码巨丑就不贴了 题解见巨神博客 假装自己没有做过这套

  3. April Fools Contest 2017 F

    Description You are developing a new feature for the website which sells airline tickets: being able ...

  4. April Fools Contest 2017 E

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

  5. April Fools Contest 2017 D

    Description Input The only line of the input contains a string of digits. The length of the string i ...

  6. April Fools Contest 2017 C

    Description DO YOU EXPECT ME TO FIND THIS OUT? WHAT BASE AND/XOR LANGUAGE INCLUDES string? DON'T BYT ...

  7. April Fools Contest 2017 B

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

  8. April Fools Contest 2017 A

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

  9. ECJTUACM16 Winter vacation training #4 题解&源码

    A......................................................................................... 题目链接→Code ...

随机推荐

  1. 小程序代码包压缩 策略&方案

    微信小程序自推出以来,逐渐发展,目前正受到越来越多的青睐.其中很重要的一点得益于小程序的轻量级特性,每个小程序最多不超过2MB,招之即来挥之即去,相比于几十上百兆的APP,用户进入小程序,或者说,小程 ...

  2. 【java设计模式】【创建模式Creational Pattern】工厂方法模式Factory Method Pattern(多态性工厂模式Polymorphic Factory Pattern、虚拟构造子模式Virtual Constructor Pattern)

    public class Test { public static void main(String[] args){ Creator ca=new ConcreteCreatorA(); ca.cr ...

  3. 【java】打印流的基本实现及java.io.PrintStream、java.io.PrintWriter示例

    package 打印流; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; impor ...

  4. sqlserver 存储过程 查询

    --查询 CREATE PROCEDURE [dbo].[SelelctMessage] @strTable varchar(), --要查询的表 @strColum varchar(), --要查询 ...

  5. sourceTree git 忽略指定文件

    按照如下步骤执行(终端命令) 1. git status modified: LovegoMall.xcworkspace/xcuserdata/Tiny.xcuserdatad/xcdebugger ...

  6. Python3 学习Python流程--试水中

    二.基础语法之后可以搭载服务器练习: 教程 一.1.Python 搭建环境. 初学基本语法 :Python基本语法 2.推荐 IDE :  PyCharm CE 下载 菜鸟教程都是基础语法,可以对py ...

  7. Intellij IDEA 像eclipse那样给maven添加依赖

    打开pom.xml,在它里面使用快捷键:ALT+Insert  ---->点击dependency 再输入想要添加的依赖关键字,比如:输个spring   出现下图: 根据需求选择版本,完成以后 ...

  8. scala-Future和Promise

    首先说明同步与异步,阻塞与非阻塞的问题: Asynchronous vs. Synchronous A method call is considered synchronous if the cal ...

  9. java 操作本地数据库 mysql

    单线程版 /** * */ import java.sql.*; import java.util.Date; import org.omg.CORBA.PUBLIC_MEMBER; /** * @a ...

  10. Java 字符编码与解码

    1.字符编码的发展历程 ①.ASCII 码 因为计算机只认识数字,所以我们在计算机里面的一切数据都是以数字来表示,因为英文字符有限,所以规定使用的字节的最高位是 0,每一个字节都是以 0-127 之间 ...