April Fools Contest 2017 题解
趁着上课无聊,来补一补……
A. Numbers Joke
直接oeis就好了:http://oeis.org/search?q=numbers+joke&language=english&go=Search
#include<bits/stdc++.h>
using namespace std;
long long p[]={ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165};
int main(){
int n;
cin>>n;
cout<<p[n-1]<<endl;
}
B - Kids' Riddle
16进制中圈圈的个数。。。。
这TM谁猜得到(微笑)
#include<bits/stdc++.h>
using namespace std;
char getc(long long p){
if(p==10)return 'A';
if(p==11)return 'B';
if(p==12)return 'C';
if(p==13)return 'D';
if(p==14)return 'E';
if(p==15)return 'F';
return char(p+'0');
}
string get(long long x){
string s;
while(x){
s+=getc(x%16);
x/=16;
}
return s;
}
map<char,int> H;
int main(){
H['0']=1;
H['1']=0;
H['2']=0;
H['3']=0;
H['4']=1;
H['5']=0;
H['6']=1;
H['7']=0;
H['8']=2;
H['9']=1;
H['A']=1;
H['B']=2;
H['C']=0;
H['D']=1;
H['E']=0;
H['F']=0;
long long p;
cin>>p;
if(p==0){
cout<<"1"<<endl;
return 0;
}
string s = get(p);
int ans = 0;
for(int i=0;i<s.size();i++)
ans+=H[s[i]];
cout<<ans<<endl;
}
C. INTERCALC
FIND XOR OF LARGEST AND LAST ARRAY ELEMENTS
#include<bits/stdc++.h>
using namespace std;
int n,x,mx;
int main(){
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d",&x);
mx=max(x,mx);
}
cout<<(x^mx)<<endl;
}
D - Touchy-Feely Palindromes
给你个字符串,问你这个字符串在盲文的条件下,是否回文
#include<bits/stdc++.h>
using namespace std;
map<char,char>H;
string s;
int main(){
H['3']='3';
H['4']='6';
H['5']='9';
H['6']='4';
H['7']='7';
H['8']='0';
H['9']='5';
H['0']='8';
cin>>s;
int flag = 1;
for(int i=0;i<s.size();i++){
if(!H.count(s[i]))flag=0;
else{
if(H[s[i]]!=s[s.size()-1-i])
flag=0;
}
}
if(flag)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
E - Twisted Circuit
给一个电路图,然后把OR门看成XOR门,把XOR门看成OR门就好了
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
int a1=a^b;
int b1=c|d;
int c1=b&c;
int d1=a^d;
int a2=a1&b1;
int b2=c1|d1;
cout<<(a2^b2)<<endl;
}
F - Crunching Numbers Just for You
必须运行超过1秒。。
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1000006;
int n,a[maxn];
int main(){
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(int i=n;i<maxn;i++){
a[i]=101;
}
for(int i=0;i<100;i++){
a[n+i]=102+i;
sort(a,a+maxn);
}
for(int i=0;i<n;i++)
cout<<a[i]<<" ";
cout<<endl;
}
G. BF Calculator
写一个表达式,让你用brainfuck写出答案是多少。
#include<bits/stdc++.h>
using namespace std;
string s;
string get(int p){
if(p==0){
return "0";
}
int flag = 0;
if(p<0)flag=1,p=-p;
string tmp;
while(p){
tmp+=(p%10+'0');
p/=10;
}
if(flag)tmp+='-';
reverse(tmp.begin(),tmp.end());
return tmp;
}
int main(){
cin>>s;
int now = 0;
int num = 0;
int flag = 0;
for(int i=0;i<s.size();i++){
if(s[i]=='+'||s[i]=='-'){
if(flag==0){
now+=num;
}
else{
now-=num;
}
if(s[i]=='+')
flag=0;
else
flag=1;
num=0;
}else{
num=num*10+(s[i]-'0');
}
}
if(flag==0){
now+=num;
}
else{
now-=num;
}
string ss = get(now);
for(int i=0;i<ss.size();i++){
for(int j=0;j<ss[i];j++){
cout<<"+";
}
cout<<".";
cout<<">"<<endl;
}
}
April Fools Contest 2017 题解的更多相关文章
- April Fools Contest 2017 题解&源码(A,数学 B,数学 C,数学 D,字符串 E,数字逻辑 F,排序,卡时间,G,数学)
A. Numbers Joke time limit per test:2 seconds memory limit per test:64 megabytes input:standard inpu ...
- Codeforces April Fools Contest 2017
都是神题,我一题都不会,全程听学长题解打代码,我代码巨丑就不贴了 题解见巨神博客 假装自己没有做过这套
- April Fools Contest 2017 F
Description You are developing a new feature for the website which sells airline tickets: being able ...
- April Fools Contest 2017 E
Description Input The input consists of four lines, each line containing a single digit 0 or 1. Outp ...
- April Fools Contest 2017 D
Description Input The only line of the input contains a string of digits. The length of the string i ...
- April Fools Contest 2017 C
Description DO YOU EXPECT ME TO FIND THIS OUT? WHAT BASE AND/XOR LANGUAGE INCLUDES string? DON'T BYT ...
- April Fools Contest 2017 B
Description Programmers' kids solve this riddle in 5-10 minutes. How fast can you do it? Input The i ...
- April Fools Contest 2017 A
Description Input The input contains a single integer a (1 ≤ a ≤ 30). Output Output a single integer ...
- April Fools Contest 2018
这个比赛不正经,但是我可以一本正经的写代码啊 A. Quirky Quantifiers time limit per test 2 seconds memory limit per test 64 ...
随机推荐
- jenkins cobertura单元测试
1.1 Maven 工程 pom.xml 修改 1.2 Build添加插件目标 此时构建项目,会在项目 targer/site/cobertura 目录中生成 html 与 xml ...
- mysql 常用,使用经验
mysql default boolean字段 `enable` char(1) NOT NULL DEFAULT '1' COMMENT '启(禁)用',结果: this.enable ? &qu ...
- 瞅瞅!!免费看VIP视频的技巧
最近再逛强大的知乎,发现一个免费看VIP视频的方法(腾讯是可能有点不稳定) 以爱奇艺为例: 复制URL到www.a6a6.org 把地址输入到输入框,点击开始 然后会提示你输入提取码 输入:22336 ...
- LeetCode(9):回文数
Easy! 题目描述: 判断一个整数是否是回文数.回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数. 示例 1: 输入: 121 输出: true 示例 2: 输入: -121 输出: f ...
- python 全栈开发,Day58(bootstrap组件,bootstrap JavaScript 插件,后台模板,图表插件,jQuery插件库,Animate.css,swiper,运行vue项目)
一.bootstrap组件 无数可复用的组件,包括字体图标.下拉菜单.导航.警告框.弹出框等更多功能. 组件和插件的区别? 插件:一个功能,比如js文件 组件:html css js 组件包含插件 面 ...
- java 判断字符串什么编码类型
public static String getEncoding(String str) { String encode = "GB2312"; try { if (str.equ ...
- ActiveMQ的应用实例
一.部署和启动ActiveMQ 去官网下载:http://activemq.apache.org/ 我下载的是apache-activemq-5.12.0-bin.tar.gz, 解压到本地目录,进入 ...
- 支持删除的并查集 hdu2473
题解: 代码: #include<bits/stdc++.h> using namespace std; #define ll long long ; int fa[maxn],id,vi ...
- python全栈开发day39-CSS继承性和层叠性、权重问题、盒模型和其属性、文本级标签和块级标签、浮动
一.上次内容回顾 1.CSS的三种引入方式: 行内式 内接式 外接式 链接式 导入式 2.基础选择器和高级选择器 1)标签选择器 p{} 2) id选择器 #nva{} 3) 类选择器 .nva{} ...
- Codeforces 160D Edges in MST tarjan找桥
Edges in MST 在用克鲁斯卡尔求MST的时候, 每个权值的边分为一类, 然后将每类的图建出来, 那些桥就是必须有的, 不是桥就不是必须有. #include<bits/stdc++.h ...