趁着上课无聊,来补一补……

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 题解的更多相关文章

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

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

    这个比赛不正经,但是我可以一本正经的写代码啊 A. Quirky Quantifiers time limit per test 2 seconds memory limit per test 64 ...

随机推荐

  1. 最大流算法-最高标号预流推进(HLPP)

    昨天我们学习了ISAP算法,它属于增广路算法的大类.今天学习的算法是预流推进算法中很高效的一类--最高标号预流推进(HLPP). 预流推进 预流推进是一种很直观的网络流算法.如果给到一个网络流让你手算 ...

  2. vi与vim

    vi 的使用 基本上 vi 共分为三种模式,分别是『一般模式』.『编辑模式』与『指令列命令模式』. 这三种模式的作用分别是: 一般模式:以 vi 打开一个档案就直接进入一般模式了(这是默认的模式).在 ...

  3. 解读使用Daisy-chain(菊花链)方式筛选一定范围内素数的代码

    go version go1.11 windows/amd64 本文为解读 参考链接1 中的 菊花链 一节 的示例程序,此程序和 参考链接2 中代码有些类似:前者有范围,后者是无限循环.清楚了 参考链 ...

  4. Java基础95 过滤器 Filter

    1.filter 过滤器的概述 filter过滤器:是面向切面编程的一种实现策略,在不影响原来的程序流程的前提下,将一些业务逻辑切入流程中,在请求达到目标之前进行处理,一般用于编码过滤.权限过滤... ...

  5. 学习笔记(二)--->《Java 8编程官方参考教程(第9版).pdf》:第七章到九章学习笔记

    注:本文声明事项. 本博文整理者:刘军 本博文出自于: <Java8 编程官方参考教程>一书 声明:1:转载请标注出处.本文不得作为商业活动.若有违本之,则本人不负法律责任.违法者自负一切 ...

  6. tcpdump使用示例

    前言 这段时间一直在研究kubernetes当中的网络, 包括通过keepalived来实现VIP的高可用时常常不得不排查一些网络方面的问题, 在这里顺道梳理一下tcpdump的使用姿势, 若有写的不 ...

  7. 性能测试二十一:环境部署之mysql

    在正常工作中,mysql应该部署到 一台独立的服务器上,不与tomcat共用服务器,由于成本原因,现部署到一起 为避免出错引起麻烦,先备份: 一:环境清理:先卸载系统自带的mysql 停止mysql: ...

  8. python 全栈开发,Day97(Token 认证的来龙去脉,DRF认证,DRF权限,DRF节流)

    昨日内容回顾 1. 五个葫芦娃和三行代码 APIView(views.View) 1. 封装了Django的request - request.query_params --> 取URL中的参数 ...

  9. .Net开发工程师工具箱

    Visual Studio Visual Studio Productivity Power tool:Visual Studio专业版(及以上)的扩展,具有丰富的功能,如快速查找,导航解决方案,可搜 ...

  10. STL算法之函数copy

    STL算法之copy copy(beg, end, dest) #include <iostream> #include <algorithm> #include <ve ...