April Fools Contest 2018

xiaoxiao2021-02-28  85

哇,第二天补题,发现除了第一个什么都不会,这么可怕的题意吗?

A. Quirky Quantifiers 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 (10 ≤ a ≤ 999).

Output

Output 0 or 1.

Examples input Copy 13 output 1 input Copy 927 output 1 input Copy 48 output 0

直觉告诉我,奇偶搞定。男人的第六感一般不会太差。我写了if—else判断,但看别人代码一个%2就ok了,思维跟不上啊。

代码实现:

#include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<queue> #include<vector> #include<set> #include<cstdio> #define ll long long #define mset(a,x) memset(a,x,sizeof(a)) using namespace std; const double PI=acos(-1); const int inf=0x3f3f3f3f; const double esp=1e-6; const int maxn=1e6+5; const int mod=1e9+7; int dir[4][2]={0,1,1,0,0,-1,-1,0}; ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} ll lcm(ll a,ll b){return a/gcd(a,b)*b;} ll inv(ll b){if(b==1)return 1; return (mod-mod/b)*inv(mod%b)%mod;} ll fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%mod;n=n*n%mod;}return r;} ll Fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n;n=n*n;}return r;} ll upd(ll x,ll v){x=x+v>=mod?x+v-mod:x+v;return x;} int main() { int n; cin>>n; if(n%2==0) cout<<0<<endl; else cout<<1<<endl; }

B. A Map of the Cat time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output

If you have ever interacted with a cat, you have probably noticed that they are quite particular about how to pet them. Here is an approximate map of a normal cat.

However, some cats won't tolerate this nonsense from the humans. Here is a map of a grumpy cat.

You have met a cat. Can you figure out whether it's normal or grumpy?

Interaction

This is an interactive problem. Initially you're not given any information about the cat. Instead, the cat is divided into ten areas, indexed from 0 to 9.

In one query you can choose which area you'll pet and print the corresponding index to standard out. You will get the cat's response, as depicted on the corresponding map, via standard in. For simplicity all responses are written in lowercase.

Once you're certain what type of cat you're dealing with, output "normal" or "grumpy" to standard out.

Note

Please make sure to use the stream flushing operation after each query in order not to leave part of your output in some buffer.

这题也没啥坑点,就是一个交互式输入,但是我不懂。 点击打开链接 代码实现: #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<queue> #include<vector> #include<set> #include<cstdio> #define ll long long #define mset(a,x) memset(a,x,sizeof(a)) using namespace std; const double PI=acos(-1); const int inf=0x3f3f3f3f; const double esp=1e-6; const int maxn=1e6+5; const int mod=1e9+7; int dir[4][2]={0,1,1,0,0,-1,-1,0}; ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} ll lcm(ll a,ll b){return a/gcd(a,b)*b;} ll inv(ll b){if(b==1)return 1; return (mod-mod/b)*inv(mod%b)%mod;} ll fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%mod;n=n*n%mod;}return r;} ll Fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n;n=n*n;}return r;} ll upd(ll x,ll v){x=x+v>=mod?x+v-mod:x+v;return x;} int main() { string str; for(int i=0;i<9;i++) { cout<<i<<endl; getline(cin,str); if(str == "no") continue; else { if(str=="great"||str=="cool"||str=="don't think so"||str=="not bad"||str=="don't touch me") { printf("normal\n"); } else { printf("grumpy\n"); } } } return 0; } C. Ravioli Sort time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output

Everybody knows of spaghetti sort. You decided to implement an analog sorting algorithm yourself, but as you survey your pantry you realize you're out of spaghetti! The only type of pasta you have is ravioli, but you are not going to let this stop you...

You come up with the following algorithm. For each number in the array ai, build a stack of ai ravioli. The image shows the stack forai = 4.

Arrange the stacks in one row in the order in which the corresponding numbers appear in the input array. Find the tallest one (if there are several stacks of maximal height, use the leftmost one). Remove it and add its height to the end of the output array. Shift the stacks in the row so that there is no gap between them. Repeat the procedure until all stacks have been removed.

