Codefroces 784 愚人节题目(部分)
The input contains a single integer a (1 ≤ a ≤ 30).
Output a single integer.
3
27
史密夫数列
史密夫数(或作史密斯数)是指在某个进位下,它每一位数的数字的和相等於它因数分解(不用指数记数)中每一个因数的位数的和。
#include<iostream> using namespace std; int a[36]={0,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}; int main() { int n; while(cin>>n) { cout<<a[n]<<endl; } return 0; }
Programmers' kids solve this riddle in 5-10 minutes. How fast can you do it?
The input contains a single integer n (0 ≤ n ≤ 2000000000).
Output a single integer.
11
2
14
0
61441
2
571576
10
2128506
3
转换为16进制后数圈圈
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include <vector> #include <queue> #include <cstdlib> #include <iomanip> #include <cmath> #include <ctime> #include <map> #include <set> using namespace std; #define lowbit(x) (x&(-x)) #define max(x,y) (x>y?x:y) #define min(x,y) (x<y?x:y) #define MAX 100000000000000000 #define MOD 1000000007 #define pi acos(-1.0) #define ei exp(1) #define PI 3.141592653589793238462 #define ios() ios::sync_with_stdio(false) #define INF 0x3f3f3f3f3f #define mem(a) (memset(a,0,sizeof(a))) typedef long long ll; int n,ans=0; int main() { scanf("%d",&n); while(n>=16) { if(n%16==0) ans+=1; if(n%16==4) ans+=1; if(n%16==6) ans+=1; if(n%16==8) ans+=2; if(n%16==9) ans+=1; if(n%16==10) ans+=1; if(n%16==11) ans+=2; if(n%16==13) ans+=1; n/=16; } if(n==0) ans+=1; if(n==4) ans+=1; if(n==6) ans+=1; if(n==8) ans+=2; if(n==9) ans+=1; if(n==10) ans+=1; if(n==11) ans+=2; if(n==13) ans+=1; printf("%d\n",ans); return 0; }
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
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 a single integer.
4
2 5 3 1
4
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include <vector> #include <queue> #include <cstdlib> #include <iomanip> #include <cmath> #include <ctime> #include <map> #include <set> using namespace std; #define lowbit(x) (x&(-x)) #define max(x,y) (x>y?x:y) #define min(x,y) (x<y?x:y) #define MAX 100000000000000000 #define MOD 1000000007 #define pi acos(-1.0) #define ei exp(1) #define PI 3.141592653589793238462 #define ios() ios::sync_with_stdio(false) #define INF 0x3f3f3f3f3f #define mem(a) (memset(a,0,sizeof(a))) typedef long long ll; int n,ans=0; int main() { int n,x,ans; cin>>n; cin>>x; ans=x; for(int i=1;i<n;i++) { cin>>x; ans=max(ans,x); } printf("%d\n",ans^x); return 0; }
The only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.
Output "Yes" or "No".
373
Yes
121
No
436
Yes
数字回文串
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include <vector> #include <queue> #include <cstdlib> #include <iomanip> #include <cmath> #include <ctime> #include <map> #include <set> using namespace std; #define lowbit(x) (x&(-x)) #define max(x,y) (x>y?x:y) #define min(x,y) (x<y?x:y) #define MAX 100000000000000000 #define MOD 1000000007 #define pi acos(-1.0) #define ei exp(1) #define PI 3.141592653589793238462 #define ios() ios::sync_with_stdio(false) #define INF 0x3f3f3f3f3f #define mem(a) (memset(a,0,sizeof(a))) typedef long long ll; // 0 1 2 3 4 5 6 7 8 9 int mirror[] = {8,-1,-1, 3, 6, 9, 4, 7, 0, 5}; int main() { char a[15]; scanf("%s",&a); int len=strlen(a); int i=0; while(a[i]!='\0' && mirror[a[i]-'0']==a[len-i-1]-'0') i++; puts(i==len?"Yes":"No"); }
The input consists of four lines, each line containing a single digit 0 or 1.
Output a single digit, 0 or 1.
0
1
1
0
0
数字电路,或与非
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include <vector> #include <queue> #include <cstdlib> #include <iomanip> #include <cmath> #include <ctime> #include <map> #include <set> using namespace std; #define lowbit(x) (x&(-x)) #define max(x,y) (x>y?x:y) #define min(x,y) (x<y?x:y) #define MAX 100000000000000000 #define MOD 1000000007 #define pi acos(-1.0) #define ei exp(1) #define PI 3.141592653589793238462 #define ios() ios::sync_with_stdio(false) #define INF 0x3f3f3f3f3f #define mem(a) (memset(a,0,sizeof(a))) typedef long long ll; int a,b,c,d; int main() { scanf("%d%d%d%d",&a,&b,&c,&d); printf("%d\n",((a^b)&(c|d))^((b&c)|(a^d))); return 0; }