At first you are very happy with your algorithm, but as you try it on more inputs you realize that it doesn't always produce the right sorted array. Turns out when two stacks of ravioli are next to each other (at any step of the process) and differ in height by two or more, the top ravioli of the taller stack slides down on top of the lower stack.

Given an input array, figure out whether the described algorithm will sort it correctly.

Input

The first line of input contains a single number n (1 ≤ n ≤ 10) — the size of the array.

The second line of input contains n space-separated integers ai (1 ≤ ai ≤ 100) — the elements of the array.

Output

Output "YES" if the array can be sorted using the described procedure and "NO" if it can not.

Examples input Copy 3 1 2 3 output YES input Copy 3 3 1 2 output NO Note

In the second example the array will change even before the tallest stack is chosen for the first time: ravioli from stack of height 3 will slide on the stack of height 1, and the algorithm will output an array {2, 2, 2}.

题意依旧看不懂,就是相隔的数的差大于等于2的就输出NO,其他YES。 代码实现: #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<queue> #include<vector> #include<set> #include<cstdio> #define ll long long #define mset(a,x) memset(a,x,sizeof(a)) using namespace std; const double PI=acos(-1); const int inf=0x3f3f3f3f; const double esp=1e-6; const int maxn=1e6+5; const int mod=1e9+7; int dir[4][2]={0,1,1,0,0,-1,-1,0}; ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} ll lcm(ll a,ll b){return a/gcd(a,b)*b;} ll inv(ll b){if(b==1)return 1; return (mod-mod/b)*inv(mod%b)%mod;} ll fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%mod;n=n*n%mod;}return r;} ll Fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n;n=n*n;}return r;} ll upd(ll x,ll v){x=x+v>=mod?x+v-mod:x+v;return x;} int a[maxn]; int main() { int n,i,j,k; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d",&a[i]); for(i=0;i<n-1;i++) { if(abs(a[i]-a[i+1])>=2) { printf("NO\n"); return 0; } } printf("YES\n"); return 0; } D. I'm Feeling Lucky! time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output

You have one chip and one chance to play roulette. Are you feeling lucky?

Output

Print your bet. Your chip must be placed entirely within some square (not on an edge or a corner shared by adjacent squares).

输出red,black,even,odd,四分之一的可能性。 E. Cheese Board time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output

Not to be confused with chessboard.

Input

The first line of input contains a single integer N (1 ≤ N ≤ 100) — the number of cheeses you have.

The next N lines describe the cheeses you have. Each line contains two space-separated strings: the name of the cheese and its type. The name is a string of lowercase English letters between 1 and 10 characters long. The type is either "soft" or "hard. All cheese names are distinct.

Output

Output a single number.

Examples input Copy 9 brie soft camembert soft feta soft goat soft muenster soft asiago hard cheddar hard gouda hard swiss hard output 3 input Copy 6 parmesan hard emmental hard edam hard colby hard gruyere hard asiago hard output 4 不会做啊,不会做。看别人的代码解决的。 代码实现: #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<queue> #include<vector> #include<set> #include<cstdio> #define ll long long #define mset(a,x) memset(a,x,sizeof(a)) using namespace std; const double PI=acos(-1); const int inf=0x3f3f3f3f; const double esp=1e-6; const int maxn=1e6+5; const int mod=1e9+7; int dir[4][2]={0,1,1,0,0,-1,-1,0}; ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} ll lcm(ll a,ll b){return a/gcd(a,b)*b;} ll inv(ll b){if(b==1)return 1; return (mod-mod/b)*inv(mod%b)%mod;} ll fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%mod;n=n*n%mod;}return r;} ll Fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n;n=n*n;}return r;} ll upd(ll x,ll v){x=x+v>=mod?x+v-mod:x+v;return x;} int main() { int s1=0,s2=0,n,i,j,k; string a,b; cin>>n; for(i=0;i<n;i++) { cin>>a>>b; if(b=="hard") s1++; else s2++; } int sum=0; while((sum*sum)/2<min(s1,s2)||(sum*sum+1)/2<max(s1,s2)) sum++; cout<<sum<<endl; }

转载请注明原文地址: https://www.6miu.com/read-2150292.html

最新回复(0)