sample_inputs
stringlengths
5
384
input_specification
stringlengths
48
911
src_uid
stringlengths
32
32
source_code
stringlengths
29
6.77k
sample_outputs
stringlengths
5
393
lang_cluster
stringclasses
4 values
notes
stringlengths
30
1.52k
output_specification
stringlengths
25
681
description
stringlengths
140
2.49k
human_testcases
stringlengths
243
50.8k
human_pass_rate
float64
100
100
human_line_coverage
float64
100
100
human_branch_coverage
float64
100
100
human_sample_testcases_1
stringlengths
190
3.11k
human_sample_testcases_2
stringlengths
190
3.11k
human_sample_testcases_3
stringlengths
190
3.11k
human_sample_testcases_4
stringlengths
190
3.11k
human_sample_testcases_5
stringlengths
190
3.11k
human_sample_pass_rate_1
float64
100
100
human_sample_pass_rate_2
float64
100
100
human_sample_pass_rate_3
float64
100
100
human_sample_pass_rate_4
float64
100
100
human_sample_pass_rate_5
float64
100
100
human_sample_line_coverage_1
float64
52.2
100
human_sample_line_coverage_2
float64
60
100
human_sample_line_coverage_3
float64
50
100
human_sample_line_coverage_4
float64
43.5
100
human_sample_line_coverage_5
float64
21.7
100
human_sample_branch_coverage_1
float64
45.5
100
human_sample_branch_coverage_2
float64
45.8
100
human_sample_branch_coverage_3
float64
16.7
100
human_sample_branch_coverage_4
float64
36.4
100
human_sample_branch_coverage_5
float64
18.2
100
id
int64
1
400
human_sample_pass_rate
float64
100
100
human_sample_line_coverage
float64
47
100
human_sample_branch_coverage
float64
41.8
100
["4 3", "10 1"]
The first line will contain two integers n, k (1 ≤ n ≤ 50, 1 ≤ k ≤ min{1018, l} where l is the length of the Kyoya's list).
e03c6d3bb8cf9119530668765691a346
//God & me // ya mahdi adrekni #include <iostream> #include <algorithm> using namespace std; long long int fib[112]={1,1},k; int p[112],n; int main(){ for(int i=2;i<=85;i++) fib[i]=fib[i-1]+fib[i-2]; cin>>n>>k; for(int i=0;i<n;i++) p[i]=i; //int L=0; while(k>0){//timed in test 5 :( maby for this. int pos=0; while(fib[++pos]<k);//long long int* it=lower_bound(fib,fib+85,k);//thank from maths.surrey.ac.uk :D I am so lazzy //cout<<pos<<endl; pos--; k-=fib[pos]; if(pos) swap(p[n-pos-1],p[n-pos]); //if(++L>10)return 0; } for(int i=0;i<n;i++) cout<<p[i]+1<<" "; cout<<endl; return 0; }
["1 3 2 4", "1 2 3 4 5 6 7 8 9 10"]
C++
NoteThe standard cycle representation is (1)(32)(4), which after removing parenthesis gives us the original permutation. The first permutation on the list would be [1, 2, 3, 4], while the second permutation would be [1, 2, 4, 3].
Print n space-separated integers, representing the permutation that is the answer for the question.
Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, value 2 into the value p2 and so on.Kyota Ootori has just learned about cyclic representation of a permutation. A cycle is a sequence of numbers such that each element of this sequence is being mapped into the next element of this sequence (and the last element of the cycle is being mapped into the first element of the cycle). The cyclic representation is a representation of p as a collection of cycles forming p. For example, permutation p = [4, 1, 6, 2, 5, 3] has a cyclic representation that looks like (142)(36)(5) because 1 is replaced by 4, 4 is replaced by 2, 2 is replaced by 1, 3 and 6 are swapped, and 5 remains in place. Permutation may have several cyclic representations, so Kyoya defines the standard cyclic representation of a permutation as follows. First, reorder the elements within each cycle so the largest element is first. Then, reorder all of the cycles so they are sorted by their first element. For our example above, the standard cyclic representation of [4, 1, 6, 2, 5, 3] is (421)(5)(63).Now, Kyoya notices that if we drop the parenthesis in the standard cyclic representation, we get another permutation! For instance, [4, 1, 6, 2, 5, 3] will become [4, 2, 1, 5, 6, 3].Kyoya notices that some permutations don't change after applying operation described above at all. He wrote all permutations of length n that do not change in a list in lexicographic order. Unfortunately, his friend Tamaki Suoh lost this list. Kyoya wishes to reproduce the list and he needs your help. Given the integers n and k, print the permutation that was k-th on Kyoya's list.
[{"input": "4 3\r\n", "output": ["1 3 2 4"]}, {"input": "10 1\r\n", "output": ["1 2 3 4 5 6 7 8 9 10"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "50 1\r\n", "output": ["1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50"]}, {"input": "10 57\r\n", "output": ["2 1 3 4 5 6 7 8 10 9"]}, {"input": "50 20365011074\r\n", "output": ["2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 25 28 27 30 29 32 31 34 33 36 35 38 37 40 39 42 41 44 43 46 45 48 47 50 49"]}, {"input": "20 9999\r\n", "output": ["2 1 4 3 5 7 6 8 9 10 11 13 12 14 15 17 16 18 19 20"]}, {"input": "49 12586269025\r\n", "output": ["2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 25 28 27 30 29 32 31 34 33 36 35 38 37 40 39 42 41 44 43 46 45 48 47 49"]}, {"input": "49 1\r\n", "output": ["1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49"]}, {"input": "10 89\r\n", "output": ["2 1 4 3 6 5 8 7 10 9"]}, {"input": "10 1\r\n", "output": ["1 2 3 4 5 6 7 8 9 10"]}, {"input": "5 8\r\n", "output": ["2 1 4 3 5"]}, {"input": "5 1\r\n", "output": ["1 2 3 4 5"]}, {"input": "25 121393\r\n", "output": ["2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 25"]}, {"input": "25 1\r\n", "output": ["1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "2 2\r\n", "output": ["2 1"]}, {"input": "3 3\r\n", "output": ["2 1 3"]}, {"input": "4 2\r\n", "output": ["1 2 4 3"]}, {"input": "5 8\r\n", "output": ["2 1 4 3 5"]}, {"input": "6 10\r\n", "output": ["2 1 3 4 6 5"]}, {"input": "7 20\r\n", "output": ["2 1 4 3 5 7 6"]}, {"input": "8 24\r\n", "output": ["2 1 3 4 5 7 6 8"]}, {"input": "9 1\r\n", "output": ["1 2 3 4 5 6 7 8 9"]}, {"input": "10 24\r\n", "output": ["1 2 4 3 5 6 7 9 8 10"]}, {"input": "11 77\r\n", "output": ["1 3 2 5 4 6 7 8 9 10 11"]}, {"input": "12 101\r\n", "output": ["1 3 2 4 5 6 8 7 10 9 11 12"]}, {"input": "13 240\r\n", "output": ["2 1 3 4 5 6 7 8 10 9 11 13 12"]}, {"input": "14 356\r\n", "output": ["1 3 2 5 4 6 8 7 10 9 12 11 14 13"]}, {"input": "15 463\r\n", "output": ["1 3 2 4 5 7 6 9 8 11 10 12 13 15 14"]}, {"input": "16 747\r\n", "output": ["1 3 2 4 5 7 6 9 8 11 10 12 13 14 15 16"]}, {"input": "17 734\r\n", "output": ["1 2 4 3 5 6 8 7 10 9 11 12 13 14 15 16 17"]}, {"input": "18 1809\r\n", "output": ["1 3 2 4 5 6 8 7 10 9 11 12 14 13 16 15 18 17"]}, {"input": "19 859\r\n", "output": ["1 2 3 4 6 5 8 7 9 10 11 12 14 13 15 16 18 17 19"]}, {"input": "20 491\r\n", "output": ["1 2 3 4 5 6 8 7 9 11 10 12 14 13 15 16 18 17 19 20"]}, {"input": "21 14921\r\n", "output": ["2 1 3 5 4 7 6 9 8 10 11 12 13 15 14 16 18 17 19 20 21"]}, {"input": "22 731\r\n", "output": ["1 2 3 4 5 6 7 9 8 10 11 13 12 14 16 15 18 17 19 21 20 22"]}, {"input": "23 45599\r\n", "output": ["2 1 4 3 6 5 8 7 9 10 11 13 12 15 14 16 18 17 20 19 21 22 23"]}, {"input": "24 47430\r\n", "output": ["2 1 3 4 5 6 7 8 10 9 11 12 13 14 16 15 17 19 18 21 20 22 24 23"]}, {"input": "25 58467\r\n", "output": ["1 3 2 4 6 5 7 8 9 11 10 12 13 15 14 16 17 19 18 20 21 22 23 24 25"]}, {"input": "26 168988\r\n", "output": ["2 1 4 3 5 6 7 8 9 10 12 11 13 15 14 16 17 18 19 20 21 23 22 24 26 25"]}, {"input": "27 298209\r\n", "output": ["2 1 4 3 5 7 6 9 8 10 12 11 14 13 15 16 17 19 18 21 20 22 24 23 25 27 26"]}, {"input": "28 77078\r\n", "output": ["1 2 3 5 4 6 7 8 9 10 11 13 12 14 16 15 17 18 20 19 22 21 23 24 25 27 26 28"]}, {"input": "29 668648\r\n", "output": ["2 1 3 5 4 6 8 7 9 10 12 11 13 14 15 16 17 19 18 20 22 21 23 25 24 26 27 29 28"]}, {"input": "30 582773\r\n", "output": ["1 3 2 4 5 6 8 7 10 9 11 13 12 14 15 16 17 19 18 20 21 23 22 25 24 26 28 27 29 30"]}, {"input": "31 1899100\r\n", "output": ["2 1 4 3 5 6 7 8 10 9 11 13 12 15 14 16 17 19 18 21 20 23 22 24 26 25 28 27 29 31 30"]}, {"input": "32 1314567\r\n", "output": ["1 2 4 3 6 5 8 7 9 11 10 13 12 14 16 15 18 17 19 20 22 21 23 24 25 26 27 28 30 29 32 31"]}, {"input": "33 1811927\r\n", "output": ["1 2 4 3 5 7 6 9 8 10 11 13 12 15 14 16 18 17 19 21 20 22 23 24 25 26 27 28 29 31 30 32 33"]}, {"input": "34 2412850\r\n", "output": ["1 2 4 3 5 6 7 9 8 10 11 13 12 14 16 15 18 17 19 20 21 22 23 25 24 26 28 27 29 31 30 32 34 33"]}, {"input": "35 706065\r\n", "output": ["1 2 3 4 5 6 8 7 9 11 10 13 12 15 14 16 18 17 20 19 21 23 22 25 24 27 26 28 29 31 30 32 33 35 34"]}, {"input": "36 7074882\r\n", "output": ["1 2 4 3 5 7 6 8 9 10 11 12 13 14 16 15 18 17 19 20 22 21 23 25 24 26 27 28 30 29 32 31 33 34 35 36"]}, {"input": "37 27668397\r\n", "output": ["2 1 3 4 5 7 6 9 8 11 10 13 12 15 14 16 18 17 19 21 20 23 22 24 25 26 28 27 30 29 32 31 34 33 35 36 37"]}, {"input": "38 23790805\r\n", "output": ["1 2 4 3 6 5 8 7 10 9 11 12 14 13 15 16 18 17 20 19 21 22 24 23 25 27 26 29 28 31 30 32 33 34 36 35 38 37"]}, {"input": "39 68773650\r\n", "output": ["2 1 3 4 5 6 8 7 10 9 12 11 13 15 14 16 17 19 18 20 21 23 22 24 26 25 28 27 29 31 30 32 33 34 35 36 37 39 38"]}, {"input": "40 43782404\r\n", "output": ["1 2 4 3 5 6 7 9 8 10 12 11 14 13 15 16 17 18 20 19 21 22 23 25 24 26 28 27 29 31 30 32 34 33 36 35 37 39 38 40"]}, {"input": "41 130268954\r\n", "output": ["1 3 2 4 6 5 7 8 10 9 11 12 13 14 16 15 17 19 18 20 21 23 22 25 24 26 27 28 30 29 31 32 34 33 35 36 37 38 39 41 40"]}, {"input": "42 40985206\r\n", "output": ["1 2 3 4 6 5 7 8 9 10 11 13 12 15 14 16 17 18 19 21 20 22 24 23 25 26 28 27 29 30 31 33 32 35 34 36 37 39 38 40 42 41"]}, {"input": "43 193787781\r\n", "output": ["1 2 4 3 5 6 8 7 9 10 12 11 13 14 16 15 17 18 19 20 21 22 24 23 25 26 27 28 29 30 31 32 33 35 34 36 38 37 39 40 41 43 42"]}, {"input": "44 863791309\r\n", "output": ["2 1 3 4 6 5 8 7 10 9 12 11 13 14 15 16 18 17 19 20 21 22 23 24 26 25 27 29 28 31 30 32 34 33 36 35 38 37 40 39 41 42 44 43"]}, {"input": "45 1817653076\r\n", "output": ["2 1 4 3 6 5 8 7 9 11 10 12 14 13 16 15 18 17 19 20 22 21 24 23 25 27 26 29 28 30 32 31 34 33 35 36 38 37 39 40 42 41 43 44 45"]}, {"input": "46 1176411936\r\n", "output": ["1 3 2 4 5 6 7 8 10 9 11 12 13 14 16 15 17 18 19 21 20 22 23 25 24 27 26 29 28 31 30 32 34 33 35 37 36 38 40 39 41 42 43 44 46 45"]}, {"input": "47 4199125763\r\n", "output": ["2 1 4 3 5 6 7 8 10 9 12 11 13 14 16 15 18 17 20 19 22 21 23 24 25 27 26 28 30 29 31 32 33 34 36 35 38 37 39 40 41 43 42 44 45 46 47"]}, {"input": "48 4534695914\r\n", "output": ["1 3 2 5 4 6 8 7 10 9 12 11 14 13 15 17 16 18 19 21 20 23 22 25 24 26 27 28 29 30 31 32 33 34 36 35 37 38 40 39 41 43 42 44 46 45 47 48"]}, {"input": "49 3790978105\r\n", "output": ["1 2 4 3 5 7 6 8 9 11 10 12 13 15 14 16 17 18 19 21 20 22 24 23 25 27 26 28 30 29 31 33 32 35 34 37 36 38 39 41 40 42 44 43 45 47 46 48 49"]}, {"input": "50 5608642004\r\n", "output": ["1 2 4 3 5 6 8 7 9 10 11 13 12 15 14 17 16 18 20 19 22 21 23 24 25 26 28 27 30 29 31 32 33 34 35 36 38 37 40 39 42 41 44 43 45 46 47 48 50 49"]}]
100
100
100
[{'input': '7 20\r\n', 'output': ['2 1 4 3 5 7 6']}, {'input': '27 298209\r\n', 'output': ['2 1 4 3 5 7 6 9 8 10 12 11 14 13 15 16 17 19 18 21 20 22 24 23 25 27 26']}, {'input': '24 47430\r\n', 'output': ['2 1 3 4 5 6 7 8 10 9 11 12 13 14 16 15 17 19 18 21 20 22 24 23']}, {'input': '25 58467\r\n', 'output': ['1 3 2 4 6 5 7 8 9 11 10 12 13 15 14 16 17 19 18 20 21 22 23 24 25']}, {'input': '17 734\r\n', 'output': ['1 2 4 3 5 6 8 7 10 9 11 12 13 14 15 16 17']}]
[{'input': '50 5608642004\r\n', 'output': ['1 2 4 3 5 6 8 7 9 10 11 13 12 15 14 17 16 18 20 19 22 21 23 24 25 26 28 27 30 29 31 32 33 34 35 36 38 37 40 39 42 41 44 43 45 46 47 48 50 49']}, {'input': '9 1\r\n', 'output': ['1 2 3 4 5 6 7 8 9']}, {'input': '50 1\r\n', 'output': ['1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50']}, {'input': '41 130268954\r\n', 'output': ['1 3 2 4 6 5 7 8 10 9 11 12 13 14 16 15 17 19 18 20 21 23 22 25 24 26 27 28 30 29 31 32 34 33 35 36 37 38 39 41 40']}, {'input': '11 77\r\n', 'output': ['1 3 2 5 4 6 7 8 9 10 11']}]
[{'input': '10 89\r\n', 'output': ['2 1 4 3 6 5 8 7 10 9']}, {'input': '30 582773\r\n', 'output': ['1 3 2 4 5 6 8 7 10 9 11 13 12 14 15 16 17 19 18 20 21 23 22 25 24 26 28 27 29 30']}, {'input': '41 130268954\r\n', 'output': ['1 3 2 4 6 5 7 8 10 9 11 12 13 14 16 15 17 19 18 20 21 23 22 25 24 26 27 28 30 29 31 32 34 33 35 36 37 38 39 41 40']}, {'input': '20 9999\r\n', 'output': ['2 1 4 3 5 7 6 8 9 10 11 13 12 14 15 17 16 18 19 20']}, {'input': '9 1\r\n', 'output': ['1 2 3 4 5 6 7 8 9']}]
[{'input': '26 168988\r\n', 'output': ['2 1 4 3 5 6 7 8 9 10 12 11 13 15 14 16 17 18 19 20 21 23 22 24 26 25']}, {'input': '36 7074882\r\n', 'output': ['1 2 4 3 5 7 6 8 9 10 11 12 13 14 16 15 18 17 19 20 22 21 23 25 24 26 27 28 30 29 32 31 33 34 35 36']}, {'input': '33 1811927\r\n', 'output': ['1 2 4 3 5 7 6 9 8 10 11 13 12 15 14 16 18 17 19 21 20 22 23 24 25 26 27 28 29 31 30 32 33']}, {'input': '47 4199125763\r\n', 'output': ['2 1 4 3 5 6 7 8 10 9 12 11 13 14 16 15 18 17 20 19 22 21 23 24 25 27 26 28 30 29 31 32 33 34 36 35 38 37 39 40 41 43 42 44 45 46 47']}, {'input': '9 1\r\n', 'output': ['1 2 3 4 5 6 7 8 9']}]
[{'input': '26 168988\r\n', 'output': ['2 1 4 3 5 6 7 8 9 10 12 11 13 15 14 16 17 18 19 20 21 23 22 24 26 25']}, {'input': '46 1176411936\r\n', 'output': ['1 3 2 4 5 6 7 8 10 9 11 12 13 14 16 15 17 18 19 21 20 22 23 25 24 27 26 29 28 31 30 32 34 33 35 37 36 38 40 39 41 42 43 44 46 45']}, {'input': '50 20365011074\r\n', 'output': ['2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 25 28 27 30 29 32 31 34 33 36 35 38 37 40 39 42 41 44 43 46 45 48 47 50 49']}, {'input': '41 130268954\r\n', 'output': ['1 3 2 4 6 5 7 8 10 9 11 12 13 14 16 15 17 19 18 20 21 23 22 25 24 26 27 28 30 29 31 32 34 33 35 36 37 38 39 41 40']}, {'input': '11 77\r\n', 'output': ['1 3 2 5 4 6 7 8 9 10 11']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
101
100
100
100
["512 4", "1000000000 9"]
The first line of the input contains two integer numbers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le k \le 50$$$) — the number from which Tanya will subtract and the number of subtractions correspondingly.
064162604284ce252b88050b4174ba55
#include<bits/stdc++.h> using namespace std; long long a,b; int main(void) { scanf("%d%d",&a,&b); while(b--)if(a%10)a--;else a/=10; printf("%lld",a); return 0; }
["50", "1"]
C++
NoteThe first example corresponds to the following sequence: $$$512 \rightarrow 511 \rightarrow 510 \rightarrow 51 \rightarrow 50$$$.
Print one integer number — the result of the decreasing $$$n$$$ by one $$$k$$$ times. It is guaranteed that the result will be positive integer number.
Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm: if the last digit of the number is non-zero, she decreases the number by one; if the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit). You are given an integer number $$$n$$$. Tanya will subtract one from it $$$k$$$ times. Your task is to print the result after all $$$k$$$ subtractions.It is guaranteed that the result will be positive integer number.
[{"input": "512 4\r\n", "output": ["50"]}, {"input": "1000000000 9\r\n", "output": ["1"]}, {"input": "131203 11\r\n", "output": ["12"]}, {"input": "999999999 50\r\n", "output": ["9999"]}, {"input": "999999999 49\r\n", "output": ["99990"]}, {"input": "131203 9\r\n", "output": ["130"]}, {"input": "900000000 16\r\n", "output": ["1"]}, {"input": "909090909 50\r\n", "output": ["3"]}, {"input": "1001 2\r\n", "output": ["100"]}, {"input": "5 2\r\n", "output": ["3"]}, {"input": "2 1\r\n", "output": ["1"]}]
100
100
100
[{'input': '131203 11\r\n', 'output': ['12']}, {'input': '1000000000 9\r\n', 'output': ['1']}, {'input': '512 4\r\n', 'output': ['50']}, {'input': '2 1\r\n', 'output': ['1']}, {'input': '5 2\r\n', 'output': ['3']}]
[{'input': '999999999 50\r\n', 'output': ['9999']}, {'input': '131203 11\r\n', 'output': ['12']}, {'input': '900000000 16\r\n', 'output': ['1']}, {'input': '512 4\r\n', 'output': ['50']}, {'input': '909090909 50\r\n', 'output': ['3']}]
[{'input': '1000000000 9\r\n', 'output': ['1']}, {'input': '900000000 16\r\n', 'output': ['1']}, {'input': '1001 2\r\n', 'output': ['100']}, {'input': '5 2\r\n', 'output': ['3']}, {'input': '909090909 50\r\n', 'output': ['3']}]
[{'input': '2 1\r\n', 'output': ['1']}, {'input': '5 2\r\n', 'output': ['3']}, {'input': '131203 9\r\n', 'output': ['130']}, {'input': '1001 2\r\n', 'output': ['100']}, {'input': '512 4\r\n', 'output': ['50']}]
[{'input': '999999999 50\r\n', 'output': ['9999']}, {'input': '5 2\r\n', 'output': ['3']}, {'input': '131203 11\r\n', 'output': ['12']}, {'input': '1001 2\r\n', 'output': ['100']}, {'input': '909090909 50\r\n', 'output': ['3']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
102
100
100
100
["4 4 0\n2 1 2", "5 6 1\n2 7 2", "3 3 3\n2 2 2"]
The first line of the input contains three integers a, b and c (0 ≤ a, b, c ≤ 1 000 000) — the number of blue, violet and orange spheres that are in the magician's disposal. The second line of the input contains three integers, x, y and z (0 ≤ x, y, z ≤ 1 000 000) — the number of blue, violet and orange spheres that he needs to get.
1db4ba9dc1000e26532bb73336cf12c3
///////////////////////////////////////////// ///////////// YURKA PRO AZAZAZ ////////// /////////////////////////////////////////// #include <bits/stdc++.h> #define pb push_back using namespace std; const long long INF = 1e9; long long n,m,k,ans,sum,mn,pl; long long x,y,z; long long a,b,c,tmp,nd; bool na,nb,nc; main() { cin >> x >> y >> z; cin >> a >> b >> c; if(x > a) tmp+=((x-a)/2); else nd+= a-x; if(y > b) tmp+=((y-b)/2); else nd+= b-y; if(z > c) tmp+=((z-c)/2); else nd+= c-z; if(tmp >= nd) cout << "YES"; else cout << "NO"; }
["Yes", "No", "Yes"]
C++
NoteIn the first sample the wizard has 4 blue and 4 violet spheres. In his first action he can turn two blue spheres into one violet one. After that he will have 2 blue and 5 violet spheres. Then he turns 4 violet spheres into 2 orange spheres and he ends up with 2 blue, 1 violet and 2 orange spheres, which is exactly what he needs.
If the wizard is able to obtain the required numbers of spheres, print "Yes". Otherwise, print "No".
Carl is a beginner magician. He has a blue, b violet and c orange magic spheres. In one move he can transform two spheres of the same color into one sphere of any other color. To make a spell that has never been seen before, he needs at least x blue, y violet and z orange spheres. Can he get them (possible, in multiple actions)?
[{"input": "4 4 0\r\n2 1 2\r\n", "output": ["YES", "Yes"]}, {"input": "5 6 1\r\n2 7 2\r\n", "output": ["No", "NO"]}, {"input": "3 3 3\r\n2 2 2\r\n", "output": ["YES", "Yes"]}, {"input": "0 0 0\r\n0 0 0\r\n", "output": ["YES", "Yes"]}, {"input": "0 0 0\r\n0 0 1\r\n", "output": ["No", "NO"]}, {"input": "0 1 0\r\n0 0 0\r\n", "output": ["YES", "Yes"]}, {"input": "1 0 0\r\n1 0 0\r\n", "output": ["YES", "Yes"]}, {"input": "2 2 1\r\n1 1 2\r\n", "output": ["No", "NO"]}, {"input": "1 3 1\r\n2 1 1\r\n", "output": ["YES", "Yes"]}, {"input": "1000000 1000000 1000000\r\n1000000 1000000 1000000\r\n", "output": ["YES", "Yes"]}, {"input": "1000000 500000 500000\r\n0 750000 750000\r\n", "output": ["YES", "Yes"]}, {"input": "500000 1000000 500000\r\n750001 0 750000\r\n", "output": ["No", "NO"]}, {"input": "499999 500000 1000000\r\n750000 750000 0\r\n", "output": ["No", "NO"]}, {"input": "500000 500000 0\r\n0 0 500000\r\n", "output": ["YES", "Yes"]}, {"input": "0 500001 499999\r\n500000 0 0\r\n", "output": ["No", "NO"]}, {"input": "1000000 500000 1000000\r\n500000 1000000 500000\r\n", "output": ["YES", "Yes"]}, {"input": "1000000 1000000 499999\r\n500000 500000 1000000\r\n", "output": ["No", "NO"]}, {"input": "500000 1000000 1000000\r\n1000000 500001 500000\r\n", "output": ["No", "NO"]}, {"input": "1000000 500000 500000\r\n0 1000000 500000\r\n", "output": ["YES", "Yes"]}, {"input": "500000 500000 1000000\r\n500001 1000000 0\r\n", "output": ["No", "NO"]}, {"input": "500000 999999 500000\r\n1000000 0 500000\r\n", "output": ["No", "NO"]}, {"input": "4 0 3\r\n2 2 1\r\n", "output": ["YES", "Yes"]}, {"input": "0 2 4\r\n2 0 2\r\n", "output": ["YES", "Yes"]}, {"input": "3 1 0\r\n1 1 1\r\n", "output": ["YES", "Yes"]}, {"input": "4 4 1\r\n1 3 2\r\n", "output": ["YES", "Yes"]}, {"input": "1 2 4\r\n2 1 3\r\n", "output": ["No", "NO"]}, {"input": "1 1 0\r\n0 0 1\r\n", "output": ["No", "NO"]}, {"input": "4 0 0\r\n0 1 1\r\n", "output": ["YES", "Yes"]}, {"input": "0 3 0\r\n1 0 1\r\n", "output": ["No", "NO"]}, {"input": "0 0 3\r\n1 0 1\r\n", "output": ["YES", "Yes"]}, {"input": "1 12 1\r\n4 0 4\r\n", "output": ["YES", "Yes"]}, {"input": "4 0 4\r\n1 2 1\r\n", "output": ["YES", "Yes"]}, {"input": "4 4 0\r\n1 1 3\r\n", "output": ["No", "NO"]}, {"input": "0 9 0\r\n2 2 2\r\n", "output": ["No", "NO"]}, {"input": "0 10 0\r\n2 2 2\r\n", "output": ["YES", "Yes"]}, {"input": "9 0 9\r\n0 8 0\r\n", "output": ["YES", "Yes"]}, {"input": "0 9 9\r\n9 0 0\r\n", "output": ["No", "NO"]}, {"input": "9 10 0\r\n0 0 9\r\n", "output": ["YES", "Yes"]}, {"input": "10 0 9\r\n0 10 0\r\n", "output": ["No", "NO"]}, {"input": "0 10 10\r\n10 0 0\r\n", "output": ["YES", "Yes"]}, {"input": "10 10 0\r\n0 0 11\r\n", "output": ["No", "NO"]}, {"input": "307075 152060 414033\r\n381653 222949 123101\r\n", "output": ["No", "NO"]}, {"input": "569950 228830 153718\r\n162186 357079 229352\r\n", "output": ["No", "NO"]}, {"input": "149416 303568 749016\r\n238307 493997 190377\r\n", "output": ["No", "NO"]}, {"input": "438332 298094 225324\r\n194220 400244 245231\r\n", "output": ["No", "NO"]}, {"input": "293792 300060 511272\r\n400687 382150 133304\r\n", "output": ["No", "NO"]}, {"input": "295449 518151 368838\r\n382897 137148 471892\r\n", "output": ["No", "NO"]}, {"input": "191789 291147 691092\r\n324321 416045 176232\r\n", "output": ["YES", "Yes"]}, {"input": "286845 704749 266526\r\n392296 104421 461239\r\n", "output": ["YES", "Yes"]}, {"input": "135522 188282 377041\r\n245719 212473 108265\r\n", "output": ["YES", "Yes"]}, {"input": "404239 359124 133292\r\n180069 184791 332544\r\n", "output": ["No", "NO"]}, {"input": "191906 624432 244408\r\n340002 367217 205432\r\n", "output": ["No", "NO"]}, {"input": "275980 429361 101824\r\n274288 302579 166062\r\n", "output": ["No", "NO"]}, {"input": "136092 364927 395302\r\n149173 343146 390922\r\n", "output": ["No", "NO"]}, {"input": "613852 334661 146012\r\n363786 326286 275233\r\n", "output": ["No", "NO"]}, {"input": "348369 104625 525203\r\n285621 215396 366411\r\n", "output": ["No", "NO"]}, {"input": "225307 153572 114545\r\n154753 153282 149967\r\n", "output": ["YES", "Yes"]}, {"input": "438576 124465 629784\r\n375118 276028 390116\r\n", "output": ["YES", "Yes"]}, {"input": "447521 327510 158732\r\n395759 178458 259139\r\n", "output": ["YES", "Yes"]}, {"input": "8 5 5\r\n5 5 5\r\n", "output": ["YES", "Yes"]}, {"input": "100 100 100\r\n1 1 1\r\n", "output": ["YES", "Yes"]}, {"input": "100 100 100\r\n0 0 0\r\n", "output": ["YES", "Yes"]}, {"input": "3 2 3\r\n2 3 2\r\n", "output": ["No", "NO"]}, {"input": "5 4 3\r\n2 2 2\r\n", "output": ["YES", "Yes"]}, {"input": "14 9 8\r\n12 5 10\r\n", "output": ["YES", "Yes"]}, {"input": "10 10 10\r\n1 1 1\r\n", "output": ["YES", "Yes"]}, {"input": "6 3 3\r\n3 3 3\r\n", "output": ["YES", "Yes"]}, {"input": "10 0 4\r\n2 4 2\r\n", "output": ["YES", "Yes"]}, {"input": "100 100 100\r\n2 2 2\r\n", "output": ["YES", "Yes"]}, {"input": "4 6 0\r\n2 1 2\r\n", "output": ["YES", "Yes"]}, {"input": "4 6 3\r\n4 2 3\r\n", "output": ["YES", "Yes"]}, {"input": "5 5 5\r\n1 1 1\r\n", "output": ["YES", "Yes"]}, {"input": "41 17 34\r\n0 19 24\r\n", "output": ["YES", "Yes"]}, {"input": "8 8 8\r\n3 3 3\r\n", "output": ["YES", "Yes"]}, {"input": "7 7 1\r\n1 1 2\r\n", "output": ["YES", "Yes"]}, {"input": "6 6 0\r\n2 2 2\r\n", "output": ["YES", "Yes"]}, {"input": "5 5 5\r\n2 2 2\r\n", "output": ["YES", "Yes"]}, {"input": "400 400 400\r\n1 1 1\r\n", "output": ["YES", "Yes"]}, {"input": "4 4 4\r\n2 2 2\r\n", "output": ["YES", "Yes"]}]
100
100
100
[{'input': '4 0 4\r\n1 2 1\r\n', 'output': ['YES', 'Yes']}, {'input': '0 0 0\r\n0 0 0\r\n', 'output': ['YES', 'Yes']}, {'input': '100 100 100\r\n1 1 1\r\n', 'output': ['YES', 'Yes']}, {'input': '10 10 10\r\n1 1 1\r\n', 'output': ['YES', 'Yes']}, {'input': '225307 153572 114545\r\n154753 153282 149967\r\n', 'output': ['YES', 'Yes']}]
[{'input': '0 10 0\r\n2 2 2\r\n', 'output': ['YES', 'Yes']}, {'input': '0 2 4\r\n2 0 2\r\n', 'output': ['YES', 'Yes']}, {'input': '191789 291147 691092\r\n324321 416045 176232\r\n', 'output': ['YES', 'Yes']}, {'input': '3 3 3\r\n2 2 2\r\n', 'output': ['YES', 'Yes']}, {'input': '0 0 0\r\n0 0 1\r\n', 'output': ['No', 'NO']}]
[{'input': '14 9 8\r\n12 5 10\r\n', 'output': ['YES', 'Yes']}, {'input': '100 100 100\r\n1 1 1\r\n', 'output': ['YES', 'Yes']}, {'input': '1 2 4\r\n2 1 3\r\n', 'output': ['No', 'NO']}, {'input': '41 17 34\r\n0 19 24\r\n', 'output': ['YES', 'Yes']}, {'input': '0 9 0\r\n2 2 2\r\n', 'output': ['No', 'NO']}]
[{'input': '569950 228830 153718\r\n162186 357079 229352\r\n', 'output': ['No', 'NO']}, {'input': '7 7 1\r\n1 1 2\r\n', 'output': ['YES', 'Yes']}, {'input': '4 4 0\r\n1 1 3\r\n', 'output': ['No', 'NO']}, {'input': '4 4 0\r\n2 1 2\r\n', 'output': ['YES', 'Yes']}, {'input': '5 5 5\r\n1 1 1\r\n', 'output': ['YES', 'Yes']}]
[{'input': '9 0 9\r\n0 8 0\r\n', 'output': ['YES', 'Yes']}, {'input': '149416 303568 749016\r\n238307 493997 190377\r\n', 'output': ['No', 'NO']}, {'input': '136092 364927 395302\r\n149173 343146 390922\r\n', 'output': ['No', 'NO']}, {'input': '307075 152060 414033\r\n381653 222949 123101\r\n', 'output': ['No', 'NO']}, {'input': '100 100 100\r\n1 1 1\r\n', 'output': ['YES', 'Yes']}]
100
100
100
100
100
91.67
100
100
91.67
91.67
87.5
100
100
87.5
87.5
103
100
95.002
92.5
["1", "2", "3"]
The first line contains a single integer n (1 ≤ n ≤ 40).
c2cbc35012c6ff7ab0d6899e6015e4e7
//Tornike Mandzulashvili //#pragma comment(linker, "/STACK:16777216") #include <time.h> #include <stdio.h> #include <stdlib.h> #include <algorithm> #include <math.h> #include <vector> #include <string> #include <map> #include <queue> #include <iostream> #include <set> #define PI 3.14159265 #define hash1 1000003 #define hash2 1000033 #define md 1000000007 #define INF 1000000000 using namespace std; long long d[41]={2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497, 86243, 110503, 132049, 216091, 756839, 859433, 1257787, 1398269, 2976221, 3021377, 6972593, 13466917, 20996011, 24036583}; long long n; long long go(long long num) { if (num==0) return 1; long long h=go(num/2); if (num%2) return (h*h%md)*2LL%md;else return h*h%md; } main() { //freopen("text.in","r",stdin);freopen("text.out","w",stdout); cin>>n; cout<<(go(d[n-1]-1)+md-1)%md<<endl; }
["1", "3", "15"]
C++
null
Print a single integer — the number zn modulo 1000000007 (109 + 7). It is guaranteed that the answer exists.
Consider the following equation: where sign [a] represents the integer part of number a.Let's find all integer z (z &gt; 0), for which this equation is unsolvable in positive integers. The phrase "unsolvable in positive integers" means that there are no such positive integers x and y (x, y &gt; 0), for which the given above equation holds.Let's write out all such z in the increasing order: z1, z2, z3, and so on (zi &lt; zi + 1). Your task is: given the number n, find the number zn.
[{"input": "1\r\n", "output": ["1"]}, {"input": "2\r\n", "output": ["3"]}, {"input": "3\r\n", "output": ["15"]}, {"input": "4\r\n", "output": ["63"]}, {"input": "5\r\n", "output": ["4095"]}, {"input": "6\r\n", "output": ["65535"]}, {"input": "7\r\n", "output": ["262143"]}, {"input": "8\r\n", "output": ["73741816"]}, {"input": "9\r\n", "output": ["536396503"]}, {"input": "10\r\n", "output": ["140130950"]}, {"input": "11\r\n", "output": ["487761805"]}, {"input": "12\r\n", "output": ["319908070"]}, {"input": "13\r\n", "output": ["106681874"]}, {"input": "14\r\n", "output": ["373391776"]}, {"input": "15\r\n", "output": ["317758023"]}, {"input": "16\r\n", "output": ["191994803"]}, {"input": "17\r\n", "output": ["416292236"]}, {"input": "18\r\n", "output": ["110940209"]}, {"input": "19\r\n", "output": ["599412198"]}, {"input": "20\r\n", "output": ["383601260"]}, {"input": "21\r\n", "output": ["910358878"]}, {"input": "22\r\n", "output": ["532737550"]}, {"input": "23\r\n", "output": ["348927936"]}, {"input": "24\r\n", "output": ["923450985"]}, {"input": "25\r\n", "output": ["470083777"]}, {"input": "26\r\n", "output": ["642578561"]}, {"input": "27\r\n", "output": ["428308066"]}, {"input": "28\r\n", "output": ["485739298"]}, {"input": "29\r\n", "output": ["419990027"]}, {"input": "30\r\n", "output": ["287292016"]}, {"input": "31\r\n", "output": ["202484167"]}, {"input": "32\r\n", "output": ["389339971"]}, {"input": "33\r\n", "output": ["848994100"]}, {"input": "34\r\n", "output": ["273206869"]}, {"input": "35\r\n", "output": ["853092282"]}, {"input": "36\r\n", "output": ["411696552"]}, {"input": "37\r\n", "output": ["876153853"]}, {"input": "38\r\n", "output": ["90046024"]}, {"input": "39\r\n", "output": ["828945523"]}, {"input": "40\r\n", "output": ["697988359"]}]
100
100
100
[{'input': '7\r\n', 'output': ['262143']}, {'input': '3\r\n', 'output': ['15']}, {'input': '26\r\n', 'output': ['642578561']}, {'input': '37\r\n', 'output': ['876153853']}, {'input': '32\r\n', 'output': ['389339971']}]
[{'input': '12\r\n', 'output': ['319908070']}, {'input': '2\r\n', 'output': ['3']}, {'input': '33\r\n', 'output': ['848994100']}, {'input': '36\r\n', 'output': ['411696552']}, {'input': '3\r\n', 'output': ['15']}]
[{'input': '30\r\n', 'output': ['287292016']}, {'input': '21\r\n', 'output': ['910358878']}, {'input': '28\r\n', 'output': ['485739298']}, {'input': '11\r\n', 'output': ['487761805']}, {'input': '1\r\n', 'output': ['1']}]
[{'input': '25\r\n', 'output': ['470083777']}, {'input': '34\r\n', 'output': ['273206869']}, {'input': '1\r\n', 'output': ['1']}, {'input': '18\r\n', 'output': ['110940209']}, {'input': '30\r\n', 'output': ['287292016']}]
[{'input': '37\r\n', 'output': ['876153853']}, {'input': '2\r\n', 'output': ['3']}, {'input': '15\r\n', 'output': ['317758023']}, {'input': '24\r\n', 'output': ['923450985']}, {'input': '10\r\n', 'output': ['140130950']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
104
100
100
100
["1 3", "2 2"]
The first line contains two integers $$$n$$$ and $$$m$$$, separated by spaces ($$$1 \leq n,m \leq 10^9$$$) — the number of kinds of presents and the number of boxes that Alice has.
71029e5bf085b0f5f39d1835eb801891
#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<queue> #include<set> #include<vector> #include<cmath> using namespace std; typedef long long ll; const ll p = 1e9 + 7; ll n,m,ans; ll qp(ll a,ll b){ ll ans = 1,base = a; while(b != 0){ if(b & 1)ans = ans * base % p; base = base * base % p; b >>= 1; } return ans; } int main() { scanf("%lld%lld",&n,&m); ans = qp((qp(2,m)%p - 1 + p)%p,n)%p; cout<<ans<<endl; return 0; } /* long long 线段树四倍 写代码时请注意: 1.是否要开Long Long?数组边界处理好了么? 2.实数精度有没有处理? 3.特殊情况处理好了么? 4.做一些总比不做好. 思考提醒: 1.最大值和最小值问题可不可以用二分答案? 2.有没有贪心策略?否则能不能dp? */
["7", "9"]
C++
NoteIn the first example, there are seven ways to pack presents:$$$\{1\}\{\}\{\}$$$$$$\{\}\{1\}\{\}$$$$$$\{\}\{\}\{1\}$$$$$$\{1\}\{1\}\{\}$$$$$$\{\}\{1\}\{1\}$$$$$$\{1\}\{\}\{1\}$$$$$$\{1\}\{1\}\{1\}$$$In the second example there are nine ways to pack presents:$$$\{\}\{1,2\}$$$$$$\{1\}\{2\}$$$$$$\{1\}\{1,2\}$$$$$$\{2\}\{1\}$$$$$$\{2\}\{1,2\}$$$$$$\{1,2\}\{\}$$$$$$\{1,2\}\{1\}$$$$$$\{1,2\}\{2\}$$$$$$\{1,2\}\{1,2\}$$$For example, the way $$$\{2\}\{2\}$$$ is wrong, because presents of the first kind should be used in the least one box.
Print one integer  — the number of ways to pack the presents with Alice's rules, calculated by modulo $$$10^9+7$$$
Alice got many presents these days. So she decided to pack them into boxes and send them to her friends.There are $$$n$$$ kinds of presents. Presents of one kind are identical (i.e. there is no way to distinguish two gifts of the same kind). Presents of different kinds are different (i.e. that is, two gifts of different kinds are distinguishable). The number of presents of each kind, that Alice has is very big, so we can consider Alice has an infinite number of gifts of each kind.Also, there are $$$m$$$ boxes. All of them are for different people, so they are pairwise distinct (consider that the names of $$$m$$$ friends are written on the boxes). For example, putting the first kind of present into the first box but not into the second box, is different from putting the first kind of present into the second box but not into the first box.Alice wants to pack presents with the following rules: She won't pack more than one present of each kind into the same box, so each box should contain presents of different kinds (i.e. each box contains a subset of $$$n$$$ kinds, empty boxes are allowed); For each kind at least one present should be packed into some box. Now Alice wants to know how many different ways to pack the presents exists. Please, help her and calculate this number. Since the answer can be huge, output it by modulo $$$10^9+7$$$.See examples and their notes for clarification.
[{"input": "1 3\r\n", "output": ["7"]}, {"input": "2 2\r\n", "output": ["9"]}, {"input": "1000000000 1000000000\r\n", "output": ["751201557"]}, {"input": "489132389 96\r\n", "output": ["496937"]}, {"input": "462817723 208\r\n", "output": ["886407548"]}, {"input": "10 415749054\r\n", "output": ["763222305"]}, {"input": "185182737 683516583\r\n", "output": ["568113155"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "67 445057511\r\n", "output": ["687331027"]}, {"input": "53 710974288\r\n", "output": ["739543572"]}, {"input": "766313215 146\r\n", "output": ["577417399"]}, {"input": "483378560 249\r\n", "output": ["400296687"]}, {"input": "294440070 297\r\n", "output": ["391755258"]}, {"input": "22 346212760\r\n", "output": ["70690719"]}, {"input": "214 70\r\n", "output": ["57768876"]}, {"input": "498 36\r\n", "output": ["238608733"]}, {"input": "243 155\r\n", "output": ["872572138"]}, {"input": "911 144\r\n", "output": ["588180251"]}, {"input": "1208 1429\r\n", "output": ["809533438"]}, {"input": "362 1464\r\n", "output": ["76973162"]}, {"input": "1956 1933\r\n", "output": ["376783113"]}, {"input": "958 1712\r\n", "output": ["555561716"]}, {"input": "1737 2760\r\n", "output": ["702877932"]}, {"input": "297 2221\r\n", "output": ["118273419"]}, {"input": "851963022 4\r\n", "output": ["843890746"]}, {"input": "242811857 22\r\n", "output": ["658352132"]}, {"input": "943226362 45\r\n", "output": ["326355794"]}, {"input": "744891088 118\r\n", "output": ["857670894"]}, {"input": "607778684 18\r\n", "output": ["241523454"]}, {"input": "69 553612861\r\n", "output": ["343253715"]}, {"input": "39 884188112\r\n", "output": ["485799965"]}, {"input": "208 898957748\r\n", "output": ["590505163"]}, {"input": "204 697134196\r\n", "output": ["878017912"]}, {"input": "311 619805019\r\n", "output": ["357441166"]}, {"input": "75 511331377\r\n", "output": ["891361754"]}, {"input": "798664260 289720442\r\n", "output": ["405748370"]}, {"input": "118448079 385479325\r\n", "output": ["929397040"]}, {"input": "122681800 592225969\r\n", "output": ["849919410"]}, {"input": "411520242 339446102\r\n", "output": ["69858832"]}, {"input": "248755287 144691387\r\n", "output": ["666866415"]}, {"input": "617282691 956569994\r\n", "output": ["407582988"]}, {"input": "565315457 718194150\r\n", "output": ["180672585"]}, {"input": "330332097 730084442\r\n", "output": ["536919158"]}, {"input": "534571158 222043261\r\n", "output": ["212941625"]}, {"input": "807153816 542148359\r\n", "output": ["452817189"]}, {"input": "35785771 557468706\r\n", "output": ["763956563"]}, {"input": "199108316 823003436\r\n", "output": ["650559775"]}, {"input": "592582684 738223068\r\n", "output": ["830809744"]}, {"input": "840387185 768322358\r\n", "output": ["364216881"]}, {"input": "294176817 643050540\r\n", "output": ["425282882"]}, {"input": "651139198 572383165\r\n", "output": ["362206900"]}, {"input": "314697041 784667526\r\n", "output": ["579388817"]}, {"input": "188186551 379116090\r\n", "output": ["655244255"]}, {"input": "922338645 900544285\r\n", "output": ["187784871"]}, {"input": "117909304 588342759\r\n", "output": ["852741659"]}, {"input": "426452433 106792\r\n", "output": ["740748981"]}, {"input": "686898624 980111485\r\n", "output": ["805355123"]}, {"input": "169231047 790996597\r\n", "output": ["442732671"]}, {"input": "393454015 42675288\r\n", "output": ["221958294"]}, {"input": "955475387 410847984\r\n", "output": ["544061679"]}, {"input": "290496089 820810891\r\n", "output": ["707906935"]}, {"input": "635994662 423804127\r\n", "output": ["831152709"]}, {"input": "33727662 414901164\r\n", "output": ["529262173"]}, {"input": "886792224 998690495\r\n", "output": ["183247773"]}, {"input": "31 112\r\n", "output": ["626643854"]}, {"input": "71 106\r\n", "output": ["603494283"]}, {"input": "100 474\r\n", "output": ["180274936"]}, {"input": "14 469\r\n", "output": ["14294519"]}, {"input": "18 290\r\n", "output": ["544261782"]}, {"input": "172 39\r\n", "output": ["222650110"]}, {"input": "139 415\r\n", "output": ["639620853"]}, {"input": "117 2553\r\n", "output": ["906570878"]}, {"input": "156 342\r\n", "output": ["306076272"]}, {"input": "260 2998\r\n", "output": ["573924479"]}, {"input": "184 7\r\n", "output": ["715075794"]}, {"input": "428 71\r\n", "output": ["677189841"]}, {"input": "1046 34\r\n", "output": ["92349932"]}, {"input": "560 27\r\n", "output": ["179196390"]}, {"input": "732 137\r\n", "output": ["596791767"]}, {"input": "1730 39\r\n", "output": ["352860620"]}, {"input": "1335 185\r\n", "output": ["596600489"]}, {"input": "175 59\r\n", "output": ["315527995"]}, {"input": "900 32\r\n", "output": ["832035237"]}, {"input": "2998 38\r\n", "output": ["63403329"]}, {"input": "1 1000000000\r\n", "output": ["140625000"]}, {"input": "1000000000 1\r\n", "output": ["1"]}, {"input": "5 2\r\n", "output": ["243"]}, {"input": "2 5\r\n", "output": ["961"]}, {"input": "7 6\r\n", "output": ["980611601"]}, {"input": "5 8\r\n", "output": ["203901829"]}]
100
100
100
[{'input': '686898624 980111485\r\n', 'output': ['805355123']}, {'input': '565315457 718194150\r\n', 'output': ['180672585']}, {'input': '184 7\r\n', 'output': ['715075794']}, {'input': '1046 34\r\n', 'output': ['92349932']}, {'input': '807153816 542148359\r\n', 'output': ['452817189']}]
[{'input': '732 137\r\n', 'output': ['596791767']}, {'input': '635994662 423804127\r\n', 'output': ['831152709']}, {'input': '1 3\r\n', 'output': ['7']}, {'input': '943226362 45\r\n', 'output': ['326355794']}, {'input': '53 710974288\r\n', 'output': ['739543572']}]
[{'input': '1 1000000000\r\n', 'output': ['140625000']}, {'input': '67 445057511\r\n', 'output': ['687331027']}, {'input': '214 70\r\n', 'output': ['57768876']}, {'input': '39 884188112\r\n', 'output': ['485799965']}, {'input': '900 32\r\n', 'output': ['832035237']}]
[{'input': '117909304 588342759\r\n', 'output': ['852741659']}, {'input': '411520242 339446102\r\n', 'output': ['69858832']}, {'input': '67 445057511\r\n', 'output': ['687331027']}, {'input': '199108316 823003436\r\n', 'output': ['650559775']}, {'input': '156 342\r\n', 'output': ['306076272']}]
[{'input': '100 474\r\n', 'output': ['180274936']}, {'input': '943226362 45\r\n', 'output': ['326355794']}, {'input': '607778684 18\r\n', 'output': ['241523454']}, {'input': '651139198 572383165\r\n', 'output': ['362206900']}, {'input': '483378560 249\r\n', 'output': ['400296687']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
105
100
100
100
["6\n1 5 5 5 4 2", "5\n10 20 30 20 10", "4\n1 2 1 2", "7\n3 3 3 3 3 3 3"]
The first line contains integer n (1 ≤ n ≤ 100) — the number of elements in the array. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 1 000) — the elements of the array.
5482ed8ad02ac32d28c3888299bf3658
#include<iostream> using namespace std; int i,x,y,n,f,ff; int main(){ f=0; cin>>n; cin>>y; for(i=2;i<=n;i++){ cin>>x; if(x>y)ff=0; if(x==y)ff=1; if(x<y)ff=2; if(ff<f){ cout<<"NO"; return 0; } f=ff; y=x; } cout<<"YES"; }
["YES", "YES", "NO", "YES"]
C++
NoteIn the first example the array is unimodal, because it is strictly increasing in the beginning (from position 1 to position 2, inclusively), that it is constant (from position 2 to position 4, inclusively) and then it is strictly decreasing (from position 4 to position 6, inclusively).
Print "YES" if the given array is unimodal. Otherwise, print "NO". You can output each letter in any case (upper or lower).
Array of integers is unimodal, if: it is strictly increasing in the beginning; after that it is constant; after that it is strictly decreasing. The first block (increasing) and the last block (decreasing) may be absent. It is allowed that both of this blocks are absent.For example, the following three arrays are unimodal: [5, 7, 11, 11, 2, 1], [4, 4, 2], [7], but the following three are not unimodal: [5, 5, 6, 6, 1], [1, 2, 1, 2], [4, 5, 5, 6].Write a program that checks if an array is unimodal.
[{"input": "6\r\n1 5 5 5 4 2\r\n", "output": ["YES"]}, {"input": "5\r\n10 20 30 20 10\r\n", "output": ["YES"]}, {"input": "4\r\n1 2 1 2\r\n", "output": ["NO"]}, {"input": "7\r\n3 3 3 3 3 3 3\r\n", "output": ["YES"]}, {"input": "6\r\n5 7 11 11 2 1\r\n", "output": ["YES"]}, {"input": "1\r\n7\r\n", "output": ["YES"]}, {"input": "100\r\n527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527\r\n", "output": ["YES"]}, {"input": "5\r\n5 5 6 6 1\r\n", "output": ["NO"]}, {"input": "3\r\n4 4 2\r\n", "output": ["YES"]}, {"input": "4\r\n4 5 5 6\r\n", "output": ["NO"]}, {"input": "3\r\n516 516 515\r\n", "output": ["YES"]}, {"input": "5\r\n502 503 508 508 507\r\n", "output": ["YES"]}, {"input": "10\r\n538 538 538 538 538 538 538 538 538 538\r\n", "output": ["YES"]}, {"input": "15\r\n452 454 455 455 450 448 443 442 439 436 433 432 431 428 426\r\n", "output": ["YES"]}, {"input": "20\r\n497 501 504 505 509 513 513 513 513 513 513 513 513 513 513 513 513 513 513 513\r\n", "output": ["YES"]}, {"input": "50\r\n462 465 465 465 463 459 454 449 444 441 436 435 430 429 426 422 421 418 417 412 408 407 406 403 402 399 395 392 387 386 382 380 379 376 374 371 370 365 363 359 358 354 350 349 348 345 342 341 338 337\r\n", "output": ["YES"]}, {"input": "70\r\n290 292 294 297 299 300 303 305 310 312 313 315 319 320 325 327 328 333 337 339 340 341 345 350 351 354 359 364 367 372 374 379 381 382 383 384 389 393 395 397 398 400 402 405 409 411 416 417 422 424 429 430 434 435 440 442 445 449 451 453 458 460 465 470 474 477 482 482 482 479\r\n", "output": ["YES"]}, {"input": "99\r\n433 435 439 444 448 452 457 459 460 464 469 470 471 476 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 480 479 478 477 476 474 469 468 465 460 457 453 452 450 445 443 440 438 433 432 431 430 428 425 421 418 414 411 406 402 397 396 393\r\n", "output": ["YES"]}, {"input": "100\r\n537 538 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543\r\n", "output": ["YES"]}, {"input": "100\r\n524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 521\r\n", "output": ["YES"]}, {"input": "100\r\n235 239 243 245 246 251 254 259 260 261 264 269 272 275 277 281 282 285 289 291 292 293 298 301 302 303 305 307 308 310 315 317 320 324 327 330 334 337 342 346 347 348 353 357 361 366 370 373 376 378 379 384 386 388 390 395 398 400 405 408 413 417 420 422 424 429 434 435 438 441 443 444 445 450 455 457 459 463 465 468 471 473 475 477 481 486 491 494 499 504 504 504 504 504 504 504 504 504 504 504\r\n", "output": ["YES"]}, {"input": "100\r\n191 196 201 202 207 212 216 219 220 222 224 227 230 231 234 235 238 242 246 250 253 254 259 260 263 267 269 272 277 280 284 287 288 290 295 297 300 305 307 312 316 320 324 326 327 332 333 334 338 343 347 351 356 358 363 368 370 374 375 380 381 386 390 391 394 396 397 399 402 403 405 410 414 419 422 427 429 433 437 442 443 447 448 451 455 459 461 462 464 468 473 478 481 484 485 488 492 494 496 496\r\n", "output": ["YES"]}, {"input": "100\r\n466 466 466 466 466 464 459 455 452 449 446 443 439 436 435 433 430 428 425 424 420 419 414 412 407 404 401 396 394 391 386 382 379 375 374 369 364 362 360 359 356 351 350 347 342 340 338 337 333 330 329 326 321 320 319 316 311 306 301 297 292 287 286 281 278 273 269 266 261 257 256 255 253 252 250 245 244 242 240 238 235 230 225 220 216 214 211 209 208 206 203 198 196 194 192 190 185 182 177 173\r\n", "output": ["YES"]}, {"input": "100\r\n360 362 367 369 374 377 382 386 389 391 396 398 399 400 405 410 413 416 419 420 423 428 431 436 441 444 445 447 451 453 457 459 463 468 468 468 468 468 468 468 468 468 468 468 468 468 468 468 468 468 468 468 468 468 468 468 465 460 455 453 448 446 443 440 436 435 430 425 420 415 410 405 404 403 402 399 394 390 387 384 382 379 378 373 372 370 369 366 361 360 355 353 349 345 344 342 339 338 335 333\r\n", "output": ["YES"]}, {"input": "1\r\n1000\r\n", "output": ["YES"]}, {"input": "100\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n", "output": ["YES"]}, {"input": "100\r\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\r\n", "output": ["YES"]}, {"input": "100\r\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1\r\n", "output": ["YES"]}, {"input": "100\r\n1 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\r\n", "output": ["YES"]}, {"input": "100\r\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 999 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\r\n", "output": ["NO"]}, {"input": "100\r\n998 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 999 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 999\r\n", "output": ["NO"]}, {"input": "100\r\n537 538 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 691 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543 543\r\n", "output": ["NO"]}, {"input": "100\r\n527 527 527 527 527 527 527 527 872 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527\r\n", "output": ["NO"]}, {"input": "100\r\n524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 208 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 521\r\n", "output": ["NO"]}, {"input": "100\r\n235 239 243 245 246 251 254 259 260 261 264 269 272 275 277 281 282 285 289 291 292 293 298 301 302 303 305 307 308 310 315 317 320 324 327 330 334 337 342 921 347 348 353 357 361 366 370 373 376 378 379 384 386 388 390 395 398 400 405 408 413 417 420 422 424 429 434 435 438 441 443 444 445 450 455 457 459 463 465 468 471 473 475 477 481 486 491 494 499 504 504 504 504 504 504 504 504 504 504 504\r\n", "output": ["NO"]}, {"input": "100\r\n191 196 201 202 207 212 216 219 220 222 224 227 230 231 234 235 238 242 246 250 253 254 259 260 263 267 269 272 277 280 284 287 288 290 295 297 300 305 307 312 316 320 324 326 327 332 333 334 338 343 347 351 356 358 119 368 370 374 375 380 381 386 390 391 394 396 397 399 402 403 405 410 414 419 422 427 429 433 437 442 443 447 448 451 455 459 461 462 464 468 473 478 481 484 485 488 492 494 496 496\r\n", "output": ["NO"]}, {"input": "100\r\n466 466 466 466 466 464 459 455 452 449 446 443 439 436 435 433 430 428 425 424 420 419 414 412 407 404 401 396 394 391 386 382 379 375 374 369 364 362 360 359 356 335 350 347 342 340 338 337 333 330 329 326 321 320 319 316 311 306 301 297 292 287 286 281 278 273 269 266 261 257 256 255 253 252 250 245 244 242 240 238 235 230 225 220 216 214 211 209 208 206 203 198 196 194 192 190 185 182 177 173\r\n", "output": ["NO"]}, {"input": "100\r\n360 362 367 369 374 377 382 386 389 391 396 398 399 400 405 410 413 416 419 420 423 428 525 436 441 444 445 447 451 453 457 459 463 468 468 468 468 468 468 468 468 468 468 468 468 468 468 468 468 468 468 468 468 468 468 468 465 460 455 453 448 446 443 440 436 435 430 425 420 415 410 405 404 403 402 399 394 390 387 384 382 379 378 373 372 370 369 366 361 360 355 353 349 345 344 342 339 338 335 333\r\n", "output": ["NO"]}, {"input": "3\r\n1 2 3\r\n", "output": ["YES"]}, {"input": "3\r\n3 2 1\r\n", "output": ["YES"]}, {"input": "3\r\n1 1 2\r\n", "output": ["NO"]}, {"input": "3\r\n2 1 1\r\n", "output": ["NO"]}, {"input": "3\r\n2 1 2\r\n", "output": ["NO"]}, {"input": "3\r\n3 1 2\r\n", "output": ["NO"]}, {"input": "3\r\n1 3 2\r\n", "output": ["YES"]}, {"input": "100\r\n395 399 402 403 405 408 413 415 419 424 426 431 434 436 439 444 447 448 449 454 457 459 461 462 463 464 465 469 470 473 477 480 482 484 485 487 492 494 496 497 501 504 505 508 511 506 505 503 500 499 494 490 488 486 484 481 479 474 472 471 470 465 462 458 453 452 448 445 440 436 433 430 428 426 424 421 419 414 413 408 404 403 399 395 393 388 384 379 377 375 374 372 367 363 360 356 353 351 350 346\r\n", "output": ["YES"]}, {"input": "100\r\n263 268 273 274 276 281 282 287 288 292 294 295 296 300 304 306 308 310 311 315 319 322 326 330 333 336 339 341 342 347 351 353 356 358 363 365 369 372 374 379 383 387 389 391 392 395 396 398 403 404 407 411 412 416 419 421 424 428 429 430 434 436 440 443 444 448 453 455 458 462 463 464 469 473 477 481 486 489 492 494 499 503 506 509 510 512 514 515 511 510 507 502 499 498 494 491 486 482 477 475\r\n", "output": ["YES"]}, {"input": "100\r\n482 484 485 489 492 496 499 501 505 509 512 517 520 517 515 513 509 508 504 503 498 496 493 488 486 481 478 476 474 470 468 466 463 459 456 453 452 449 445 444 439 438 435 432 428 427 424 423 421 419 417 413 408 405 402 399 397 393 388 385 380 375 370 366 363 361 360 355 354 352 349 345 340 336 335 331 329 327 324 319 318 317 315 314 310 309 307 304 303 300 299 295 291 287 285 282 280 278 273 271\r\n", "output": ["YES"]}, {"input": "100\r\n395 399 402 403 405 408 413 415 419 424 426 431 434 436 439 444 447 448 449 454 457 459 461 462 463 464 465 469 470 473 477 480 482 484 485 487 492 494 496 32 501 504 505 508 511 506 505 503 500 499 494 490 488 486 484 481 479 474 472 471 470 465 462 458 453 452 448 445 440 436 433 430 428 426 424 421 419 414 413 408 404 403 399 395 393 388 384 379 377 375 374 372 367 363 360 356 353 351 350 346\r\n", "output": ["NO"]}, {"input": "100\r\n263 268 273 274 276 281 282 287 288 292 294 295 296 300 304 306 308 310 311 315 319 322 326 330 247 336 339 341 342 347 351 353 356 358 363 365 369 372 374 379 383 387 389 391 392 395 396 398 403 404 407 411 412 416 419 421 424 428 429 430 434 436 440 443 444 448 453 455 458 462 463 464 469 473 477 481 486 489 492 494 499 503 506 509 510 512 514 515 511 510 507 502 499 498 494 491 486 482 477 475\r\n", "output": ["NO"]}, {"input": "100\r\n482 484 485 489 492 496 499 501 505 509 512 517 520 517 515 513 509 508 504 503 497 496 493 488 486 481 478 476 474 470 468 466 463 459 456 453 452 449 445 444 439 438 435 432 428 427 424 423 421 419 417 413 408 405 402 399 397 393 388 385 380 375 370 366 363 361 360 355 354 352 349 345 340 336 335 331 329 327 324 319 318 317 315 314 310 309 307 304 303 300 299 295 291 287 285 282 280 278 273 271\r\n", "output": ["YES"]}, {"input": "2\r\n1 3\r\n", "output": ["YES"]}, {"input": "2\r\n1 2\r\n", "output": ["YES"]}, {"input": "5\r\n2 2 1 1 1\r\n", "output": ["NO"]}, {"input": "4\r\n1 3 2 2\r\n", "output": ["NO"]}, {"input": "6\r\n1 2 1 2 2 1\r\n", "output": ["NO"]}, {"input": "2\r\n4 2\r\n", "output": ["YES"]}, {"input": "3\r\n3 2 2\r\n", "output": ["NO"]}, {"input": "9\r\n1 2 2 3 3 4 3 2 1\r\n", "output": ["NO"]}, {"input": "4\r\n5 5 4 4\r\n", "output": ["NO"]}, {"input": "2\r\n2 1\r\n", "output": ["YES"]}, {"input": "5\r\n5 4 3 2 1\r\n", "output": ["YES"]}, {"input": "7\r\n4 3 3 3 3 3 3\r\n", "output": ["NO"]}, {"input": "5\r\n1 2 3 4 5\r\n", "output": ["YES"]}, {"input": "3\r\n2 2 1\r\n", "output": ["YES"]}, {"input": "3\r\n4 3 3\r\n", "output": ["NO"]}, {"input": "7\r\n1 5 5 4 3 3 1\r\n", "output": ["NO"]}, {"input": "6\r\n3 3 1 2 2 1\r\n", "output": ["NO"]}, {"input": "5\r\n1 2 1 2 1\r\n", "output": ["NO"]}, {"input": "2\r\n5 1\r\n", "output": ["YES"]}, {"input": "9\r\n1 2 3 4 4 3 2 2 1\r\n", "output": ["NO"]}, {"input": "3\r\n2 2 3\r\n", "output": ["NO"]}, {"input": "2\r\n5 4\r\n", "output": ["YES"]}, {"input": "5\r\n1 3 3 2 2\r\n", "output": ["NO"]}, {"input": "10\r\n1 2 3 4 5 6 7 8 9 99\r\n", "output": ["YES"]}, {"input": "4\r\n1 2 3 4\r\n", "output": ["YES"]}, {"input": "3\r\n5 5 2\r\n", "output": ["YES"]}, {"input": "4\r\n1 4 2 3\r\n", "output": ["NO"]}, {"input": "2\r\n3 2\r\n", "output": ["YES"]}, {"input": "5\r\n1 2 2 1 1\r\n", "output": ["NO"]}, {"input": "4\r\n3 3 2 2\r\n", "output": ["NO"]}, {"input": "5\r\n1 2 3 2 2\r\n", "output": ["NO"]}, {"input": "5\r\n5 6 6 5 5\r\n", "output": ["NO"]}, {"input": "4\r\n2 2 1 1\r\n", "output": ["NO"]}, {"input": "5\r\n5 4 3 3 2\r\n", "output": ["NO"]}, {"input": "7\r\n1 3 3 3 2 1 1\r\n", "output": ["NO"]}, {"input": "9\r\n5 6 6 5 5 4 4 3 3\r\n", "output": ["NO"]}, {"input": "6\r\n1 5 5 3 2 2\r\n", "output": ["NO"]}, {"input": "5\r\n2 1 3 3 1\r\n", "output": ["NO"]}, {"input": "2\r\n4 3\r\n", "output": ["YES"]}, {"input": "5\r\n3 2 2 1 1\r\n", "output": ["NO"]}, {"input": "4\r\n5 4 3 2\r\n", "output": ["YES"]}, {"input": "4\r\n4 4 1 1\r\n", "output": ["NO"]}, {"input": "4\r\n3 3 1 1\r\n", "output": ["NO"]}, {"input": "4\r\n4 4 2 2\r\n", "output": ["NO"]}, {"input": "5\r\n4 4 3 2 2\r\n", "output": ["NO"]}, {"input": "8\r\n4 4 4 4 5 6 7 8\r\n", "output": ["NO"]}, {"input": "5\r\n3 5 4 4 3\r\n", "output": ["NO"]}, {"input": "6\r\n2 5 3 3 2 2\r\n", "output": ["NO"]}, {"input": "4\r\n5 5 2 2\r\n", "output": ["NO"]}, {"input": "5\r\n1 2 2 3 5\r\n", "output": ["NO"]}]
100
100
100
[{'input': '4\r\n3 3 2 2\r\n', 'output': ['NO']}, {'input': '5\r\n1 2 1 2 1\r\n', 'output': ['NO']}, {'input': '4\r\n5 4 3 2\r\n', 'output': ['YES']}, {'input': '100\r\n191 196 201 202 207 212 216 219 220 222 224 227 230 231 234 235 238 242 246 250 253 254 259 260 263 267 269 272 277 280 284 287 288 290 295 297 300 305 307 312 316 320 324 326 327 332 333 334 338 343 347 351 356 358 119 368 370 374 375 380 381 386 390 391 394 396 397 399 402 403 405 410 414 419 422 427 429 433 437 442 443 447 448 451 455 459 461 462 464 468 473 478 481 484 485 488 492 494 496 496\r\n', 'output': ['NO']}, {'input': '2\r\n1 3\r\n', 'output': ['YES']}]
[{'input': '3\r\n2 1 2\r\n', 'output': ['NO']}, {'input': '2\r\n5 4\r\n', 'output': ['YES']}, {'input': '3\r\n4 3 3\r\n', 'output': ['NO']}, {'input': '8\r\n4 4 4 4 5 6 7 8\r\n', 'output': ['NO']}, {'input': '100\r\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1\r\n', 'output': ['YES']}]
[{'input': '4\r\n2 2 1 1\r\n', 'output': ['NO']}, {'input': '5\r\n1 2 3 2 2\r\n', 'output': ['NO']}, {'input': '6\r\n3 3 1 2 2 1\r\n', 'output': ['NO']}, {'input': '2\r\n4 2\r\n', 'output': ['YES']}, {'input': '3\r\n4 3 3\r\n', 'output': ['NO']}]
[{'input': '4\r\n3 3 1 1\r\n', 'output': ['NO']}, {'input': '70\r\n290 292 294 297 299 300 303 305 310 312 313 315 319 320 325 327 328 333 337 339 340 341 345 350 351 354 359 364 367 372 374 379 381 382 383 384 389 393 395 397 398 400 402 405 409 411 416 417 422 424 429 430 434 435 440 442 445 449 451 453 458 460 465 470 474 477 482 482 482 479\r\n', 'output': ['YES']}, {'input': '5\r\n502 503 508 508 507\r\n', 'output': ['YES']}, {'input': '100\r\n482 484 485 489 492 496 499 501 505 509 512 517 520 517 515 513 509 508 504 503 497 496 493 488 486 481 478 476 474 470 468 466 463 459 456 453 452 449 445 444 439 438 435 432 428 427 424 423 421 419 417 413 408 405 402 399 397 393 388 385 380 375 370 366 363 361 360 355 354 352 349 345 340 336 335 331 329 327 324 319 318 317 315 314 310 309 307 304 303 300 299 295 291 287 285 282 280 278 273 271\r\n', 'output': ['YES']}, {'input': '6\r\n1 5 5 3 2 2\r\n', 'output': ['NO']}]
[{'input': '2\r\n2 1\r\n', 'output': ['YES']}, {'input': '100\r\n395 399 402 403 405 408 413 415 419 424 426 431 434 436 439 444 447 448 449 454 457 459 461 462 463 464 465 469 470 473 477 480 482 484 485 487 492 494 496 32 501 504 505 508 511 506 505 503 500 499 494 490 488 486 484 481 479 474 472 471 470 465 462 458 453 452 448 445 440 436 433 430 428 426 424 421 419 414 413 408 404 403 399 395 393 388 384 379 377 375 374 372 367 363 360 356 353 351 350 346\r\n', 'output': ['NO']}, {'input': '3\r\n2 2 3\r\n', 'output': ['NO']}, {'input': '3\r\n4 4 2\r\n', 'output': ['YES']}, {'input': '100\r\n191 196 201 202 207 212 216 219 220 222 224 227 230 231 234 235 238 242 246 250 253 254 259 260 263 267 269 272 277 280 284 287 288 290 295 297 300 305 307 312 316 320 324 326 327 332 333 334 338 343 347 351 356 358 363 368 370 374 375 380 381 386 390 391 394 396 397 399 402 403 405 410 414 419 422 427 429 433 437 442 443 447 448 451 455 459 461 462 464 468 473 478 481 484 485 488 492 494 496 496\r\n', 'output': ['YES']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
106
100
100
100
["1\n0 0 0 0 0 0 0 0 0 1", "2\n1 1 0 0 0 0 0 0 0 0", "3\n1 1 0 0 0 0 0 0 0 0"]
The first line contains integer n (1 ≤ n ≤ 100). The next line contains 10 integers a[0], a[1], ..., a[9] (0 ≤ a[i] ≤ 100) — elements of array a. The numbers are separated by spaces.
c1b5169a5c3b1bd4a2f1df1069ee7755
//#include<fstream> #include <vector> #include <iostream> using namespace std; int n,i,j,a[11],m=1e9+7,ans=0; long long c[211][211],F[211][11]; int f(int n, int t) { if (t==9) return 1; if (F[n][t]!=-1) return F[n][t]; int s=0,i; long long ans1=0; for(i=t;i<10;i++) s+=a[i]; for(i=a[t];i+s-a[t]<=n;i++) if (t==0) ans1+=(c[n-1][i]*f(n-i,t+1))%m; else ans1+=(c[n][i]*f(n-i,t+1))%m; ans1%=m; F[n][t]=ans1; return ans1; } int main () { cin>>n; int dn=n; for(i=0;i<10;i++) { cin>>a[i]; dn-=a[i]; } for(i=0;i<=100;i++) { c[i][0]=1; c[i][i]=1; for(j=1;j<i;j++) c[i][j]=(c[i-1][j-1]+c[i-1][j])%m; } for(i=0;i<=n;i++) for(j=0;j<10;j++) F[i][j]=-1; for(i=1;i<=n;i++) ans=(ans+f(i,0))%m; cout<<ans; return 0; }
["1", "1", "36"]
C++
NoteIn the first sample number 9 meets the requirements.In the second sample number 10 meets the requirements.In the third sample numbers 10, 110, 210, 120, 103 meet the requirements. There are other suitable numbers, 36 in total.
On a single line print the remainder of dividing the answer to the problem by 1000000007 (109 + 7).
Furik loves writing all sorts of problems, especially such that he can't solve himself. You've got one of his problems, the one Furik gave to Rubik. And Rubik asks you to solve it.There is integer n and array a, consisting of ten integers, indexed by numbers from 0 to 9. Your task is to count the number of positive integers with the following properties: the number's length does not exceed n; the number doesn't have leading zeroes; digit i (0 ≤ i ≤ 9) occurs in the number at least a[i] times.
[{"input": "1\r\n0 0 0 0 0 0 0 0 0 1\r\n", "output": ["1"]}, {"input": "2\r\n1 1 0 0 0 0 0 0 0 0\r\n", "output": ["1"]}, {"input": "3\r\n1 1 0 0 0 0 0 0 0 0\r\n", "output": ["36"]}, {"input": "4\r\n0 1 0 1 2 0 0 0 0 0\r\n", "output": ["12"]}, {"input": "5\r\n2 1 2 0 0 0 0 0 0 0\r\n", "output": ["18"]}, {"input": "6\r\n1 1 0 1 2 1 0 0 0 0\r\n", "output": ["300"]}, {"input": "7\r\n0 0 2 2 1 0 1 0 0 0\r\n", "output": ["9660"]}, {"input": "8\r\n1 0 1 0 1 1 2 2 0 0\r\n", "output": ["8820"]}, {"input": "9\r\n1 1 1 2 1 0 0 2 0 1\r\n", "output": ["80640"]}, {"input": "10\r\n2 0 0 1 0 2 0 1 1 0\r\n", "output": ["46501116"]}, {"input": "100\r\n10 11 14 16 12 17 10 10 0 0\r\n", "output": ["5806772"]}, {"input": "100\r\n0 0 0 0 0 0 0 0 0 0\r\n", "output": ["226732709"]}, {"input": "100\r\n12 7 8 5 17 1 19 5 7 9\r\n", "output": ["72317872"]}, {"input": "100\r\n15 16 10 9 11 7 18 14 0 0\r\n", "output": ["657295203"]}, {"input": "100\r\n1 12 0 7 16 19 15 2 17 11\r\n", "output": ["94324764"]}, {"input": "100\r\n19 9 15 16 9 10 15 7 0 0\r\n", "output": ["965593411"]}, {"input": "100\r\n12 11 2 10 18 15 10 2 8 9\r\n", "output": ["2861328"]}, {"input": "100\r\n5 3 15 14 9 4 11 2 0 6\r\n", "output": ["20742041"]}, {"input": "100\r\n12 2 12 4 12 7 18 18 13 2\r\n", "output": ["213099632"]}, {"input": "100\r\n7 12 8 18 13 1 1 19 13 8\r\n", "output": ["570613710"]}, {"input": "100\r\n13 3 4 7 2 15 6 12 7 6\r\n", "output": ["765010290"]}, {"input": "100\r\n0 45 0 0 0 0 0 55 0 0\r\n", "output": ["742404204"]}, {"input": "100\r\n9 0 3 23 0 0 0 0 0 65\r\n", "output": ["417270431"]}, {"input": "100\r\n0 0 19 0 0 0 27 0 0 54\r\n", "output": ["697702662"]}, {"input": "100\r\n0 0 68 0 18 14 0 0 0 0\r\n", "output": ["31893604"]}, {"input": "100\r\n0 34 12 0 16 0 0 0 38 0\r\n", "output": ["425145859"]}, {"input": "100\r\n0 45 29 0 0 4 0 0 0 22\r\n", "output": ["53914825"]}, {"input": "100\r\n32 0 0 0 0 0 0 67 1 0\r\n", "output": ["916165184"]}, {"input": "100\r\n58 0 0 0 0 0 40 2 0 0\r\n", "output": ["61389954"]}, {"input": "100\r\n0 27 0 0 0 0 0 0 73 0\r\n", "output": ["739250810"]}, {"input": "100\r\n0 0 40 0 0 0 0 0 60 0\r\n", "output": ["213157642"]}, {"input": "100\r\n0 24 0 0 0 29 25 22 0 0\r\n", "output": ["830465544"]}, {"input": "100\r\n4 0 1 15 20 0 0 34 0 26\r\n", "output": ["873619937"]}, {"input": "100\r\n30 0 8 19 0 1 11 0 0 31\r\n", "output": ["428927538"]}, {"input": "100\r\n31 0 27 15 7 9 5 0 0 6\r\n", "output": ["338317227"]}, {"input": "100\r\n1 14 5 6 7 27 13 0 27 0\r\n", "output": ["636666417"]}, {"input": "100\r\n5 18 12 0 0 2 15 0 8 40\r\n", "output": ["280146328"]}, {"input": "100\r\n13 34 0 0 0 0 19 27 1 6\r\n", "output": ["989464034"]}, {"input": "100\r\n24 0 0 0 0 36 16 24 0 0\r\n", "output": ["386276754"]}, {"input": "100\r\n0 27 0 0 0 0 22 21 30 0\r\n", "output": ["362638820"]}, {"input": "100\r\n0 2 23 27 0 23 0 0 24 1\r\n", "output": ["974134889"]}, {"input": "100\r\n6 6 7 5 9 8 9 6 7 9\r\n", "output": ["896625890"]}, {"input": "100\r\n17 18 19 13 26 22 26 17 19 26\r\n", "output": ["0"]}, {"input": "100\r\n3 24 1 12 29 27 27 25 5 20\r\n", "output": ["0"]}, {"input": "100\r\n23 18 6 14 10 7 8 5 1 24\r\n", "output": ["0"]}, {"input": "100\r\n23 10 21 11 6 7 10 19 11 4\r\n", "output": ["0"]}, {"input": "100\r\n5 18 12 5 28 2 15 20 12 40\r\n", "output": ["0"]}, {"input": "100\r\n13 34 34 12 11 29 26 27 1 6\r\n", "output": ["0"]}, {"input": "100\r\n24 9 23 26 28 36 16 24 39 36\r\n", "output": ["0"]}, {"input": "100\r\n16 27 26 10 17 39 22 21 30 25\r\n", "output": ["0"]}, {"input": "100\r\n18 2 23 27 9 23 27 13 24 39\r\n", "output": ["0"]}, {"input": "100\r\n100 100 100 100 100 100 100 100 100 100\r\n", "output": ["0"]}, {"input": "55\r\n100 100 100 100 100 100 100 100 100 100\r\n", "output": ["0"]}, {"input": "82\r\n100 100 100 100 100 100 100 100 100 100\r\n", "output": ["0"]}, {"input": "80\r\n100 100 100 100 100 100 100 100 100 100\r\n", "output": ["0"]}, {"input": "74\r\n100 100 100 100 100 100 100 100 100 100\r\n", "output": ["0"]}, {"input": "70\r\n100 100 100 100 100 100 100 100 100 100\r\n", "output": ["0"]}, {"input": "96\r\n100 100 100 100 100 100 100 100 100 100\r\n", "output": ["0"]}, {"input": "14\r\n100 100 100 100 100 100 100 100 100 100\r\n", "output": ["0"]}, {"input": "46\r\n100 100 100 100 100 100 100 100 100 100\r\n", "output": ["0"]}, {"input": "57\r\n100 100 100 100 100 100 100 100 100 100\r\n", "output": ["0"]}, {"input": "100\r\n100 0 0 0 0 0 0 0 0 0\r\n", "output": ["0"]}, {"input": "100\r\n0 100 0 0 0 0 0 0 0 0\r\n", "output": ["1"]}, {"input": "100\r\n0 0 100 0 0 0 0 0 0 0\r\n", "output": ["1"]}, {"input": "100\r\n0 0 0 0 0 100 0 0 0 0\r\n", "output": ["1"]}, {"input": "100\r\n0 0 0 0 0 0 100 0 0 0\r\n", "output": ["1"]}, {"input": "100\r\n0 0 0 0 0 0 0 100 0 0\r\n", "output": ["1"]}, {"input": "100\r\n0 0 0 0 0 0 0 0 100 0\r\n", "output": ["1"]}, {"input": "100\r\n0 0 0 0 0 0 0 0 0 100\r\n", "output": ["1"]}, {"input": "100\r\n50 0 0 0 0 50 0 0 0 0\r\n", "output": ["769496025"]}, {"input": "100\r\n2 2 2 3 2 3 2 3 1 2\r\n", "output": ["962893731"]}, {"input": "100\r\n2 2 2 3 2 3 2 3 1 2\r\n", "output": ["962893731"]}, {"input": "100\r\n2 1 1 1 3 0 3 1 1 1\r\n", "output": ["824639681"]}, {"input": "100\r\n3 3 2 1 2 1 3 3 0 1\r\n", "output": ["824583946"]}, {"input": "100\r\n0 2 0 1 3 3 3 0 3 3\r\n", "output": ["714175595"]}, {"input": "100\r\n3 1 3 3 1 2 3 2 0 2\r\n", "output": ["230289012"]}, {"input": "100\r\n2 2 0 2 3 3 2 0 1 1\r\n", "output": ["40065169"]}, {"input": "100\r\n1 0 3 2 1 0 2 0 0 1\r\n", "output": ["366089372"]}, {"input": "100\r\n2 0 2 0 2 1 3 3 2 1\r\n", "output": ["40065169"]}, {"input": "100\r\n1 2 1 3 2 0 0 3 2 2\r\n", "output": ["886460596"]}, {"input": "100\r\n2 0 0 1 0 3 1 2 1 1\r\n", "output": ["93799192"]}, {"input": "6\r\n1 1 1 1 1 1 0 0 0 0\r\n", "output": ["600"]}, {"input": "4\r\n0 0 1 0 1 0 0 0 1 1\r\n", "output": ["24"]}, {"input": "6\r\n0 1 0 1 1 0 0 0 1 0\r\n", "output": ["23160"]}, {"input": "4\r\n1 1 1 0 1 0 0 0 0 0\r\n", "output": ["18"]}, {"input": "5\r\n1 1 1 0 1 1 0 0 0 0\r\n", "output": ["96"]}, {"input": "6\r\n2 2 2 0 0 0 0 0 0 0\r\n", "output": ["60"]}, {"input": "4\r\n1 1 2 0 0 0 0 0 0 0\r\n", "output": ["9"]}, {"input": "77\r\n2 2 3 2 3 2 3 1 2 2\r\n", "output": ["296754123"]}, {"input": "69\r\n1 1 3 0 3 1 1 1 3 3\r\n", "output": ["441116461"]}, {"input": "76\r\n1 2 1 3 3 0 1 0 2 0\r\n", "output": ["434673284"]}]
100
100
100
[{'input': '100\r\n0 0 68 0 18 14 0 0 0 0\r\n', 'output': ['31893604']}, {'input': '10\r\n2 0 0 1 0 2 0 1 1 0\r\n', 'output': ['46501116']}, {'input': '100\r\n0 100 0 0 0 0 0 0 0 0\r\n', 'output': ['1']}, {'input': '100\r\n2 2 2 3 2 3 2 3 1 2\r\n', 'output': ['962893731']}, {'input': '100\r\n5 18 12 0 0 2 15 0 8 40\r\n', 'output': ['280146328']}]
[{'input': '6\r\n1 1 1 1 1 1 0 0 0 0\r\n', 'output': ['600']}, {'input': '100\r\n5 18 12 5 28 2 15 20 12 40\r\n', 'output': ['0']}, {'input': '6\r\n0 1 0 1 1 0 0 0 1 0\r\n', 'output': ['23160']}, {'input': '100\r\n3 1 3 3 1 2 3 2 0 2\r\n', 'output': ['230289012']}, {'input': '8\r\n1 0 1 0 1 1 2 2 0 0\r\n', 'output': ['8820']}]
[{'input': '100\r\n31 0 27 15 7 9 5 0 0 6\r\n', 'output': ['338317227']}, {'input': '100\r\n1 2 1 3 2 0 0 3 2 2\r\n', 'output': ['886460596']}, {'input': '76\r\n1 2 1 3 3 0 1 0 2 0\r\n', 'output': ['434673284']}, {'input': '14\r\n100 100 100 100 100 100 100 100 100 100\r\n', 'output': ['0']}, {'input': '100\r\n0 0 0 0 0 0 0 0 100 0\r\n', 'output': ['1']}]
[{'input': '100\r\n9 0 3 23 0 0 0 0 0 65\r\n', 'output': ['417270431']}, {'input': '10\r\n2 0 0 1 0 2 0 1 1 0\r\n', 'output': ['46501116']}, {'input': '8\r\n1 0 1 0 1 1 2 2 0 0\r\n', 'output': ['8820']}, {'input': '100\r\n15 16 10 9 11 7 18 14 0 0\r\n', 'output': ['657295203']}, {'input': '100\r\n50 0 0 0 0 50 0 0 0 0\r\n', 'output': ['769496025']}]
[{'input': '100\r\n0 2 23 27 0 23 0 0 24 1\r\n', 'output': ['974134889']}, {'input': '100\r\n50 0 0 0 0 50 0 0 0 0\r\n', 'output': ['769496025']}, {'input': '4\r\n0 0 1 0 1 0 0 0 1 1\r\n', 'output': ['24']}, {'input': '6\r\n2 2 2 0 0 0 0 0 0 0\r\n', 'output': ['60']}, {'input': '46\r\n100 100 100 100 100 100 100 100 100 100\r\n', 'output': ['0']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
95.45
107
100
100
99.09
["100", "48", "521"]
The first line contains the positive integer x (1 ≤ x ≤ 1018) — the integer which Anton has.
e55b0debbf33c266091e6634494356b8
#include <stdio.h> #include <string.h> #include <iostream> #include <string> using namespace std; char s[32768]; char ans[32768]; int main() { ios_base::sync_with_stdio(0); cin.getline(s, sizeof(s)); int n = (int)strlen(s); int def = 0; for (int i = 0; i < n; i++) def += (int)(s[i] - '0'); int ret = def; strcpy(ans, s); // for (int i = n - 1; i >= 0; i--) { int cnt = 0; if (s[i] != '0') { cnt = def - 1; for (int j = i + 1; j < n; j++) { cnt += (int)('9' - s[j]); } } if (cnt > ret) { ret = cnt; ans[i] = s[i] - 1; for (int j = i + 1; j < n; j++) { ans[j] = '9'; } } } int from = 0; while (ans[from] == '0') from++; cout << (ans + from) << "\n"; // return 0; }
["99", "48", "499"]
C++
null
Print the positive integer which doesn't exceed x and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros.
Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits.Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them.
[{"input": "100\r\n", "output": ["99"]}, {"input": "48\r\n", "output": ["48"]}, {"input": "521\r\n", "output": ["499"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "2\r\n", "output": ["2"]}, {"input": "3\r\n", "output": ["3"]}, {"input": "39188\r\n", "output": ["38999"]}, {"input": "5\r\n", "output": ["5"]}, {"input": "6\r\n", "output": ["6"]}, {"input": "7\r\n", "output": ["7"]}, {"input": "8\r\n", "output": ["8"]}, {"input": "9\r\n", "output": ["9"]}, {"input": "10\r\n", "output": ["9"]}, {"input": "59999154\r\n", "output": ["59998999"]}, {"input": "1000\r\n", "output": ["999"]}, {"input": "10000\r\n", "output": ["9999"]}, {"input": "100000\r\n", "output": ["99999"]}, {"input": "1000000\r\n", "output": ["999999"]}, {"input": "10000000\r\n", "output": ["9999999"]}, {"input": "100000000\r\n", "output": ["99999999"]}, {"input": "1000000000\r\n", "output": ["999999999"]}, {"input": "10000000000\r\n", "output": ["9999999999"]}, {"input": "100000000000\r\n", "output": ["99999999999"]}, {"input": "1000000000000\r\n", "output": ["999999999999"]}, {"input": "10000000000000\r\n", "output": ["9999999999999"]}, {"input": "100000000000000\r\n", "output": ["99999999999999"]}, {"input": "1000000000000000\r\n", "output": ["999999999999999"]}, {"input": "10000000000000000\r\n", "output": ["9999999999999999"]}, {"input": "100000000000000000\r\n", "output": ["99999999999999999"]}, {"input": "1000000000000000000\r\n", "output": ["999999999999999999"]}, {"input": "999999990\r\n", "output": ["999999989"]}, {"input": "666666899789879\r\n", "output": ["599999999999999"]}, {"input": "65499992294999000\r\n", "output": ["59999999999999999"]}, {"input": "9879100000000099\r\n", "output": ["8999999999999999"]}, {"input": "9991919190909919\r\n", "output": ["9989999999999999"]}, {"input": "978916546899999999\r\n", "output": ["899999999999999999"]}, {"input": "5684945999999999\r\n", "output": ["4999999999999999"]}, {"input": "999999999999999999\r\n", "output": ["999999999999999999"]}, {"input": "999999999999990999\r\n", "output": ["999999999999989999"]}, {"input": "999999999999999990\r\n", "output": ["999999999999999989"]}, {"input": "909999999999999999\r\n", "output": ["899999999999999999"]}, {"input": "199999999999999999\r\n", "output": ["199999999999999999"]}, {"input": "299999999999999999\r\n", "output": ["299999999999999999"]}, {"input": "999999990009999999\r\n", "output": ["999999989999999999"]}, {"input": "999000000001999999\r\n", "output": ["998999999999999999"]}, {"input": "999999999991\r\n", "output": ["999999999989"]}, {"input": "999999999992\r\n", "output": ["999999999989"]}, {"input": "79320\r\n", "output": ["78999"]}, {"input": "99004\r\n", "output": ["98999"]}, {"input": "99088\r\n", "output": ["98999"]}, {"input": "99737\r\n", "output": ["98999"]}, {"input": "29652\r\n", "output": ["28999"]}, {"input": "59195\r\n", "output": ["58999"]}, {"input": "19930\r\n", "output": ["19899"]}, {"input": "49533\r\n", "output": ["48999"]}, {"input": "69291\r\n", "output": ["68999"]}, {"input": "59452\r\n", "output": ["58999"]}, {"input": "11\r\n", "output": ["9"]}, {"input": "110\r\n", "output": ["99"]}, {"input": "111\r\n", "output": ["99"]}, {"input": "119\r\n", "output": ["99"]}, {"input": "118\r\n", "output": ["99"]}, {"input": "1100\r\n", "output": ["999"]}, {"input": "1199\r\n", "output": ["999"]}, {"input": "1109\r\n", "output": ["999"]}, {"input": "1190\r\n", "output": ["999"]}, {"input": "12\r\n", "output": ["9"]}, {"input": "120\r\n", "output": ["99"]}, {"input": "121\r\n", "output": ["99"]}, {"input": "129\r\n", "output": ["99"]}, {"input": "128\r\n", "output": ["99"]}, {"input": "1200\r\n", "output": ["999"]}, {"input": "1299\r\n", "output": ["999"]}, {"input": "1209\r\n", "output": ["999"]}, {"input": "1290\r\n", "output": ["999"]}, {"input": "13\r\n", "output": ["9"]}, {"input": "130\r\n", "output": ["99"]}, {"input": "131\r\n", "output": ["99"]}, {"input": "139\r\n", "output": ["99"]}, {"input": "138\r\n", "output": ["99"]}, {"input": "1300\r\n", "output": ["999"]}, {"input": "1399\r\n", "output": ["999"]}, {"input": "1309\r\n", "output": ["999"]}, {"input": "1390\r\n", "output": ["999"]}, {"input": "14\r\n", "output": ["9"]}, {"input": "140\r\n", "output": ["99"]}, {"input": "141\r\n", "output": ["99"]}, {"input": "149\r\n", "output": ["99"]}, {"input": "148\r\n", "output": ["99"]}, {"input": "1400\r\n", "output": ["999"]}, {"input": "1499\r\n", "output": ["999"]}, {"input": "1409\r\n", "output": ["999"]}, {"input": "1490\r\n", "output": ["999"]}, {"input": "15\r\n", "output": ["9"]}, {"input": "150\r\n", "output": ["99"]}, {"input": "151\r\n", "output": ["99"]}, {"input": "159\r\n", "output": ["99"]}, {"input": "158\r\n", "output": ["99"]}, {"input": "1500\r\n", "output": ["999"]}, {"input": "1599\r\n", "output": ["999"]}, {"input": "1509\r\n", "output": ["999"]}, {"input": "1590\r\n", "output": ["999"]}, {"input": "16\r\n", "output": ["9"]}, {"input": "160\r\n", "output": ["99"]}, {"input": "161\r\n", "output": ["99"]}, {"input": "169\r\n", "output": ["99"]}, {"input": "168\r\n", "output": ["99"]}, {"input": "1600\r\n", "output": ["999"]}, {"input": "1699\r\n", "output": ["999"]}, {"input": "1609\r\n", "output": ["999"]}, {"input": "1690\r\n", "output": ["999"]}, {"input": "17\r\n", "output": ["9"]}, {"input": "170\r\n", "output": ["99"]}, {"input": "171\r\n", "output": ["99"]}, {"input": "179\r\n", "output": ["99"]}, {"input": "178\r\n", "output": ["99"]}, {"input": "1700\r\n", "output": ["999"]}, {"input": "1799\r\n", "output": ["999"]}, {"input": "1709\r\n", "output": ["999"]}, {"input": "1790\r\n", "output": ["999"]}, {"input": "18\r\n", "output": ["18"]}, {"input": "180\r\n", "output": ["99"]}, {"input": "181\r\n", "output": ["99"]}, {"input": "189\r\n", "output": ["189"]}, {"input": "188\r\n", "output": ["99"]}, {"input": "1800\r\n", "output": ["999"]}, {"input": "1899\r\n", "output": ["1899"]}, {"input": "1809\r\n", "output": ["999"]}, {"input": "1890\r\n", "output": ["999"]}, {"input": "19\r\n", "output": ["19"]}, {"input": "190\r\n", "output": ["189"]}, {"input": "191\r\n", "output": ["189"]}, {"input": "199\r\n", "output": ["199"]}, {"input": "198\r\n", "output": ["198"]}, {"input": "1900\r\n", "output": ["1899"]}, {"input": "1999\r\n", "output": ["1999"]}, {"input": "1909\r\n", "output": ["1899"]}, {"input": "1990\r\n", "output": ["1989"]}, {"input": "20\r\n", "output": ["19"]}, {"input": "200\r\n", "output": ["199"]}, {"input": "201\r\n", "output": ["199"]}, {"input": "209\r\n", "output": ["199"]}, {"input": "208\r\n", "output": ["199"]}, {"input": "2000\r\n", "output": ["1999"]}, {"input": "2099\r\n", "output": ["1999"]}, {"input": "2009\r\n", "output": ["1999"]}, {"input": "2090\r\n", "output": ["1999"]}, {"input": "21\r\n", "output": ["19"]}, {"input": "210\r\n", "output": ["199"]}, {"input": "211\r\n", "output": ["199"]}, {"input": "219\r\n", "output": ["199"]}, {"input": "218\r\n", "output": ["199"]}, {"input": "2100\r\n", "output": ["1999"]}, {"input": "2199\r\n", "output": ["1999"]}, {"input": "2109\r\n", "output": ["1999"]}, {"input": "2190\r\n", "output": ["1999"]}, {"input": "22\r\n", "output": ["19"]}, {"input": "220\r\n", "output": ["199"]}, {"input": "221\r\n", "output": ["199"]}, {"input": "229\r\n", "output": ["199"]}, {"input": "228\r\n", "output": ["199"]}, {"input": "2200\r\n", "output": ["1999"]}, {"input": "2299\r\n", "output": ["1999"]}, {"input": "2209\r\n", "output": ["1999"]}, {"input": "2290\r\n", "output": ["1999"]}, {"input": "23\r\n", "output": ["19"]}, {"input": "230\r\n", "output": ["199"]}, {"input": "231\r\n", "output": ["199"]}, {"input": "239\r\n", "output": ["199"]}, {"input": "238\r\n", "output": ["199"]}, {"input": "2300\r\n", "output": ["1999"]}, {"input": "2399\r\n", "output": ["1999"]}, {"input": "2309\r\n", "output": ["1999"]}, {"input": "2390\r\n", "output": ["1999"]}, {"input": "24\r\n", "output": ["19"]}, {"input": "240\r\n", "output": ["199"]}, {"input": "241\r\n", "output": ["199"]}, {"input": "249\r\n", "output": ["199"]}, {"input": "248\r\n", "output": ["199"]}, {"input": "2400\r\n", "output": ["1999"]}, {"input": "2499\r\n", "output": ["1999"]}, {"input": "2409\r\n", "output": ["1999"]}, {"input": "2490\r\n", "output": ["1999"]}, {"input": "25\r\n", "output": ["19"]}, {"input": "250\r\n", "output": ["199"]}, {"input": "251\r\n", "output": ["199"]}, {"input": "259\r\n", "output": ["199"]}, {"input": "258\r\n", "output": ["199"]}, {"input": "2500\r\n", "output": ["1999"]}, {"input": "2599\r\n", "output": ["1999"]}, {"input": "2509\r\n", "output": ["1999"]}, {"input": "2590\r\n", "output": ["1999"]}, {"input": "26\r\n", "output": ["19"]}, {"input": "260\r\n", "output": ["199"]}, {"input": "261\r\n", "output": ["199"]}, {"input": "269\r\n", "output": ["199"]}, {"input": "268\r\n", "output": ["199"]}, {"input": "2600\r\n", "output": ["1999"]}, {"input": "2699\r\n", "output": ["1999"]}, {"input": "2609\r\n", "output": ["1999"]}, {"input": "2690\r\n", "output": ["1999"]}, {"input": "27\r\n", "output": ["19"]}, {"input": "270\r\n", "output": ["199"]}, {"input": "271\r\n", "output": ["199"]}, {"input": "279\r\n", "output": ["199"]}, {"input": "278\r\n", "output": ["199"]}, {"input": "2700\r\n", "output": ["1999"]}, {"input": "2799\r\n", "output": ["1999"]}, {"input": "2709\r\n", "output": ["1999"]}, {"input": "2790\r\n", "output": ["1999"]}, {"input": "28\r\n", "output": ["28"]}, {"input": "280\r\n", "output": ["199"]}, {"input": "281\r\n", "output": ["199"]}, {"input": "289\r\n", "output": ["289"]}, {"input": "288\r\n", "output": ["199"]}, {"input": "2800\r\n", "output": ["1999"]}, {"input": "2899\r\n", "output": ["2899"]}, {"input": "2809\r\n", "output": ["1999"]}, {"input": "2890\r\n", "output": ["1999"]}, {"input": "29\r\n", "output": ["29"]}, {"input": "290\r\n", "output": ["289"]}, {"input": "291\r\n", "output": ["289"]}, {"input": "299\r\n", "output": ["299"]}, {"input": "298\r\n", "output": ["298"]}, {"input": "2900\r\n", "output": ["2899"]}, {"input": "2999\r\n", "output": ["2999"]}, {"input": "2909\r\n", "output": ["2899"]}, {"input": "2990\r\n", "output": ["2989"]}, {"input": "999\r\n", "output": ["999"]}, {"input": "890\r\n", "output": ["889"]}, {"input": "995\r\n", "output": ["989"]}, {"input": "989\r\n", "output": ["989"]}, {"input": "991\r\n", "output": ["989"]}, {"input": "9929\r\n", "output": ["9899"]}, {"input": "4999\r\n", "output": ["4999"]}, {"input": "9690\r\n", "output": ["8999"]}, {"input": "8990\r\n", "output": ["8989"]}, {"input": "9982\r\n", "output": ["9899"]}, {"input": "9999\r\n", "output": ["9999"]}, {"input": "1993\r\n", "output": ["1989"]}, {"input": "9367\r\n", "output": ["8999"]}, {"input": "8939\r\n", "output": ["8899"]}, {"input": "9899\r\n", "output": ["9899"]}, {"input": "99999\r\n", "output": ["99999"]}, {"input": "93929\r\n", "output": ["89999"]}, {"input": "38579\r\n", "output": ["29999"]}, {"input": "79096\r\n", "output": ["78999"]}, {"input": "72694\r\n", "output": ["69999"]}, {"input": "99992\r\n", "output": ["99989"]}, {"input": "27998\r\n", "output": ["19999"]}, {"input": "460999\r\n", "output": ["399999"]}, {"input": "999999\r\n", "output": ["999999"]}, {"input": "998999\r\n", "output": ["998999"]}, {"input": "999929\r\n", "output": ["999899"]}, {"input": "979199\r\n", "output": ["899999"]}, {"input": "9899999\r\n", "output": ["9899999"]}, {"input": "9699959\r\n", "output": ["8999999"]}, {"input": "9999999\r\n", "output": ["9999999"]}, {"input": "9997099\r\n", "output": ["9989999"]}, {"input": "8992091\r\n", "output": ["8989999"]}, {"input": "9599295\r\n", "output": ["8999999"]}, {"input": "2999902\r\n", "output": ["2999899"]}, {"input": "9999953\r\n", "output": ["9999899"]}, {"input": "9590999\r\n", "output": ["8999999"]}]
100
100
100
[{'input': '100000000000000\r\n', 'output': ['99999999999999']}, {'input': '271\r\n', 'output': ['199']}, {'input': '2599\r\n', 'output': ['1999']}, {'input': '10000000000\r\n', 'output': ['9999999999']}, {'input': '229\r\n', 'output': ['199']}]
[{'input': '218\r\n', 'output': ['199']}, {'input': '9999\r\n', 'output': ['9999']}, {'input': '9991919190909919\r\n', 'output': ['9989999999999999']}, {'input': '1890\r\n', 'output': ['999']}, {'input': '909999999999999999\r\n', 'output': ['899999999999999999']}]
[{'input': '2490\r\n', 'output': ['1999']}, {'input': '29652\r\n', 'output': ['28999']}, {'input': '199999999999999999\r\n', 'output': ['199999999999999999']}, {'input': '9879100000000099\r\n', 'output': ['8999999999999999']}, {'input': '999\r\n', 'output': ['999']}]
[{'input': '1500\r\n', 'output': ['999']}, {'input': '1809\r\n', 'output': ['999']}, {'input': '2099\r\n', 'output': ['1999']}, {'input': '2199\r\n', 'output': ['1999']}, {'input': '1000000000000000\r\n', 'output': ['999999999999999']}]
[{'input': '1390\r\n', 'output': ['999']}, {'input': '270\r\n', 'output': ['199']}, {'input': '129\r\n', 'output': ['99']}, {'input': '200\r\n', 'output': ['199']}, {'input': '151\r\n', 'output': ['99']}]
100
100
100
100
100
100
100
100
100
100
100
100
92.86
100
100
108
100
100
98.572
["4 6", "10 1"]
The first and the only line of the input contains two distinct integers n and m (1 ≤ n, m ≤ 104), separated by a space .
861f8edd2813d6d3a5ff7193a804486f
#include<iostream> #include<cmath> #include<string> #include<cstring> #include<vector> #include<map> #include<iomanip> #include<algorithm> #include<cstdio> using namespace std; int ans,l,r; int main() { cin>>l>>r; while(l!=r) { if(l>r) { r++; } else { if(r&1)//奇数 { r++; } else { r/=2; } } ans++; } cout<<ans<<endl; }
["2", "9"]
C++
NoteIn the first example you need to push the blue button once, and then push the red button once.In the second example, doubling the number is unnecessary, so we need to push the blue button nine times.
Print a single number — the minimum number of times one needs to push the button required to get the number m out of number n.
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at some point the number stops being positive, the device breaks down. The display can show arbitrarily large numbers. Initially, the display shows number n.Bob wants to get number m on the display. What minimum number of clicks he has to make in order to achieve this result?
[{"input": "4 6\r\n", "output": ["2"]}, {"input": "10 1\r\n", "output": ["9"]}, {"input": "1 2\r\n", "output": ["1"]}, {"input": "2 1\r\n", "output": ["1"]}, {"input": "1 3\r\n", "output": ["3"]}, {"input": "3 1\r\n", "output": ["2"]}, {"input": "2 10\r\n", "output": ["5"]}, {"input": "100 99\r\n", "output": ["1"]}, {"input": "99 100\r\n", "output": ["50"]}, {"input": "10 17\r\n", "output": ["3"]}, {"input": "666 6666\r\n", "output": ["255"]}, {"input": "6666 666\r\n", "output": ["6000"]}, {"input": "1 8192\r\n", "output": ["13"]}, {"input": "1 8193\r\n", "output": ["27"]}, {"input": "9999 10000\r\n", "output": ["5000"]}, {"input": "10000 9999\r\n", "output": ["1"]}, {"input": "10000 1\r\n", "output": ["9999"]}, {"input": "1234 5678\r\n", "output": ["528"]}, {"input": "9102 9103\r\n", "output": ["4552"]}, {"input": "8192 1\r\n", "output": ["8191"]}, {"input": "9912 1023\r\n", "output": ["8889"]}, {"input": "100 500\r\n", "output": ["41"]}, {"input": "9997 9999\r\n", "output": ["4999"]}, {"input": "5000 10000\r\n", "output": ["1"]}, {"input": "4000 7997\r\n", "output": ["3"]}, {"input": "1 10000\r\n", "output": ["20"]}, {"input": "1 8191\r\n", "output": ["14"]}, {"input": "9097 9998\r\n", "output": ["4099"]}, {"input": "886 9383\r\n", "output": ["305"]}, {"input": "1 9\r\n", "output": ["7"]}, {"input": "1918 10000\r\n", "output": ["671"]}, {"input": "1 4\r\n", "output": ["2"]}, {"input": "2 10000\r\n", "output": ["19"]}, {"input": "3 10000\r\n", "output": ["17"]}, {"input": "4 10000\r\n", "output": ["18"]}, {"input": "9998 10000\r\n", "output": ["4999"]}, {"input": "5001 10000\r\n", "output": ["2"]}, {"input": "1 9999\r\n", "output": ["21"]}, {"input": "7777 9999\r\n", "output": ["2779"]}, {"input": "2 100\r\n", "output": ["9"]}, {"input": "10 8722\r\n", "output": ["18"]}, {"input": "848 4561\r\n", "output": ["283"]}, {"input": "9967 9973\r\n", "output": ["4982"]}, {"input": "5555 10000\r\n", "output": ["556"]}, {"input": "999 10000\r\n", "output": ["378"]}, {"input": "3 6\r\n", "output": ["1"]}, {"input": "9 38\r\n", "output": ["8"]}]
100
100
100
[{'input': '5001 10000\r\n', 'output': ['2']}, {'input': '1 9999\r\n', 'output': ['21']}, {'input': '10 1\r\n', 'output': ['9']}, {'input': '5555 10000\r\n', 'output': ['556']}, {'input': '4 6\r\n', 'output': ['2']}]
[{'input': '9967 9973\r\n', 'output': ['4982']}, {'input': '5000 10000\r\n', 'output': ['1']}, {'input': '7777 9999\r\n', 'output': ['2779']}, {'input': '4000 7997\r\n', 'output': ['3']}, {'input': '848 4561\r\n', 'output': ['283']}]
[{'input': '9997 9999\r\n', 'output': ['4999']}, {'input': '7777 9999\r\n', 'output': ['2779']}, {'input': '100 500\r\n', 'output': ['41']}, {'input': '6666 666\r\n', 'output': ['6000']}, {'input': '4 6\r\n', 'output': ['2']}]
[{'input': '4 6\r\n', 'output': ['2']}, {'input': '9997 9999\r\n', 'output': ['4999']}, {'input': '2 10000\r\n', 'output': ['19']}, {'input': '5000 10000\r\n', 'output': ['1']}, {'input': '10 1\r\n', 'output': ['9']}]
[{'input': '1 2\r\n', 'output': ['1']}, {'input': '3 10000\r\n', 'output': ['17']}, {'input': '2 100\r\n', 'output': ['9']}, {'input': '9912 1023\r\n', 'output': ['8889']}, {'input': '9102 9103\r\n', 'output': ['4552']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
109
100
100
100
["2 2", "4 3", "2020 2021"]
The only line contains two integers $$$n$$$, $$$m$$$ ($$$1\le n, m\le 2021$$$).
1738dc65af1fffa445cb0c3074c6bedb
#include <bits/stdc++.h> #define forn(i,s,t) for(register int i=(s);i<=(t);++i) #define form(i,s,t) for(register int i=(s);i>=(t);--i) using namespace std; const int N = 2040, Mod = 998244353; struct Mint { int res; Mint() {res = 0;} Mint(int a) : res(a) {} friend Mint operator + (Mint A, Mint B) { return Mint((A.res + B.res >= Mod) ? (A.res + B.res - Mod) : (A.res + B.res)); } friend Mint& operator += (Mint& A, Mint B) {return A = A + B;} friend Mint operator - (Mint A, Mint B) {B.res = Mod - B.res; return A + B;} friend Mint operator - (Mint A) {return Mint(Mod - A.res);} friend Mint operator + (Mint A) {return A;} friend Mint& operator -= (Mint& A, Mint B) {return A = A - B;} friend Mint operator * (Mint A, Mint B) {return 1ll * A.res * B.res %Mod;} friend Mint& operator *= (Mint& A, Mint B) {return A = A * B;} friend Mint operator ~ (Mint A) { static Mint res; res = Mint(1); static int k; k = Mod - 2; for(;k;k>>=1, A*=A) (k&1) && (res = res * A, 0); return res; } friend Mint operator / (Mint A, Mint B) {return A * (~B);} friend Mint& operator /= (Mint& A, Mint B) {return A *= (~B);} friend Mint operator >> (Mint A, Mint B) {return Mint(A.res / B.res);} friend Mint& operator >>= (Mint& A, Mint B) {return A = A>>B;} }; int n, m; Mint C[N << 1][N << 1]; inline Mint F(int n, int m) {return C[n + m][n];} int main() { scanf("%d%d", &n, &m); forn(i,0,n + m) { C[i][0] = C[i][i] = Mint(1); forn(j,1,i - 1) C[i][j] = C[i - 1][j] + C[i - 1][j - 1]; } static Mint res, sum; forn(h,1,n - 1) { sum = Mint(0); forn(i,1,m - 1) { res += sum * F(i, h - 1) * F(m - i - 1, h); sum += F(n - h, i - 1) * F(n - h - 1, m - i); } } forn(h,1,m - 1) { sum = Mint(0); forn(i,1,n - 1) { sum += F(m - h, i - 1) * F(m - h - 1, n - i); res += sum * F(i, h - 1) * F(n - i - 1, h); } } res = res * Mint(2); printf("%d\n", res.res); return 0; }// OJ:: LG
["2", "294", "50657649"]
C++
NoteIn the first test case, these are the only two stupid $$$2\times 2$$$ colorings.
Output a single integer — the number of stupid colorings modulo $$$998244353$$$.
There is a grid with $$$n$$$ rows and $$$m$$$ columns. Every cell of the grid should be colored either blue or yellow.A coloring of the grid is called stupid if every row has exactly one segment of blue cells and every column has exactly one segment of yellow cells.In other words, every row must have at least one blue cell, and all blue cells in a row must be consecutive. Similarly, every column must have at least one yellow cell, and all yellow cells in a column must be consecutive. An example of a stupid coloring. Examples of clever colorings. The first coloring is missing a blue cell in the second row, and the second coloring has two yellow segments in the second column. How many stupid colorings of the grid are there? Two colorings are considered different if there is some cell that is colored differently.
[{"input": "2 2\n", "output": ["2", "2\n", "2\n", "2 "]}, {"input": "4 3\n", "output": ["294 ", "294", "294\n", "294\n"]}, {"input": "2020 2021\n", "output": ["50657649", "50657649\n", "50657649\n"]}, {"input": "2021 2021\n", "output": ["138387540", "138387540\n", "138387540\n"]}, {"input": "2021 1\n", "output": ["0\n", "0", "0\n"]}, {"input": "1 2021\n", "output": ["0\n", "0\n", "0"]}, {"input": "1 1\n", "output": ["0\n", "0\n", "0"]}, {"input": "1 2\n", "output": ["0\n", "0\n", "0"]}, {"input": "1 3\n", "output": ["0\n", "0\n", "0"]}, {"input": "3 1\n", "output": ["0\n", "0\n", "0"]}, {"input": "17 13\n", "output": ["737338284\n", "737338284", "737338284\n"]}, {"input": "1848 1937\n", "output": ["337952422\n", "337952422\n", "337952422"]}, {"input": "2019 2018\n", "output": ["15395158", "15395158\n", "15395158\n"]}, {"input": "10 19\n", "output": ["272254938", "272254938\n", "272254938\n"]}, {"input": "2021 2\n", "output": ["44330628\n", "44330628", "44330628\n"]}, {"input": "2021 3\n", "output": ["435157523\n", "435157523", "435157523\n"]}, {"input": "4 2021\n", "output": ["102125833\n", "102125833", "102125833\n"]}, {"input": "5 2021\n", "output": ["2872985", "2872985\n", "2872985\n"]}, {"input": "2000 2000\n", "output": ["111024599", "111024599\n", "111024599\n"]}, {"input": "101 100\n", "output": ["137902766\n", "137902766", "137902766\n"]}, {"input": "104 328\n", "output": ["726939953\n", "726939953", "726939953\n"]}, {"input": "101 101\n", "output": ["601990061", "601990061\n", "601990061\n"]}, {"input": "598 319\n", "output": ["420237100\n", "420237100\n", "420237100"]}, {"input": "1 4\n", "output": ["0\n", "0", "0\n"]}, {"input": "1 5\n", "output": ["0\n", "0", "0\n"]}, {"input": "2 1\n", "output": ["0\n", "0", "0\n"]}, {"input": "2 3\n", "output": ["10\n", "10", "10\n"]}, {"input": "2 4\n", "output": ["30\n", "30\n", "30"]}, {"input": "2 5\n", "output": ["70\n", "70\n", "70"]}, {"input": "1000 1000\n", "output": ["72199042", "72199042\n", "72199042\n"]}, {"input": "999 2013\n", "output": ["879862853\n", "879862853\n", "879862853"]}, {"input": "3 2\n", "output": ["10\n", "10", "10\n"]}, {"input": "3 3\n", "output": ["72\n", "72\n", "72"]}, {"input": "3 4\n", "output": ["294", "294\n", "294\n"]}, {"input": "3 5\n", "output": ["896\n", "896\n", "896"]}, {"input": "4 1\n", "output": ["0\n", "0", "0\n"]}, {"input": "4 2\n", "output": ["30\n", "30\n", "30"]}, {"input": "1453 938\n", "output": ["379270595\n", "379270595", "379270595\n"]}, {"input": "4 4\n", "output": ["1570\n", "1570\n", "1570"]}, {"input": "4 5\n", "output": ["6066", "6066\n", "6066\n"]}, {"input": "5 1\n", "output": ["0\n", "0", "0\n"]}, {"input": "5 2\n", "output": ["70\n", "70\n", "70"]}, {"input": "5 3\n", "output": ["896\n", "896\n", "896"]}, {"input": "5 4\n", "output": ["6066", "6066\n", "6066\n"]}, {"input": "5 5\n", "output": ["29000\n", "29000", "29000\n"]}, {"input": "6 6\n", "output": ["498764\n", "498764\n", "498764"]}, {"input": "7 7\n", "output": ["8281392\n", "8281392\n", "8281392"]}, {"input": "8 8\n", "output": ["134909730\n", "134909730", "134909730\n"]}, {"input": "9 9\n", "output": ["177198854\n", "177198854", "177198854\n"]}, {"input": "10 10\n", "output": ["848269250\n", "848269250\n", "848269250"]}]
100
100
100
[{'input': '4 2\n', 'output': ['30\n', '30\n', '30']}, {'input': '4 3\n', 'output': ['294 ', '294', '294\n', '294\n']}, {'input': '104 328\n', 'output': ['726939953\n', '726939953', '726939953\n']}, {'input': '10 19\n', 'output': ['272254938', '272254938\n', '272254938\n']}, {'input': '1 5\n', 'output': ['0\n', '0', '0\n']}]
[{'input': '5 5\n', 'output': ['29000\n', '29000', '29000\n']}, {'input': '7 7\n', 'output': ['8281392\n', '8281392\n', '8281392']}, {'input': '3 2\n', 'output': ['10\n', '10', '10\n']}, {'input': '5 1\n', 'output': ['0\n', '0', '0\n']}, {'input': '9 9\n', 'output': ['177198854\n', '177198854', '177198854\n']}]
[{'input': '4 5\n', 'output': ['6066', '6066\n', '6066\n']}, {'input': '1 5\n', 'output': ['0\n', '0', '0\n']}, {'input': '6 6\n', 'output': ['498764\n', '498764\n', '498764']}, {'input': '2020 2021\n', 'output': ['50657649', '50657649\n', '50657649\n']}, {'input': '2 5\n', 'output': ['70\n', '70\n', '70']}]
[{'input': '9 9\n', 'output': ['177198854\n', '177198854', '177198854\n']}, {'input': '4 2021\n', 'output': ['102125833\n', '102125833', '102125833\n']}, {'input': '4 1\n', 'output': ['0\n', '0', '0\n']}, {'input': '101 101\n', 'output': ['601990061', '601990061\n', '601990061\n']}, {'input': '4 5\n', 'output': ['6066', '6066\n', '6066\n']}]
[{'input': '598 319\n', 'output': ['420237100\n', '420237100\n', '420237100']}, {'input': '2 5\n', 'output': ['70\n', '70\n', '70']}, {'input': '5 3\n', 'output': ['896\n', '896\n', '896']}, {'input': '1 5\n', 'output': ['0\n', '0', '0\n']}, {'input': '3 1\n', 'output': ['0\n', '0\n', '0']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
110
100
100
100
["3 222", "4 190", "7 1"]
The only line of the input contains two integers n and k (1 ≤ n ≤ 10, 1 ≤ k ≤ 240) — the number of the problems in the contest and the number of minutes Limak needs to get to the party from his house.
41e554bc323857be7b8483ee358a35e2
#include <bits/stdc++.h> using namespace std; long n, k, m, kq=0; int main() { cin>>n>>k; m=240-k; for(int i=1;i<=n;i++) { if(m-(i*5)>=0) kq++; else break; m-= i*5; } cout<<kq; }
["2", "4", "7"]
C++
NoteIn the first sample, there are 3 problems and Limak needs 222 minutes to get to the party. The three problems require 5, 10 and 15 minutes respectively. Limak can spend 5 + 10 = 15 minutes to solve first two problems. Then, at 20:15 he can leave his house to get to the party at 23:57 (after 222 minutes). In this scenario Limak would solve 2 problems. He doesn't have enough time to solve 3 problems so the answer is 2.In the second sample, Limak can solve all 4 problems in 5 + 10 + 15 + 20 = 50 minutes. At 20:50 he will leave the house and go to the party. He will get there exactly at midnight.In the third sample, Limak needs only 1 minute to get to the party. He has enough time to solve all 7 problems.
Print one integer, denoting the maximum possible number of problems Limak can solve so that he could get to the party at midnight or earlier.
Limak is going to participate in a contest on the last day of the 2016. The contest will start at 20:00 and will last four hours, exactly until midnight. There will be n problems, sorted by difficulty, i.e. problem 1 is the easiest and problem n is the hardest. Limak knows it will take him 5·i minutes to solve the i-th problem.Limak's friends organize a New Year's Eve party and Limak wants to be there at midnight or earlier. He needs k minutes to get there from his house, where he will participate in the contest first.How many problems can Limak solve if he wants to make it to the party?
[{"input": "3 222\r\n", "output": ["2"]}, {"input": "4 190\r\n", "output": ["4"]}, {"input": "7 1\r\n", "output": ["7"]}, {"input": "10 135\r\n", "output": ["6"]}, {"input": "10 136\r\n", "output": ["5"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "1 240\r\n", "output": ["0"]}, {"input": "10 1\r\n", "output": ["9"]}, {"input": "10 240\r\n", "output": ["0"]}, {"input": "9 240\r\n", "output": ["0"]}, {"input": "9 1\r\n", "output": ["9"]}, {"input": "9 235\r\n", "output": ["1"]}, {"input": "9 236\r\n", "output": ["0"]}, {"input": "5 225\r\n", "output": ["2"]}, {"input": "5 226\r\n", "output": ["1"]}, {"input": "4 210\r\n", "output": ["3"]}, {"input": "4 211\r\n", "output": ["2"]}, {"input": "4 191\r\n", "output": ["3"]}, {"input": "10 165\r\n", "output": ["5"]}, {"input": "10 166\r\n", "output": ["4"]}, {"input": "8 100\r\n", "output": ["7"]}, {"input": "8 101\r\n", "output": ["6"]}, {"input": "8 60\r\n", "output": ["8"]}, {"input": "8 61\r\n", "output": ["7"]}, {"input": "10 15\r\n", "output": ["9"]}, {"input": "10 16\r\n", "output": ["8"]}, {"input": "4 100\r\n", "output": ["4"]}, {"input": "4 101\r\n", "output": ["4"]}, {"input": "7 167\r\n", "output": ["4"]}, {"input": "10 164\r\n", "output": ["5"]}, {"input": "9 170\r\n", "output": ["4"]}, {"input": "8 160\r\n", "output": ["5"]}, {"input": "1 100\r\n", "output": ["1"]}, {"input": "8 123\r\n", "output": ["6"]}, {"input": "2 99\r\n", "output": ["2"]}, {"input": "10 88\r\n", "output": ["7"]}, {"input": "1 235\r\n", "output": ["1"]}, {"input": "4 240\r\n", "output": ["0"]}, {"input": "1 55\r\n", "output": ["1"]}, {"input": "3 240\r\n", "output": ["0"]}, {"input": "2 240\r\n", "output": ["0"]}, {"input": "2 236\r\n", "output": ["0"]}, {"input": "10 2\r\n", "output": ["9"]}, {"input": "3 239\r\n", "output": ["0"]}, {"input": "1 237\r\n", "output": ["0"]}, {"input": "7 8\r\n", "output": ["7"]}, {"input": "10 235\r\n", "output": ["1"]}]
100
100
100
[{'input': '8 100\r\n', 'output': ['7']}, {'input': '3 239\r\n', 'output': ['0']}, {'input': '4 191\r\n', 'output': ['3']}, {'input': '10 164\r\n', 'output': ['5']}, {'input': '1 240\r\n', 'output': ['0']}]
[{'input': '4 100\r\n', 'output': ['4']}, {'input': '10 165\r\n', 'output': ['5']}, {'input': '10 88\r\n', 'output': ['7']}, {'input': '10 1\r\n', 'output': ['9']}, {'input': '4 190\r\n', 'output': ['4']}]
[{'input': '9 235\r\n', 'output': ['1']}, {'input': '9 236\r\n', 'output': ['0']}, {'input': '5 226\r\n', 'output': ['1']}, {'input': '10 2\r\n', 'output': ['9']}, {'input': '10 88\r\n', 'output': ['7']}]
[{'input': '10 1\r\n', 'output': ['9']}, {'input': '2 99\r\n', 'output': ['2']}, {'input': '10 164\r\n', 'output': ['5']}, {'input': '10 88\r\n', 'output': ['7']}, {'input': '9 170\r\n', 'output': ['4']}]
[{'input': '10 136\r\n', 'output': ['5']}, {'input': '3 239\r\n', 'output': ['0']}, {'input': '9 170\r\n', 'output': ['4']}, {'input': '8 61\r\n', 'output': ['7']}, {'input': '4 240\r\n', 'output': ['0']}]
100
100
100
100
100
100
100
100
100
100
75
100
75
100
75
111
100
100
85
["5", "3"]
Input contains one integer number A (3 ≤ A ≤ 1000).
1366732dddecba26db232d6ca8f35fdc
#include<bits/stdc++.h> using namespace std; long long int i,j=0,n,c,sum=0,x,a,b,f=0; int base(int k,int l) { sum=0; while(k!=0) { sum+=k%l; k/=l; } return sum; } int gcd(int a,int b) { return(b==0?a:gcd(b,a%b)); } int main() { f=0; cin>>n; for(i=2;i<n;i++) f+=base(n,i); j=gcd(f,n-2); cout<<(f/j)<<"/"<<(n-2)/j<<endl; }
["7/3", "2/1"]
C++
NoteIn the first sample number 5 written in all bases from 2 to 4 looks so: 101, 12, 11. Sums of digits are 2, 3 and 2, respectively.
Output should contain required average value in format «X/Y», where X is the numerator and Y is the denominator.
Little Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of digits of 123 in base 16 is equal to 18.Now he wonders what is an average value of sum of digits of the number A written in all bases from 2 to A - 1.Note that all computations should be done in base 10. You should find the result as an irreducible fraction, written in base 10.
[{"input": "5\r\n", "output": ["7/3"]}, {"input": "3\r\n", "output": ["2/1"]}, {"input": "1000\r\n", "output": ["90132/499"]}, {"input": "927\r\n", "output": ["155449/925"]}, {"input": "260\r\n", "output": ["6265/129"]}, {"input": "131\r\n", "output": ["3370/129"]}, {"input": "386\r\n", "output": ["857/12"]}, {"input": "277\r\n", "output": ["2864/55"]}, {"input": "766\r\n", "output": ["53217/382"]}, {"input": "28\r\n", "output": ["85/13"]}, {"input": "406\r\n", "output": ["7560/101"]}, {"input": "757\r\n", "output": ["103847/755"]}, {"input": "6\r\n", "output": ["9/4"]}, {"input": "239\r\n", "output": ["10885/237"]}, {"input": "322\r\n", "output": ["2399/40"]}, {"input": "98\r\n", "output": ["317/16"]}, {"input": "208\r\n", "output": ["4063/103"]}, {"input": "786\r\n", "output": ["55777/392"]}, {"input": "879\r\n", "output": ["140290/877"]}, {"input": "702\r\n", "output": ["89217/700"]}, {"input": "948\r\n", "output": ["7369/43"]}, {"input": "537\r\n", "output": ["52753/535"]}, {"input": "984\r\n", "output": ["174589/982"]}, {"input": "934\r\n", "output": ["157951/932"]}, {"input": "726\r\n", "output": ["95491/724"]}, {"input": "127\r\n", "output": ["3154/125"]}, {"input": "504\r\n", "output": ["23086/251"]}, {"input": "125\r\n", "output": ["3080/123"]}, {"input": "604\r\n", "output": ["33178/301"]}, {"input": "115\r\n", "output": ["2600/113"]}, {"input": "27\r\n", "output": ["167/25"]}, {"input": "687\r\n", "output": ["85854/685"]}, {"input": "880\r\n", "output": ["69915/439"]}, {"input": "173\r\n", "output": ["640/19"]}, {"input": "264\r\n", "output": ["6438/131"]}, {"input": "785\r\n", "output": ["111560/783"]}, {"input": "399\r\n", "output": ["29399/397"]}, {"input": "514\r\n", "output": ["6031/64"]}, {"input": "381\r\n", "output": ["26717/379"]}, {"input": "592\r\n", "output": ["63769/590"]}, {"input": "417\r\n", "output": ["32002/415"]}, {"input": "588\r\n", "output": ["62723/586"]}, {"input": "852\r\n", "output": ["131069/850"]}, {"input": "959\r\n", "output": ["5059/29"]}, {"input": "841\r\n", "output": ["127737/839"]}, {"input": "733\r\n", "output": ["97598/731"]}, {"input": "692\r\n", "output": ["87017/690"]}, {"input": "69\r\n", "output": ["983/67"]}, {"input": "223\r\n", "output": ["556/13"]}, {"input": "93\r\n", "output": ["246/13"]}, {"input": "643\r\n", "output": ["75503/641"]}, {"input": "119\r\n", "output": ["2833/117"]}, {"input": "498\r\n", "output": ["1459/16"]}, {"input": "155\r\n", "output": ["4637/153"]}, {"input": "305\r\n", "output": ["17350/303"]}, {"input": "454\r\n", "output": ["37893/452"]}, {"input": "88\r\n", "output": ["1529/86"]}, {"input": "850\r\n", "output": ["32645/212"]}, {"input": "474\r\n", "output": ["20581/236"]}, {"input": "309\r\n", "output": ["17731/307"]}, {"input": "762\r\n", "output": ["105083/760"]}, {"input": "591\r\n", "output": ["63761/589"]}, {"input": "457\r\n", "output": ["38317/455"]}, {"input": "141\r\n", "output": ["3832/139"]}, {"input": "385\r\n", "output": ["27232/383"]}, {"input": "387\r\n", "output": ["27628/385"]}, {"input": "469\r\n", "output": ["40306/467"]}, {"input": "624\r\n", "output": ["35285/311"]}, {"input": "330\r\n", "output": ["487/8"]}, {"input": "31\r\n", "output": ["222/29"]}, {"input": "975\r\n", "output": ["171679/973"]}, {"input": "584\r\n", "output": ["62183/582"]}, {"input": "668\r\n", "output": ["81127/666"]}, {"input": "331\r\n", "output": ["20297/329"]}, {"input": "189\r\n", "output": ["6789/187"]}, {"input": "251\r\n", "output": ["11939/249"]}, {"input": "876\r\n", "output": ["69196/437"]}, {"input": "615\r\n", "output": ["68987/613"]}, {"input": "451\r\n", "output": ["37258/449"]}, {"input": "499\r\n", "output": ["45727/497"]}, {"input": "699\r\n", "output": ["89117/697"]}, {"input": "619\r\n", "output": ["70019/617"]}, {"input": "413\r\n", "output": ["10515/137"]}, {"input": "197\r\n", "output": ["7399/195"]}, {"input": "794\r\n", "output": ["14281/99"]}, {"input": "659\r\n", "output": ["79403/657"]}, {"input": "653\r\n", "output": ["77695/651"]}, {"input": "23\r\n", "output": ["45/7"]}, {"input": "430\r\n", "output": ["16985/214"]}, {"input": "249\r\n", "output": ["11659/247"]}, {"input": "837\r\n", "output": ["126869/835"]}, {"input": "258\r\n", "output": ["12373/256"]}, {"input": "995\r\n", "output": ["59665/331"]}, {"input": "102\r\n", "output": ["504/25"]}, {"input": "989\r\n", "output": ["177124/987"]}, {"input": "376\r\n", "output": ["13008/187"]}, {"input": "657\r\n", "output": ["15715/131"]}, {"input": "746\r\n", "output": ["50509/372"]}, {"input": "602\r\n", "output": ["13177/120"]}]
100
100
100
[{'input': '331\r\n', 'output': ['20297/329']}, {'input': '309\r\n', 'output': ['17731/307']}, {'input': '251\r\n', 'output': ['11939/249']}, {'input': '305\r\n', 'output': ['17350/303']}, {'input': '984\r\n', 'output': ['174589/982']}]
[{'input': '258\r\n', 'output': ['12373/256']}, {'input': '514\r\n', 'output': ['6031/64']}, {'input': '537\r\n', 'output': ['52753/535']}, {'input': '474\r\n', 'output': ['20581/236']}, {'input': '604\r\n', 'output': ['33178/301']}]
[{'input': '28\r\n', 'output': ['85/13']}, {'input': '249\r\n', 'output': ['11659/247']}, {'input': '309\r\n', 'output': ['17731/307']}, {'input': '69\r\n', 'output': ['983/67']}, {'input': '726\r\n', 'output': ['95491/724']}]
[{'input': '127\r\n', 'output': ['3154/125']}, {'input': '602\r\n', 'output': ['13177/120']}, {'input': '305\r\n', 'output': ['17350/303']}, {'input': '88\r\n', 'output': ['1529/86']}, {'input': '197\r\n', 'output': ['7399/195']}]
[{'input': '995\r\n', 'output': ['59665/331']}, {'input': '785\r\n', 'output': ['111560/783']}, {'input': '469\r\n', 'output': ['40306/467']}, {'input': '93\r\n', 'output': ['246/13']}, {'input': '305\r\n', 'output': ['17350/303']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
112
100
100
100
["4\n6\n1\n1\n1\n1", "1\n10\n5", "3\n6\n1\n6\n5", "3\n7\n1\n6\n5"]
The first line contains a single integer $$$n$$$ $$$(1 \le n \le 100)$$$ — the number of benches in the park. The second line contains a single integer $$$m$$$ $$$(1 \le m \le 10\,000)$$$ — the number of people additionally coming to the park. Each of the next $$$n$$$ lines contains a single integer $$$a_i$$$ $$$(1 \le a_i \le 100)$$$ — the initial number of people on the $$$i$$$-th bench.
78f696bd954c9f0f9bb502e515d85a8d
#include <bits/stdc++.h> #include <math.h> using namespace std; int n,m,a; int main() { int kmin, kmax; scanf("%d",&n); scanf("%d",&m); int cnt = 0,mx=0; for (int i=0; i<n; i++){ scanf("%d",&a); cnt += a; if(a > mx) mx = a; } kmin = ceil((float)(cnt+m)/n); if(kmin<=mx) kmin = mx; kmax = m + mx; cout << kmin << " " << kmax << endl; return 0; }
["3 7", "15 15", "6 12", "7 13"]
C++
NoteIn the first example, each of four benches is occupied by a single person. The minimum $$$k$$$ is $$$3$$$. For example, it is possible to achieve if two newcomers occupy the first bench, one occupies the second bench, one occupies the third bench, and two remaining — the fourth bench. The maximum $$$k$$$ is $$$7$$$. That requires all six new people to occupy the same bench.The second example has its minimum $$$k$$$ equal to $$$15$$$ and maximum $$$k$$$ equal to $$$15$$$, as there is just a single bench in the park and all $$$10$$$ people will occupy it.
Print the minimum possible $$$k$$$ and the maximum possible $$$k$$$, where $$$k$$$ is the maximum number of people sitting on one bench after additional $$$m$$$ people came to the park.
There are $$$n$$$ benches in the Berland Central park. It is known that $$$a_i$$$ people are currently sitting on the $$$i$$$-th bench. Another $$$m$$$ people are coming to the park and each of them is going to have a seat on some bench out of $$$n$$$ available.Let $$$k$$$ be the maximum number of people sitting on one bench after additional $$$m$$$ people came to the park. Calculate the minimum possible $$$k$$$ and the maximum possible $$$k$$$.Nobody leaves the taken seat during the whole process.
[{"input": "4\r\n6\r\n1\r\n1\r\n1\r\n1\r\n", "output": ["3 7"]}, {"input": "1\r\n10\r\n5\r\n", "output": ["15 15"]}, {"input": "3\r\n6\r\n1\r\n6\r\n5\r\n", "output": ["6 12"]}, {"input": "3\r\n7\r\n1\r\n6\r\n5\r\n", "output": ["7 13"]}, {"input": "10\r\n1000\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n", "output": ["200 1100"]}, {"input": "10\r\n1\r\n3\r\n3\r\n2\r\n3\r\n3\r\n3\r\n3\r\n3\r\n3\r\n3\r\n", "output": ["3 4"]}, {"input": "51\r\n10000\r\n54\r\n23\r\n93\r\n86\r\n57\r\n68\r\n42\r\n33\r\n47\r\n18\r\n78\r\n41\r\n35\r\n92\r\n32\r\n97\r\n74\r\n93\r\n27\r\n59\r\n90\r\n23\r\n79\r\n96\r\n77\r\n29\r\n88\r\n83\r\n83\r\n46\r\n94\r\n61\r\n56\r\n68\r\n43\r\n15\r\n79\r\n26\r\n36\r\n99\r\n36\r\n55\r\n77\r\n23\r\n15\r\n12\r\n84\r\n57\r\n82\r\n33\r\n14\r\n", "output": ["254 10099"]}, {"input": "100\r\n8000\r\n88\r\n40\r\n39\r\n88\r\n33\r\n2\r\n60\r\n93\r\n62\r\n18\r\n44\r\n53\r\n79\r\n55\r\n34\r\n71\r\n45\r\n82\r\n97\r\n96\r\n96\r\n25\r\n83\r\n83\r\n54\r\n45\r\n47\r\n59\r\n94\r\n84\r\n12\r\n33\r\n97\r\n24\r\n71\r\n28\r\n81\r\n89\r\n52\r\n87\r\n96\r\n35\r\n34\r\n31\r\n45\r\n42\r\n14\r\n74\r\n8\r\n68\r\n61\r\n36\r\n65\r\n87\r\n31\r\n18\r\n38\r\n84\r\n28\r\n74\r\n98\r\n77\r\n15\r\n85\r\n82\r\n64\r\n2\r\n93\r\n31\r\n78\r\n64\r\n35\r\n6\r\n77\r\n55\r\n70\r\n83\r\n42\r\n98\r\n38\r\n59\r\n99\r\n27\r\n66\r\n10\r\n54\r\n22\r\n94\r\n21\r\n21\r\n89\r\n86\r\n73\r\n12\r\n86\r\n1\r\n98\r\n94\r\n48\r\n51\r\n", "output": ["137 8099"]}, {"input": "10\r\n10\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n", "output": ["2 11"]}, {"input": "10\r\n10\r\n1\r\n1\r\n1\r\n2\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n", "output": ["3 12"]}, {"input": "100\r\n1000\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n", "output": ["11 1001"]}, {"input": "1\r\n10000\r\n57\r\n", "output": ["10057 10057"]}, {"input": "1\r\n1000\r\n48\r\n", "output": ["1048 1048"]}, {"input": "2\r\n1000\r\n1\r\n7\r\n", "output": ["504 1007"]}, {"input": "5\r\n10\r\n68\r\n87\r\n14\r\n68\r\n23\r\n", "output": ["87 97"]}, {"input": "10\r\n20\r\n80\r\n41\r\n15\r\n77\r\n91\r\n82\r\n15\r\n83\r\n36\r\n3\r\n", "output": ["91 111"]}, {"input": "20\r\n3303\r\n25\r\n14\r\n77\r\n85\r\n66\r\n97\r\n9\r\n60\r\n79\r\n39\r\n47\r\n2\r\n97\r\n71\r\n45\r\n36\r\n92\r\n54\r\n62\r\n53\r\n", "output": ["221 3400"]}, {"input": "40\r\n10000\r\n54\r\n5\r\n23\r\n10\r\n10\r\n77\r\n15\r\n84\r\n92\r\n63\r\n34\r\n21\r\n12\r\n56\r\n25\r\n32\r\n28\r\n50\r\n50\r\n86\r\n3\r\n26\r\n39\r\n69\r\n43\r\n99\r\n71\r\n38\r\n15\r\n33\r\n50\r\n79\r\n54\r\n84\r\n33\r\n47\r\n14\r\n66\r\n99\r\n25\r\n", "output": ["296 10099"]}, {"input": "66\r\n1000\r\n27\r\n10\r\n63\r\n17\r\n28\r\n89\r\n34\r\n86\r\n27\r\n62\r\n26\r\n18\r\n25\r\n31\r\n45\r\n44\r\n92\r\n56\r\n47\r\n18\r\n53\r\n56\r\n79\r\n3\r\n9\r\n32\r\n88\r\n52\r\n21\r\n57\r\n97\r\n84\r\n50\r\n12\r\n6\r\n52\r\n21\r\n37\r\n24\r\n84\r\n44\r\n81\r\n41\r\n47\r\n7\r\n67\r\n93\r\n43\r\n100\r\n64\r\n82\r\n46\r\n28\r\n48\r\n1\r\n34\r\n28\r\n82\r\n15\r\n47\r\n1\r\n19\r\n34\r\n12\r\n48\r\n48\r\n", "output": ["100 1100"]}, {"input": "78\r\n9909\r\n63\r\n38\r\n36\r\n74\r\n56\r\n3\r\n27\r\n99\r\n71\r\n95\r\n81\r\n39\r\n45\r\n75\r\n32\r\n42\r\n5\r\n23\r\n45\r\n46\r\n63\r\n69\r\n75\r\n80\r\n89\r\n48\r\n86\r\n74\r\n18\r\n87\r\n4\r\n55\r\n54\r\n8\r\n15\r\n91\r\n39\r\n13\r\n89\r\n95\r\n75\r\n38\r\n31\r\n27\r\n48\r\n81\r\n47\r\n91\r\n62\r\n88\r\n53\r\n45\r\n73\r\n79\r\n42\r\n57\r\n72\r\n99\r\n16\r\n52\r\n15\r\n52\r\n95\r\n98\r\n26\r\n84\r\n4\r\n88\r\n31\r\n26\r\n9\r\n86\r\n29\r\n45\r\n62\r\n18\r\n99\r\n78\r\n", "output": ["182 10008"]}, {"input": "89\r\n9080\r\n29\r\n88\r\n62\r\n50\r\n63\r\n91\r\n24\r\n3\r\n93\r\n76\r\n73\r\n50\r\n26\r\n32\r\n87\r\n93\r\n48\r\n52\r\n97\r\n68\r\n100\r\n84\r\n42\r\n93\r\n59\r\n68\r\n46\r\n19\r\n53\r\n30\r\n53\r\n20\r\n65\r\n43\r\n22\r\n98\r\n46\r\n45\r\n38\r\n37\r\n45\r\n31\r\n2\r\n24\r\n56\r\n74\r\n93\r\n48\r\n40\r\n68\r\n7\r\n4\r\n68\r\n44\r\n31\r\n63\r\n32\r\n21\r\n94\r\n92\r\n99\r\n93\r\n17\r\n18\r\n18\r\n48\r\n71\r\n38\r\n67\r\n67\r\n29\r\n87\r\n38\r\n66\r\n73\r\n61\r\n59\r\n98\r\n91\r\n33\r\n22\r\n56\r\n75\r\n91\r\n73\r\n83\r\n61\r\n41\r\n70\r\n", "output": ["158 9180"]}, {"input": "90\r\n10000\r\n43\r\n85\r\n87\r\n11\r\n50\r\n66\r\n30\r\n90\r\n23\r\n22\r\n16\r\n20\r\n2\r\n60\r\n8\r\n26\r\n56\r\n89\r\n50\r\n40\r\n3\r\n23\r\n9\r\n66\r\n36\r\n85\r\n19\r\n49\r\n87\r\n97\r\n20\r\n23\r\n75\r\n32\r\n3\r\n38\r\n71\r\n54\r\n79\r\n46\r\n62\r\n27\r\n16\r\n2\r\n24\r\n55\r\n76\r\n83\r\n55\r\n47\r\n46\r\n41\r\n63\r\n30\r\n22\r\n84\r\n70\r\n81\r\n59\r\n44\r\n56\r\n23\r\n67\r\n9\r\n60\r\n54\r\n95\r\n36\r\n73\r\n60\r\n33\r\n20\r\n18\r\n67\r\n20\r\n18\r\n7\r\n65\r\n55\r\n54\r\n45\r\n32\r\n38\r\n52\r\n15\r\n15\r\n88\r\n44\r\n47\r\n88\r\n", "output": ["157 10097"]}, {"input": "99\r\n1092\r\n28\r\n89\r\n65\r\n40\r\n96\r\n47\r\n76\r\n2\r\n62\r\n59\r\n60\r\n90\r\n91\r\n12\r\n10\r\n71\r\n57\r\n97\r\n18\r\n52\r\n82\r\n32\r\n71\r\n77\r\n39\r\n16\r\n84\r\n89\r\n26\r\n95\r\n45\r\n15\r\n93\r\n73\r\n63\r\n32\r\n33\r\n3\r\n64\r\n12\r\n92\r\n12\r\n92\r\n80\r\n3\r\n80\r\n47\r\n26\r\n69\r\n84\r\n96\r\n40\r\n86\r\n95\r\n55\r\n13\r\n64\r\n73\r\n52\r\n37\r\n13\r\n98\r\n86\r\n95\r\n43\r\n67\r\n18\r\n98\r\n100\r\n66\r\n5\r\n25\r\n87\r\n25\r\n37\r\n10\r\n29\r\n43\r\n84\r\n72\r\n17\r\n70\r\n31\r\n96\r\n27\r\n38\r\n1\r\n40\r\n74\r\n17\r\n58\r\n39\r\n18\r\n5\r\n41\r\n15\r\n95\r\n53\r\n77\r\n", "output": ["100 1192"]}, {"input": "100\r\n66\r\n95\r\n19\r\n88\r\n15\r\n29\r\n52\r\n37\r\n75\r\n21\r\n90\r\n93\r\n75\r\n91\r\n71\r\n53\r\n55\r\n90\r\n78\r\n19\r\n63\r\n43\r\n25\r\n52\r\n10\r\n55\r\n76\r\n47\r\n42\r\n57\r\n45\r\n35\r\n53\r\n2\r\n62\r\n61\r\n99\r\n59\r\n59\r\n43\r\n45\r\n31\r\n37\r\n50\r\n68\r\n51\r\n91\r\n34\r\n48\r\n40\r\n69\r\n77\r\n33\r\n16\r\n64\r\n19\r\n82\r\n76\r\n35\r\n41\r\n41\r\n79\r\n29\r\n69\r\n100\r\n30\r\n81\r\n47\r\n55\r\n79\r\n21\r\n59\r\n3\r\n11\r\n43\r\n49\r\n100\r\n27\r\n87\r\n64\r\n8\r\n6\r\n7\r\n88\r\n71\r\n98\r\n6\r\n32\r\n53\r\n91\r\n85\r\n60\r\n35\r\n55\r\n5\r\n44\r\n66\r\n76\r\n99\r\n7\r\n58\r\n", "output": ["100 166"]}, {"input": "100\r\n50\r\n20\r\n63\r\n60\r\n88\r\n7\r\n22\r\n90\r\n15\r\n27\r\n82\r\n37\r\n44\r\n42\r\n50\r\n33\r\n46\r\n7\r\n97\r\n93\r\n5\r\n68\r\n79\r\n76\r\n3\r\n82\r\n5\r\n51\r\n79\r\n17\r\n1\r\n1\r\n93\r\n52\r\n88\r\n23\r\n23\r\n49\r\n86\r\n64\r\n18\r\n36\r\n53\r\n49\r\n47\r\n11\r\n19\r\n6\r\n79\r\n64\r\n59\r\n56\r\n96\r\n15\r\n72\r\n81\r\n45\r\n24\r\n55\r\n31\r\n2\r\n74\r\n64\r\n57\r\n65\r\n71\r\n44\r\n8\r\n7\r\n38\r\n50\r\n67\r\n1\r\n79\r\n89\r\n16\r\n35\r\n10\r\n72\r\n69\r\n8\r\n56\r\n42\r\n44\r\n95\r\n25\r\n26\r\n16\r\n84\r\n36\r\n73\r\n17\r\n61\r\n91\r\n15\r\n19\r\n78\r\n44\r\n77\r\n96\r\n58\r\n", "output": ["97 147"]}, {"input": "100\r\n100\r\n82\r\n51\r\n81\r\n14\r\n37\r\n17\r\n78\r\n92\r\n64\r\n15\r\n8\r\n86\r\n89\r\n8\r\n87\r\n77\r\n66\r\n10\r\n15\r\n12\r\n100\r\n25\r\n92\r\n47\r\n21\r\n78\r\n20\r\n63\r\n13\r\n49\r\n41\r\n36\r\n41\r\n79\r\n16\r\n87\r\n87\r\n69\r\n3\r\n76\r\n80\r\n60\r\n100\r\n49\r\n70\r\n59\r\n72\r\n8\r\n38\r\n71\r\n45\r\n97\r\n71\r\n14\r\n76\r\n54\r\n81\r\n4\r\n59\r\n46\r\n39\r\n29\r\n92\r\n3\r\n49\r\n22\r\n53\r\n99\r\n59\r\n52\r\n74\r\n31\r\n92\r\n43\r\n42\r\n23\r\n44\r\n9\r\n82\r\n47\r\n7\r\n40\r\n12\r\n9\r\n3\r\n55\r\n37\r\n85\r\n46\r\n22\r\n84\r\n52\r\n98\r\n41\r\n21\r\n77\r\n63\r\n17\r\n62\r\n91\r\n", "output": ["100 200"]}, {"input": "100\r\n1000\r\n91\r\n17\r\n88\r\n51\r\n92\r\n47\r\n85\r\n3\r\n82\r\n61\r\n2\r\n48\r\n55\r\n56\r\n71\r\n1\r\n12\r\n78\r\n80\r\n31\r\n42\r\n33\r\n85\r\n99\r\n25\r\n25\r\n37\r\n18\r\n29\r\n53\r\n84\r\n88\r\n4\r\n55\r\n24\r\n3\r\n53\r\n53\r\n1\r\n95\r\n36\r\n84\r\n65\r\n5\r\n40\r\n52\r\n49\r\n77\r\n48\r\n5\r\n77\r\n50\r\n31\r\n80\r\n100\r\n46\r\n28\r\n29\r\n34\r\n83\r\n26\r\n3\r\n100\r\n63\r\n100\r\n23\r\n76\r\n4\r\n70\r\n57\r\n10\r\n58\r\n7\r\n20\r\n84\r\n44\r\n86\r\n54\r\n2\r\n11\r\n85\r\n3\r\n35\r\n83\r\n96\r\n97\r\n55\r\n75\r\n39\r\n39\r\n39\r\n61\r\n19\r\n86\r\n76\r\n72\r\n29\r\n69\r\n20\r\n17\r\n", "output": ["100 1100"]}, {"input": "100\r\n2000\r\n77\r\n39\r\n49\r\n44\r\n85\r\n10\r\n28\r\n49\r\n92\r\n64\r\n67\r\n39\r\n65\r\n53\r\n81\r\n58\r\n63\r\n80\r\n74\r\n27\r\n10\r\n45\r\n9\r\n26\r\n31\r\n98\r\n55\r\n61\r\n51\r\n43\r\n2\r\n95\r\n77\r\n52\r\n79\r\n42\r\n89\r\n99\r\n68\r\n6\r\n29\r\n71\r\n63\r\n96\r\n11\r\n10\r\n77\r\n32\r\n89\r\n28\r\n12\r\n19\r\n84\r\n34\r\n22\r\n69\r\n86\r\n24\r\n35\r\n40\r\n5\r\n100\r\n55\r\n35\r\n69\r\n60\r\n74\r\n72\r\n37\r\n44\r\n82\r\n83\r\n91\r\n1\r\n68\r\n24\r\n79\r\n39\r\n47\r\n57\r\n16\r\n76\r\n64\r\n34\r\n72\r\n3\r\n48\r\n35\r\n15\r\n70\r\n33\r\n78\r\n31\r\n48\r\n10\r\n30\r\n55\r\n43\r\n6\r\n93\r\n", "output": ["100 2100"]}, {"input": "100\r\n5000\r\n30\r\n90\r\n42\r\n18\r\n55\r\n6\r\n50\r\n65\r\n31\r\n89\r\n47\r\n48\r\n76\r\n58\r\n10\r\n18\r\n2\r\n79\r\n39\r\n9\r\n7\r\n89\r\n100\r\n1\r\n44\r\n23\r\n99\r\n12\r\n23\r\n15\r\n55\r\n16\r\n95\r\n40\r\n23\r\n37\r\n87\r\n42\r\n54\r\n51\r\n11\r\n57\r\n44\r\n61\r\n32\r\n74\r\n44\r\n5\r\n1\r\n96\r\n32\r\n30\r\n21\r\n13\r\n77\r\n48\r\n62\r\n6\r\n28\r\n7\r\n49\r\n87\r\n33\r\n60\r\n72\r\n64\r\n88\r\n86\r\n34\r\n13\r\n23\r\n59\r\n46\r\n39\r\n5\r\n45\r\n81\r\n88\r\n75\r\n97\r\n40\r\n88\r\n46\r\n100\r\n87\r\n30\r\n37\r\n13\r\n68\r\n43\r\n9\r\n32\r\n48\r\n28\r\n100\r\n14\r\n28\r\n67\r\n73\r\n26\r\n", "output": ["100 5100"]}, {"input": "100\r\n9990\r\n22\r\n89\r\n54\r\n55\r\n92\r\n20\r\n84\r\n12\r\n93\r\n6\r\n73\r\n50\r\n23\r\n62\r\n97\r\n88\r\n59\r\n87\r\n4\r\n14\r\n49\r\n28\r\n47\r\n93\r\n5\r\n36\r\n50\r\n78\r\n83\r\n99\r\n100\r\n27\r\n24\r\n23\r\n27\r\n84\r\n67\r\n72\r\n45\r\n51\r\n53\r\n32\r\n60\r\n9\r\n77\r\n63\r\n15\r\n98\r\n17\r\n49\r\n58\r\n77\r\n50\r\n31\r\n10\r\n6\r\n16\r\n74\r\n50\r\n99\r\n100\r\n36\r\n51\r\n71\r\n89\r\n65\r\n17\r\n62\r\n32\r\n3\r\n25\r\n39\r\n19\r\n2\r\n25\r\n75\r\n25\r\n89\r\n87\r\n13\r\n96\r\n91\r\n10\r\n1\r\n94\r\n39\r\n10\r\n64\r\n26\r\n28\r\n32\r\n7\r\n16\r\n34\r\n96\r\n28\r\n24\r\n35\r\n82\r\n99\r\n", "output": ["150 10090"]}, {"input": "100\r\n10000\r\n25\r\n90\r\n88\r\n97\r\n71\r\n24\r\n53\r\n4\r\n32\r\n69\r\n53\r\n93\r\n80\r\n14\r\n30\r\n65\r\n9\r\n56\r\n3\r\n23\r\n70\r\n25\r\n31\r\n6\r\n13\r\n19\r\n49\r\n58\r\n95\r\n40\r\n26\r\n72\r\n75\r\n44\r\n86\r\n13\r\n94\r\n11\r\n83\r\n75\r\n26\r\n64\r\n100\r\n84\r\n82\r\n35\r\n80\r\n41\r\n40\r\n8\r\n5\r\n28\r\n3\r\n98\r\n1\r\n22\r\n73\r\n33\r\n44\r\n22\r\n2\r\n72\r\n68\r\n80\r\n39\r\n92\r\n75\r\n67\r\n61\r\n26\r\n89\r\n59\r\n19\r\n29\r\n7\r\n60\r\n91\r\n34\r\n73\r\n53\r\n22\r\n2\r\n85\r\n22\r\n47\r\n92\r\n90\r\n99\r\n100\r\n44\r\n82\r\n19\r\n1\r\n49\r\n100\r\n13\r\n67\r\n32\r\n75\r\n98\r\n", "output": ["151 10100"]}, {"input": "100\r\n10000\r\n45\r\n35\r\n50\r\n78\r\n28\r\n97\r\n37\r\n92\r\n91\r\n51\r\n93\r\n33\r\n70\r\n43\r\n53\r\n78\r\n31\r\n14\r\n29\r\n67\r\n11\r\n7\r\n41\r\n85\r\n70\r\n27\r\n74\r\n15\r\n15\r\n10\r\n52\r\n50\r\n66\r\n81\r\n95\r\n25\r\n28\r\n86\r\n17\r\n89\r\n19\r\n87\r\n85\r\n38\r\n79\r\n19\r\n92\r\n85\r\n62\r\n71\r\n18\r\n72\r\n92\r\n18\r\n93\r\n56\r\n64\r\n54\r\n3\r\n38\r\n18\r\n77\r\n3\r\n54\r\n70\r\n49\r\n56\r\n91\r\n60\r\n56\r\n34\r\n54\r\n42\r\n41\r\n75\r\n90\r\n43\r\n21\r\n18\r\n69\r\n76\r\n51\r\n24\r\n50\r\n82\r\n56\r\n62\r\n45\r\n50\r\n67\r\n20\r\n31\r\n12\r\n10\r\n10\r\n7\r\n75\r\n84\r\n17\r\n18\r\n", "output": ["151 10097"]}, {"input": "2\r\n50\r\n1\r\n51\r\n", "output": ["51 101"]}, {"input": "3\r\n100\r\n52\r\n2\r\n2\r\n", "output": ["52 152"]}, {"input": "100\r\n300\r\n1\r\n1\r\n2\r\n2\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n2\r\n2\r\n1\r\n2\r\n2\r\n1\r\n2\r\n2\r\n2\r\n2\r\n2\r\n1\r\n1\r\n1\r\n2\r\n1\r\n2\r\n1\r\n1\r\n1\r\n2\r\n1\r\n1\r\n1\r\n2\r\n1\r\n2\r\n1\r\n2\r\n1\r\n2\r\n1\r\n2\r\n1\r\n2\r\n1\r\n1\r\n1\r\n1\r\n2\r\n2\r\n2\r\n1\r\n1\r\n2\r\n1\r\n2\r\n2\r\n2\r\n1\r\n1\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n1\r\n1\r\n2\r\n2\r\n2\r\n2\r\n1\r\n2\r\n2\r\n2\r\n1\r\n2\r\n1\r\n1\r\n2\r\n2\r\n1\r\n1\r\n1\r\n1\r\n2\r\n1\r\n2\r\n2\r\n1\r\n2\r\n2\r\n1\r\n1\r\n2\r\n1\r\n2\r\n2\r\n", "output": ["5 302"]}, {"input": "100\r\n3000\r\n99\r\n100\r\n99\r\n99\r\n100\r\n99\r\n100\r\n99\r\n99\r\n100\r\n99\r\n100\r\n100\r\n99\r\n100\r\n100\r\n99\r\n99\r\n99\r\n100\r\n100\r\n100\r\n100\r\n100\r\n99\r\n100\r\n100\r\n99\r\n100\r\n100\r\n99\r\n99\r\n99\r\n99\r\n100\r\n100\r\n99\r\n99\r\n99\r\n100\r\n99\r\n100\r\n100\r\n99\r\n99\r\n100\r\n100\r\n100\r\n99\r\n99\r\n99\r\n100\r\n99\r\n99\r\n99\r\n100\r\n99\r\n99\r\n100\r\n99\r\n100\r\n100\r\n100\r\n99\r\n99\r\n100\r\n100\r\n100\r\n99\r\n100\r\n100\r\n99\r\n99\r\n100\r\n100\r\n99\r\n100\r\n100\r\n100\r\n99\r\n99\r\n100\r\n100\r\n99\r\n100\r\n99\r\n99\r\n100\r\n99\r\n99\r\n99\r\n100\r\n99\r\n100\r\n100\r\n100\r\n99\r\n100\r\n99\r\n100\r\n", "output": ["130 3100"]}, {"input": "100\r\n10000\r\n54\r\n54\r\n50\r\n52\r\n55\r\n51\r\n50\r\n53\r\n50\r\n56\r\n50\r\n51\r\n51\r\n52\r\n54\r\n50\r\n54\r\n52\r\n53\r\n56\r\n55\r\n51\r\n52\r\n55\r\n56\r\n52\r\n52\r\n56\r\n51\r\n56\r\n51\r\n51\r\n55\r\n54\r\n52\r\n55\r\n51\r\n55\r\n56\r\n54\r\n55\r\n54\r\n56\r\n56\r\n51\r\n52\r\n52\r\n56\r\n51\r\n52\r\n52\r\n55\r\n53\r\n51\r\n55\r\n51\r\n54\r\n52\r\n56\r\n51\r\n50\r\n52\r\n52\r\n55\r\n53\r\n52\r\n53\r\n53\r\n51\r\n52\r\n54\r\n50\r\n53\r\n53\r\n56\r\n52\r\n52\r\n54\r\n54\r\n52\r\n55\r\n53\r\n54\r\n53\r\n54\r\n55\r\n56\r\n51\r\n54\r\n55\r\n50\r\n56\r\n52\r\n50\r\n55\r\n55\r\n54\r\n55\r\n50\r\n50\r\n", "output": ["154 10056"]}, {"input": "100\r\n2325\r\n78\r\n78\r\n80\r\n78\r\n79\r\n80\r\n79\r\n80\r\n79\r\n80\r\n78\r\n80\r\n79\r\n80\r\n78\r\n78\r\n79\r\n80\r\n80\r\n80\r\n79\r\n79\r\n79\r\n79\r\n80\r\n80\r\n79\r\n80\r\n79\r\n80\r\n79\r\n79\r\n79\r\n79\r\n80\r\n80\r\n80\r\n78\r\n80\r\n80\r\n80\r\n78\r\n80\r\n80\r\n80\r\n80\r\n78\r\n78\r\n79\r\n79\r\n79\r\n79\r\n80\r\n78\r\n80\r\n78\r\n80\r\n80\r\n80\r\n79\r\n78\r\n79\r\n80\r\n80\r\n78\r\n78\r\n80\r\n78\r\n80\r\n79\r\n78\r\n80\r\n78\r\n78\r\n80\r\n80\r\n78\r\n78\r\n79\r\n78\r\n78\r\n79\r\n79\r\n78\r\n80\r\n78\r\n78\r\n80\r\n80\r\n80\r\n78\r\n80\r\n78\r\n79\r\n80\r\n78\r\n80\r\n79\r\n78\r\n79\r\n", "output": ["103 2405"]}, {"input": "100\r\n3241\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n", "output": ["133 3341"]}, {"input": "100\r\n9675\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n", "output": ["98 9676"]}, {"input": "100\r\n9435\r\n36\r\n37\r\n36\r\n36\r\n37\r\n34\r\n35\r\n37\r\n36\r\n34\r\n37\r\n35\r\n34\r\n35\r\n35\r\n36\r\n36\r\n37\r\n37\r\n36\r\n37\r\n34\r\n36\r\n35\r\n37\r\n36\r\n34\r\n35\r\n35\r\n35\r\n34\r\n36\r\n37\r\n36\r\n35\r\n34\r\n35\r\n34\r\n34\r\n34\r\n36\r\n37\r\n37\r\n34\r\n37\r\n34\r\n37\r\n36\r\n35\r\n36\r\n37\r\n35\r\n37\r\n35\r\n36\r\n34\r\n36\r\n35\r\n35\r\n35\r\n37\r\n37\r\n36\r\n34\r\n35\r\n35\r\n36\r\n35\r\n34\r\n35\r\n35\r\n35\r\n37\r\n36\r\n34\r\n35\r\n37\r\n36\r\n36\r\n36\r\n36\r\n35\r\n34\r\n37\r\n35\r\n34\r\n37\r\n37\r\n36\r\n37\r\n37\r\n34\r\n36\r\n35\r\n36\r\n35\r\n34\r\n37\r\n34\r\n35\r\n", "output": ["130 9472"]}, {"input": "100\r\n9999\r\n4\r\n5\r\n1\r\n8\r\n8\r\n2\r\n9\r\n5\r\n8\r\n6\r\n10\r\n8\r\n2\r\n10\r\n5\r\n10\r\n10\r\n3\r\n3\r\n1\r\n9\r\n7\r\n1\r\n5\r\n3\r\n7\r\n1\r\n3\r\n7\r\n3\r\n7\r\n8\r\n8\r\n8\r\n10\r\n3\r\n9\r\n9\r\n5\r\n9\r\n4\r\n7\r\n3\r\n8\r\n8\r\n6\r\n9\r\n4\r\n4\r\n8\r\n3\r\n6\r\n3\r\n3\r\n7\r\n10\r\n4\r\n2\r\n4\r\n3\r\n9\r\n10\r\n2\r\n4\r\n3\r\n1\r\n3\r\n4\r\n4\r\n4\r\n5\r\n8\r\n6\r\n3\r\n9\r\n10\r\n7\r\n7\r\n10\r\n2\r\n6\r\n10\r\n7\r\n7\r\n10\r\n6\r\n2\r\n9\r\n8\r\n1\r\n6\r\n7\r\n3\r\n5\r\n8\r\n6\r\n1\r\n3\r\n8\r\n5\r\n", "output": ["106 10009"]}, {"input": "100\r\n2344\r\n42\r\n40\r\n69\r\n62\r\n79\r\n43\r\n36\r\n55\r\n44\r\n13\r\n48\r\n69\r\n46\r\n61\r\n70\r\n75\r\n51\r\n67\r\n57\r\n35\r\n5\r\n19\r\n6\r\n92\r\n78\r\n59\r\n42\r\n3\r\n81\r\n41\r\n70\r\n90\r\n99\r\n93\r\n44\r\n22\r\n80\r\n62\r\n69\r\n95\r\n12\r\n63\r\n99\r\n42\r\n12\r\n9\r\n72\r\n8\r\n19\r\n33\r\n81\r\n33\r\n66\r\n32\r\n10\r\n50\r\n98\r\n83\r\n11\r\n25\r\n81\r\n13\r\n56\r\n60\r\n4\r\n89\r\n75\r\n59\r\n92\r\n7\r\n55\r\n84\r\n48\r\n85\r\n82\r\n18\r\n29\r\n68\r\n60\r\n25\r\n26\r\n37\r\n12\r\n15\r\n27\r\n17\r\n85\r\n20\r\n16\r\n47\r\n76\r\n55\r\n75\r\n66\r\n47\r\n98\r\n90\r\n32\r\n47\r\n9\r\n", "output": ["99 2443"]}, {"input": "100\r\n1\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n", "output": ["101 101"]}, {"input": "100\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n", "output": ["2 2"]}, {"input": "100\r\n2\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n50\r\n", "output": ["51 52"]}, {"input": "100\r\n300\r\n1\r\n1\r\n2\r\n2\r\n1\r\n2\r\n2\r\n2\r\n1\r\n2\r\n2\r\n2\r\n1\r\n2\r\n1\r\n1\r\n2\r\n2\r\n1\r\n1\r\n2\r\n1\r\n1\r\n2\r\n1\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n1\r\n1\r\n1\r\n2\r\n2\r\n2\r\n2\r\n1\r\n1\r\n1\r\n2\r\n1\r\n1\r\n2\r\n2\r\n2\r\n1\r\n2\r\n2\r\n2\r\n1\r\n2\r\n2\r\n1\r\n2\r\n1\r\n1\r\n2\r\n2\r\n2\r\n2\r\n1\r\n2\r\n2\r\n2\r\n1\r\n1\r\n2\r\n1\r\n1\r\n1\r\n1\r\n2\r\n2\r\n2\r\n2\r\n2\r\n1\r\n2\r\n1\r\n1\r\n1\r\n1\r\n2\r\n1\r\n1\r\n2\r\n2\r\n1\r\n2\r\n1\r\n1\r\n1\r\n2\r\n2\r\n93\r\n1\r\n2\r\n2\r\n", "output": ["93 393"]}, {"input": "100\r\n3000\r\n2\r\n4\r\n4\r\n5\r\n3\r\n3\r\n5\r\n5\r\n2\r\n4\r\n4\r\n2\r\n3\r\n1\r\n5\r\n5\r\n5\r\n3\r\n3\r\n1\r\n2\r\n2\r\n3\r\n3\r\n5\r\n5\r\n3\r\n5\r\n2\r\n1\r\n4\r\n4\r\n5\r\n3\r\n4\r\n3\r\n1\r\n3\r\n5\r\n1\r\n3\r\n3\r\n3\r\n5\r\n3\r\n4\r\n1\r\n3\r\n1\r\n5\r\n5\r\n5\r\n5\r\n3\r\n5\r\n5\r\n2\r\n1\r\n4\r\n2\r\n5\r\n1\r\n1\r\n5\r\n1\r\n3\r\n3\r\n1\r\n4\r\n2\r\n4\r\n3\r\n4\r\n4\r\n5\r\n2\r\n5\r\n95\r\n1\r\n2\r\n1\r\n2\r\n5\r\n3\r\n3\r\n2\r\n3\r\n4\r\n2\r\n3\r\n3\r\n2\r\n3\r\n4\r\n4\r\n4\r\n4\r\n3\r\n3\r\n2\r\n", "output": ["95 3095"]}, {"input": "100\r\n10000\r\n51\r\n53\r\n53\r\n54\r\n52\r\n52\r\n51\r\n53\r\n52\r\n55\r\n53\r\n51\r\n56\r\n55\r\n55\r\n50\r\n53\r\n53\r\n50\r\n52\r\n53\r\n50\r\n51\r\n56\r\n54\r\n50\r\n53\r\n51\r\n54\r\n50\r\n50\r\n55\r\n50\r\n53\r\n52\r\n52\r\n54\r\n56\r\n56\r\n52\r\n54\r\n56\r\n52\r\n52\r\n55\r\n54\r\n56\r\n53\r\n54\r\n53\r\n55\r\n50\r\n55\r\n54\r\n54\r\n56\r\n50\r\n50\r\n56\r\n55\r\n55\r\n53\r\n52\r\n54\r\n52\r\n53\r\n50\r\n53\r\n54\r\n52\r\n53\r\n52\r\n52\r\n56\r\n51\r\n53\r\n53\r\n55\r\n50\r\n50\r\n51\r\n55\r\n55\r\n51\r\n50\r\n51\r\n50\r\n54\r\n93\r\n50\r\n50\r\n55\r\n55\r\n50\r\n54\r\n55\r\n55\r\n53\r\n53\r\n56\r\n", "output": ["154 10093"]}, {"input": "100\r\n2325\r\n30\r\n18\r\n24\r\n24\r\n23\r\n23\r\n18\r\n28\r\n26\r\n28\r\n29\r\n23\r\n22\r\n19\r\n26\r\n26\r\n29\r\n20\r\n26\r\n30\r\n30\r\n26\r\n27\r\n25\r\n24\r\n25\r\n27\r\n22\r\n22\r\n19\r\n23\r\n22\r\n25\r\n27\r\n25\r\n21\r\n25\r\n26\r\n22\r\n20\r\n29\r\n21\r\n21\r\n22\r\n26\r\n29\r\n18\r\n22\r\n19\r\n23\r\n29\r\n30\r\n25\r\n22\r\n24\r\n30\r\n22\r\n23\r\n22\r\n26\r\n24\r\n19\r\n27\r\n20\r\n27\r\n29\r\n30\r\n22\r\n30\r\n26\r\n22\r\n19\r\n23\r\n20\r\n21\r\n26\r\n20\r\n30\r\n26\r\n24\r\n30\r\n20\r\n26\r\n24\r\n97\r\n25\r\n23\r\n19\r\n22\r\n19\r\n23\r\n29\r\n28\r\n28\r\n26\r\n29\r\n23\r\n26\r\n28\r\n20\r\n", "output": ["97 2422"]}, {"input": "100\r\n3241\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n93\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n10\r\n", "output": ["93 3334"]}, {"input": "100\r\n9675\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n99\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n", "output": ["99 9774"]}, {"input": "10\r\n1\r\n5\r\n5\r\n5\r\n5\r\n4\r\n5\r\n5\r\n5\r\n5\r\n5\r\n", "output": ["5 6"]}, {"input": "100\r\n9435\r\n15\r\n16\r\n21\r\n24\r\n22\r\n27\r\n24\r\n18\r\n26\r\n25\r\n17\r\n25\r\n14\r\n26\r\n15\r\n20\r\n17\r\n21\r\n17\r\n24\r\n26\r\n26\r\n27\r\n21\r\n24\r\n20\r\n26\r\n25\r\n25\r\n20\r\n22\r\n19\r\n14\r\n16\r\n17\r\n27\r\n16\r\n21\r\n16\r\n27\r\n21\r\n14\r\n24\r\n27\r\n24\r\n19\r\n25\r\n23\r\n21\r\n19\r\n16\r\n14\r\n25\r\n18\r\n96\r\n25\r\n24\r\n15\r\n20\r\n21\r\n22\r\n15\r\n24\r\n23\r\n14\r\n22\r\n26\r\n26\r\n16\r\n17\r\n23\r\n17\r\n25\r\n22\r\n21\r\n27\r\n26\r\n19\r\n25\r\n25\r\n23\r\n16\r\n25\r\n19\r\n15\r\n19\r\n18\r\n27\r\n17\r\n21\r\n25\r\n20\r\n27\r\n14\r\n26\r\n15\r\n27\r\n15\r\n24\r\n18\r\n", "output": ["117 9531"]}, {"input": "100\r\n9999\r\n1\r\n10\r\n5\r\n2\r\n9\r\n2\r\n10\r\n10\r\n9\r\n6\r\n10\r\n8\r\n10\r\n2\r\n10\r\n8\r\n5\r\n4\r\n8\r\n6\r\n3\r\n4\r\n8\r\n6\r\n1\r\n3\r\n8\r\n8\r\n7\r\n7\r\n5\r\n3\r\n2\r\n8\r\n4\r\n3\r\n7\r\n9\r\n9\r\n10\r\n7\r\n1\r\n10\r\n6\r\n2\r\n8\r\n7\r\n4\r\n3\r\n5\r\n9\r\n1\r\n10\r\n3\r\n4\r\n10\r\n1\r\n7\r\n1\r\n91\r\n10\r\n4\r\n7\r\n6\r\n4\r\n3\r\n2\r\n6\r\n3\r\n5\r\n5\r\n2\r\n3\r\n3\r\n1\r\n10\r\n10\r\n7\r\n10\r\n7\r\n8\r\n4\r\n6\r\n6\r\n1\r\n10\r\n2\r\n9\r\n6\r\n5\r\n1\r\n10\r\n8\r\n2\r\n10\r\n7\r\n8\r\n5\r\n3\r\n6\r\n", "output": ["107 10090"]}, {"input": "100\r\n2344\r\n23\r\n10\r\n18\r\n15\r\n32\r\n22\r\n10\r\n38\r\n32\r\n31\r\n39\r\n8\r\n26\r\n16\r\n22\r\n10\r\n23\r\n11\r\n25\r\n36\r\n24\r\n40\r\n7\r\n27\r\n43\r\n28\r\n23\r\n25\r\n7\r\n23\r\n22\r\n7\r\n43\r\n6\r\n22\r\n38\r\n7\r\n32\r\n35\r\n12\r\n41\r\n43\r\n97\r\n3\r\n37\r\n29\r\n27\r\n36\r\n17\r\n2\r\n27\r\n35\r\n16\r\n10\r\n3\r\n19\r\n12\r\n20\r\n29\r\n7\r\n14\r\n5\r\n31\r\n26\r\n10\r\n4\r\n3\r\n15\r\n32\r\n42\r\n24\r\n36\r\n41\r\n43\r\n36\r\n23\r\n14\r\n32\r\n3\r\n32\r\n21\r\n30\r\n32\r\n25\r\n32\r\n8\r\n27\r\n11\r\n19\r\n15\r\n34\r\n12\r\n41\r\n11\r\n39\r\n20\r\n14\r\n23\r\n7\r\n43\r\n", "output": ["97 2441"]}, {"input": "2\r\n1\r\n5\r\n1\r\n", "output": ["5 6"]}, {"input": "4\r\n1\r\n1\r\n9\r\n9\r\n9\r\n", "output": ["9 10"]}, {"input": "2\r\n3\r\n1\r\n100\r\n", "output": ["100 103"]}, {"input": "2\r\n16\r\n2\r\n100\r\n", "output": ["100 116"]}, {"input": "2\r\n1\r\n1\r\n100\r\n", "output": ["100 101"]}, {"input": "3\r\n7\r\n1\r\n6\r\n1\r\n", "output": ["6 13"]}, {"input": "2\r\n1\r\n10\r\n1\r\n", "output": ["10 11"]}, {"input": "3\r\n1\r\n1\r\n1\r\n99\r\n", "output": ["99 100"]}, {"input": "2\r\n2\r\n1\r\n100\r\n", "output": ["100 102"]}]
100
100
100
[{'input': '100\r\n8000\r\n88\r\n40\r\n39\r\n88\r\n33\r\n2\r\n60\r\n93\r\n62\r\n18\r\n44\r\n53\r\n79\r\n55\r\n34\r\n71\r\n45\r\n82\r\n97\r\n96\r\n96\r\n25\r\n83\r\n83\r\n54\r\n45\r\n47\r\n59\r\n94\r\n84\r\n12\r\n33\r\n97\r\n24\r\n71\r\n28\r\n81\r\n89\r\n52\r\n87\r\n96\r\n35\r\n34\r\n31\r\n45\r\n42\r\n14\r\n74\r\n8\r\n68\r\n61\r\n36\r\n65\r\n87\r\n31\r\n18\r\n38\r\n84\r\n28\r\n74\r\n98\r\n77\r\n15\r\n85\r\n82\r\n64\r\n2\r\n93\r\n31\r\n78\r\n64\r\n35\r\n6\r\n77\r\n55\r\n70\r\n83\r\n42\r\n98\r\n38\r\n59\r\n99\r\n27\r\n66\r\n10\r\n54\r\n22\r\n94\r\n21\r\n21\r\n89\r\n86\r\n73\r\n12\r\n86\r\n1\r\n98\r\n94\r\n48\r\n51\r\n', 'output': ['137 8099']}, {'input': '100\r\n9990\r\n22\r\n89\r\n54\r\n55\r\n92\r\n20\r\n84\r\n12\r\n93\r\n6\r\n73\r\n50\r\n23\r\n62\r\n97\r\n88\r\n59\r\n87\r\n4\r\n14\r\n49\r\n28\r\n47\r\n93\r\n5\r\n36\r\n50\r\n78\r\n83\r\n99\r\n100\r\n27\r\n24\r\n23\r\n27\r\n84\r\n67\r\n72\r\n45\r\n51\r\n53\r\n32\r\n60\r\n9\r\n77\r\n63\r\n15\r\n98\r\n17\r\n49\r\n58\r\n77\r\n50\r\n31\r\n10\r\n6\r\n16\r\n74\r\n50\r\n99\r\n100\r\n36\r\n51\r\n71\r\n89\r\n65\r\n17\r\n62\r\n32\r\n3\r\n25\r\n39\r\n19\r\n2\r\n25\r\n75\r\n25\r\n89\r\n87\r\n13\r\n96\r\n91\r\n10\r\n1\r\n94\r\n39\r\n10\r\n64\r\n26\r\n28\r\n32\r\n7\r\n16\r\n34\r\n96\r\n28\r\n24\r\n35\r\n82\r\n99\r\n', 'output': ['150 10090']}, {'input': '2\r\n2\r\n1\r\n100\r\n', 'output': ['100 102']}, {'input': '66\r\n1000\r\n27\r\n10\r\n63\r\n17\r\n28\r\n89\r\n34\r\n86\r\n27\r\n62\r\n26\r\n18\r\n25\r\n31\r\n45\r\n44\r\n92\r\n56\r\n47\r\n18\r\n53\r\n56\r\n79\r\n3\r\n9\r\n32\r\n88\r\n52\r\n21\r\n57\r\n97\r\n84\r\n50\r\n12\r\n6\r\n52\r\n21\r\n37\r\n24\r\n84\r\n44\r\n81\r\n41\r\n47\r\n7\r\n67\r\n93\r\n43\r\n100\r\n64\r\n82\r\n46\r\n28\r\n48\r\n1\r\n34\r\n28\r\n82\r\n15\r\n47\r\n1\r\n19\r\n34\r\n12\r\n48\r\n48\r\n', 'output': ['100 1100']}, {'input': '100\r\n1000\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n', 'output': ['11 1001']}]
[{'input': '100\r\n10000\r\n54\r\n54\r\n50\r\n52\r\n55\r\n51\r\n50\r\n53\r\n50\r\n56\r\n50\r\n51\r\n51\r\n52\r\n54\r\n50\r\n54\r\n52\r\n53\r\n56\r\n55\r\n51\r\n52\r\n55\r\n56\r\n52\r\n52\r\n56\r\n51\r\n56\r\n51\r\n51\r\n55\r\n54\r\n52\r\n55\r\n51\r\n55\r\n56\r\n54\r\n55\r\n54\r\n56\r\n56\r\n51\r\n52\r\n52\r\n56\r\n51\r\n52\r\n52\r\n55\r\n53\r\n51\r\n55\r\n51\r\n54\r\n52\r\n56\r\n51\r\n50\r\n52\r\n52\r\n55\r\n53\r\n52\r\n53\r\n53\r\n51\r\n52\r\n54\r\n50\r\n53\r\n53\r\n56\r\n52\r\n52\r\n54\r\n54\r\n52\r\n55\r\n53\r\n54\r\n53\r\n54\r\n55\r\n56\r\n51\r\n54\r\n55\r\n50\r\n56\r\n52\r\n50\r\n55\r\n55\r\n54\r\n55\r\n50\r\n50\r\n', 'output': ['154 10056']}, {'input': '1\r\n10\r\n5\r\n', 'output': ['15 15']}, {'input': '100\r\n3000\r\n99\r\n100\r\n99\r\n99\r\n100\r\n99\r\n100\r\n99\r\n99\r\n100\r\n99\r\n100\r\n100\r\n99\r\n100\r\n100\r\n99\r\n99\r\n99\r\n100\r\n100\r\n100\r\n100\r\n100\r\n99\r\n100\r\n100\r\n99\r\n100\r\n100\r\n99\r\n99\r\n99\r\n99\r\n100\r\n100\r\n99\r\n99\r\n99\r\n100\r\n99\r\n100\r\n100\r\n99\r\n99\r\n100\r\n100\r\n100\r\n99\r\n99\r\n99\r\n100\r\n99\r\n99\r\n99\r\n100\r\n99\r\n99\r\n100\r\n99\r\n100\r\n100\r\n100\r\n99\r\n99\r\n100\r\n100\r\n100\r\n99\r\n100\r\n100\r\n99\r\n99\r\n100\r\n100\r\n99\r\n100\r\n100\r\n100\r\n99\r\n99\r\n100\r\n100\r\n99\r\n100\r\n99\r\n99\r\n100\r\n99\r\n99\r\n99\r\n100\r\n99\r\n100\r\n100\r\n100\r\n99\r\n100\r\n99\r\n100\r\n', 'output': ['130 3100']}, {'input': '100\r\n2325\r\n78\r\n78\r\n80\r\n78\r\n79\r\n80\r\n79\r\n80\r\n79\r\n80\r\n78\r\n80\r\n79\r\n80\r\n78\r\n78\r\n79\r\n80\r\n80\r\n80\r\n79\r\n79\r\n79\r\n79\r\n80\r\n80\r\n79\r\n80\r\n79\r\n80\r\n79\r\n79\r\n79\r\n79\r\n80\r\n80\r\n80\r\n78\r\n80\r\n80\r\n80\r\n78\r\n80\r\n80\r\n80\r\n80\r\n78\r\n78\r\n79\r\n79\r\n79\r\n79\r\n80\r\n78\r\n80\r\n78\r\n80\r\n80\r\n80\r\n79\r\n78\r\n79\r\n80\r\n80\r\n78\r\n78\r\n80\r\n78\r\n80\r\n79\r\n78\r\n80\r\n78\r\n78\r\n80\r\n80\r\n78\r\n78\r\n79\r\n78\r\n78\r\n79\r\n79\r\n78\r\n80\r\n78\r\n78\r\n80\r\n80\r\n80\r\n78\r\n80\r\n78\r\n79\r\n80\r\n78\r\n80\r\n79\r\n78\r\n79\r\n', 'output': ['103 2405']}, {'input': '100\r\n2325\r\n30\r\n18\r\n24\r\n24\r\n23\r\n23\r\n18\r\n28\r\n26\r\n28\r\n29\r\n23\r\n22\r\n19\r\n26\r\n26\r\n29\r\n20\r\n26\r\n30\r\n30\r\n26\r\n27\r\n25\r\n24\r\n25\r\n27\r\n22\r\n22\r\n19\r\n23\r\n22\r\n25\r\n27\r\n25\r\n21\r\n25\r\n26\r\n22\r\n20\r\n29\r\n21\r\n21\r\n22\r\n26\r\n29\r\n18\r\n22\r\n19\r\n23\r\n29\r\n30\r\n25\r\n22\r\n24\r\n30\r\n22\r\n23\r\n22\r\n26\r\n24\r\n19\r\n27\r\n20\r\n27\r\n29\r\n30\r\n22\r\n30\r\n26\r\n22\r\n19\r\n23\r\n20\r\n21\r\n26\r\n20\r\n30\r\n26\r\n24\r\n30\r\n20\r\n26\r\n24\r\n97\r\n25\r\n23\r\n19\r\n22\r\n19\r\n23\r\n29\r\n28\r\n28\r\n26\r\n29\r\n23\r\n26\r\n28\r\n20\r\n', 'output': ['97 2422']}]
[{'input': '100\r\n9990\r\n22\r\n89\r\n54\r\n55\r\n92\r\n20\r\n84\r\n12\r\n93\r\n6\r\n73\r\n50\r\n23\r\n62\r\n97\r\n88\r\n59\r\n87\r\n4\r\n14\r\n49\r\n28\r\n47\r\n93\r\n5\r\n36\r\n50\r\n78\r\n83\r\n99\r\n100\r\n27\r\n24\r\n23\r\n27\r\n84\r\n67\r\n72\r\n45\r\n51\r\n53\r\n32\r\n60\r\n9\r\n77\r\n63\r\n15\r\n98\r\n17\r\n49\r\n58\r\n77\r\n50\r\n31\r\n10\r\n6\r\n16\r\n74\r\n50\r\n99\r\n100\r\n36\r\n51\r\n71\r\n89\r\n65\r\n17\r\n62\r\n32\r\n3\r\n25\r\n39\r\n19\r\n2\r\n25\r\n75\r\n25\r\n89\r\n87\r\n13\r\n96\r\n91\r\n10\r\n1\r\n94\r\n39\r\n10\r\n64\r\n26\r\n28\r\n32\r\n7\r\n16\r\n34\r\n96\r\n28\r\n24\r\n35\r\n82\r\n99\r\n', 'output': ['150 10090']}, {'input': '3\r\n100\r\n52\r\n2\r\n2\r\n', 'output': ['52 152']}, {'input': '100\r\n1000\r\n91\r\n17\r\n88\r\n51\r\n92\r\n47\r\n85\r\n3\r\n82\r\n61\r\n2\r\n48\r\n55\r\n56\r\n71\r\n1\r\n12\r\n78\r\n80\r\n31\r\n42\r\n33\r\n85\r\n99\r\n25\r\n25\r\n37\r\n18\r\n29\r\n53\r\n84\r\n88\r\n4\r\n55\r\n24\r\n3\r\n53\r\n53\r\n1\r\n95\r\n36\r\n84\r\n65\r\n5\r\n40\r\n52\r\n49\r\n77\r\n48\r\n5\r\n77\r\n50\r\n31\r\n80\r\n100\r\n46\r\n28\r\n29\r\n34\r\n83\r\n26\r\n3\r\n100\r\n63\r\n100\r\n23\r\n76\r\n4\r\n70\r\n57\r\n10\r\n58\r\n7\r\n20\r\n84\r\n44\r\n86\r\n54\r\n2\r\n11\r\n85\r\n3\r\n35\r\n83\r\n96\r\n97\r\n55\r\n75\r\n39\r\n39\r\n39\r\n61\r\n19\r\n86\r\n76\r\n72\r\n29\r\n69\r\n20\r\n17\r\n', 'output': ['100 1100']}, {'input': '100\r\n2344\r\n42\r\n40\r\n69\r\n62\r\n79\r\n43\r\n36\r\n55\r\n44\r\n13\r\n48\r\n69\r\n46\r\n61\r\n70\r\n75\r\n51\r\n67\r\n57\r\n35\r\n5\r\n19\r\n6\r\n92\r\n78\r\n59\r\n42\r\n3\r\n81\r\n41\r\n70\r\n90\r\n99\r\n93\r\n44\r\n22\r\n80\r\n62\r\n69\r\n95\r\n12\r\n63\r\n99\r\n42\r\n12\r\n9\r\n72\r\n8\r\n19\r\n33\r\n81\r\n33\r\n66\r\n32\r\n10\r\n50\r\n98\r\n83\r\n11\r\n25\r\n81\r\n13\r\n56\r\n60\r\n4\r\n89\r\n75\r\n59\r\n92\r\n7\r\n55\r\n84\r\n48\r\n85\r\n82\r\n18\r\n29\r\n68\r\n60\r\n25\r\n26\r\n37\r\n12\r\n15\r\n27\r\n17\r\n85\r\n20\r\n16\r\n47\r\n76\r\n55\r\n75\r\n66\r\n47\r\n98\r\n90\r\n32\r\n47\r\n9\r\n', 'output': ['99 2443']}, {'input': '90\r\n10000\r\n43\r\n85\r\n87\r\n11\r\n50\r\n66\r\n30\r\n90\r\n23\r\n22\r\n16\r\n20\r\n2\r\n60\r\n8\r\n26\r\n56\r\n89\r\n50\r\n40\r\n3\r\n23\r\n9\r\n66\r\n36\r\n85\r\n19\r\n49\r\n87\r\n97\r\n20\r\n23\r\n75\r\n32\r\n3\r\n38\r\n71\r\n54\r\n79\r\n46\r\n62\r\n27\r\n16\r\n2\r\n24\r\n55\r\n76\r\n83\r\n55\r\n47\r\n46\r\n41\r\n63\r\n30\r\n22\r\n84\r\n70\r\n81\r\n59\r\n44\r\n56\r\n23\r\n67\r\n9\r\n60\r\n54\r\n95\r\n36\r\n73\r\n60\r\n33\r\n20\r\n18\r\n67\r\n20\r\n18\r\n7\r\n65\r\n55\r\n54\r\n45\r\n32\r\n38\r\n52\r\n15\r\n15\r\n88\r\n44\r\n47\r\n88\r\n', 'output': ['157 10097']}]
[{'input': '2\r\n2\r\n1\r\n100\r\n', 'output': ['100 102']}, {'input': '2\r\n3\r\n1\r\n100\r\n', 'output': ['100 103']}, {'input': '10\r\n1\r\n3\r\n3\r\n2\r\n3\r\n3\r\n3\r\n3\r\n3\r\n3\r\n3\r\n', 'output': ['3 4']}, {'input': '10\r\n10\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n', 'output': ['2 11']}, {'input': '100\r\n1\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n', 'output': ['101 101']}]
[{'input': '40\r\n10000\r\n54\r\n5\r\n23\r\n10\r\n10\r\n77\r\n15\r\n84\r\n92\r\n63\r\n34\r\n21\r\n12\r\n56\r\n25\r\n32\r\n28\r\n50\r\n50\r\n86\r\n3\r\n26\r\n39\r\n69\r\n43\r\n99\r\n71\r\n38\r\n15\r\n33\r\n50\r\n79\r\n54\r\n84\r\n33\r\n47\r\n14\r\n66\r\n99\r\n25\r\n', 'output': ['296 10099']}, {'input': '10\r\n10\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n', 'output': ['2 11']}, {'input': '10\r\n1\r\n5\r\n5\r\n5\r\n5\r\n4\r\n5\r\n5\r\n5\r\n5\r\n5\r\n', 'output': ['5 6']}, {'input': '100\r\n50\r\n20\r\n63\r\n60\r\n88\r\n7\r\n22\r\n90\r\n15\r\n27\r\n82\r\n37\r\n44\r\n42\r\n50\r\n33\r\n46\r\n7\r\n97\r\n93\r\n5\r\n68\r\n79\r\n76\r\n3\r\n82\r\n5\r\n51\r\n79\r\n17\r\n1\r\n1\r\n93\r\n52\r\n88\r\n23\r\n23\r\n49\r\n86\r\n64\r\n18\r\n36\r\n53\r\n49\r\n47\r\n11\r\n19\r\n6\r\n79\r\n64\r\n59\r\n56\r\n96\r\n15\r\n72\r\n81\r\n45\r\n24\r\n55\r\n31\r\n2\r\n74\r\n64\r\n57\r\n65\r\n71\r\n44\r\n8\r\n7\r\n38\r\n50\r\n67\r\n1\r\n79\r\n89\r\n16\r\n35\r\n10\r\n72\r\n69\r\n8\r\n56\r\n42\r\n44\r\n95\r\n25\r\n26\r\n16\r\n84\r\n36\r\n73\r\n17\r\n61\r\n91\r\n15\r\n19\r\n78\r\n44\r\n77\r\n96\r\n58\r\n', 'output': ['97 147']}, {'input': '1\r\n10\r\n5\r\n', 'output': ['15 15']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
113
100
100
100
["2"]
The only line of the input contains a single integer n (2 ≤ n ≤ 2·1018) — the power in which you need to raise number 5.
dcaff75492eafaf61d598779d6202c9d
#include <iostream> int main(){std::cout<<"25\n";return 0;} //1534
["25"]
C++
null
Output the last two digits of 5n without spaces between them.
The HR manager was disappointed again. The last applicant failed the interview the same way as 24 previous ones. "Do I give such a hard task?" — the HR manager thought. "Just raise number 5 to the power of n and get last two digits of the number. Yes, of course, n can be rather big, and one cannot find the power using a calculator, but we need people who are able to think, not just follow the instructions."Could you pass the interview in the machine vision company in IT City?
[{"input": "2\r\n", "output": ["25"]}, {"input": "7\r\n", "output": ["25"]}, {"input": "1000000000000000000\r\n", "output": ["25"]}, {"input": "2000000000000000000\r\n", "output": ["25"]}, {"input": "987654321012345678\r\n", "output": ["25"]}]
100
100
100
[{'input': '2\r\n', 'output': ['25']}, {'input': '1000000000000000000\r\n', 'output': ['25']}, {'input': '7\r\n', 'output': ['25']}, {'input': '987654321012345678\r\n', 'output': ['25']}, {'input': '2000000000000000000\r\n', 'output': ['25']}]
[{'input': '7\r\n', 'output': ['25']}, {'input': '2\r\n', 'output': ['25']}, {'input': '987654321012345678\r\n', 'output': ['25']}, {'input': '2000000000000000000\r\n', 'output': ['25']}, {'input': '1000000000000000000\r\n', 'output': ['25']}]
[{'input': '2\r\n', 'output': ['25']}, {'input': '1000000000000000000\r\n', 'output': ['25']}, {'input': '2000000000000000000\r\n', 'output': ['25']}, {'input': '987654321012345678\r\n', 'output': ['25']}, {'input': '7\r\n', 'output': ['25']}]
[{'input': '987654321012345678\r\n', 'output': ['25']}, {'input': '7\r\n', 'output': ['25']}, {'input': '2000000000000000000\r\n', 'output': ['25']}, {'input': '1000000000000000000\r\n', 'output': ['25']}, {'input': '2\r\n', 'output': ['25']}]
[{'input': '7\r\n', 'output': ['25']}, {'input': '1000000000000000000\r\n', 'output': ['25']}, {'input': '2\r\n', 'output': ['25']}, {'input': '987654321012345678\r\n', 'output': ['25']}, {'input': '2000000000000000000\r\n', 'output': ['25']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
114
100
100
100
["4 2 100000007"]
The first line of input will contain three integers n, k, p (1 ≤ n ≤ 250 000, 1 ≤ k ≤ 26, 108 ≤ p ≤ 109 + 100, p will be prime).
97f737f59100babe5e45e1a82a1f7d99
#include<iostream> #include<algorithm> #include<cstdio> #include<cstring> using namespace std; int n,k,p; int fpow(int a,int b) { int ans=1,t=a; while(b) { if(b&1)ans=1ll*ans*t%p; t=1ll*t*t%p;b>>=1; } return ans; } int lowbit(int x) { return x&(-x); } int f[26][250010]; int fac[250010],inv[250010]; void init() { fac[0]=1; for(int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%p; inv[n]=fpow(fac[n],p-2); for(int i=n;i>=1;i--) inv[i-1]=1ll*inv[i]*i%p; return ; } int solve(int cur,int S) { if(f[cur][S]!=-1) return f[cur][S]; if(!S){ f[cur][S]=fac[n]; for(int i=1;i<=cur;i++) f[cur][S]=1ll*f[cur][S]*(k-i+1)%p; return f[cur][S]; } f[cur][S]=0; int U=S-lowbit(S); for(int T=U;T;T=(T-1)&U) f[cur][S]=(f[cur][S]+1ll*inv[S-T]*solve(cur+1,T))%p; f[cur][S]=(f[cur][S]+1ll*inv[S]*solve(cur+1,0))%p; return f[cur][S]; } int main() { scanf("%d %d %d",&n,&k,&p); int ans=1; for(int i=1;i<=n;i++) ans=1ll*ans*k%p; if(n%2==0){ init(); memset(f,-1,sizeof(f)); ans=(ans-solve(0,n)+p)%p; } printf("%d\n",ans); return 0; }
["14"]
C++
NoteThere are 14 strings that that Alice can win with. For example, some strings are "bbaa" and "baaa". Alice will lose on strings like "aaaa" or "bbbb".
Print a single integer, the number of winning words for Alice, modulo p.
Alice and Bob are playing a game with a string of characters, with Alice going first. The string consists n characters, each of which is one of the first k letters of the alphabet. On a player’s turn, they can either arbitrarily permute the characters in the words, or delete exactly one character in the word (if there is at least one character). In addition, their resulting word cannot have appeared before throughout the entire game. The player unable to make a valid move loses the game.Given n, k, p, find the number of words with exactly n characters consisting of the first k letters of the alphabet such that Alice will win if both Alice and Bob play optimally. Return this number modulo the prime number p.
[{"input": "4 2 100000007\r\n", "output": ["14"]}, {"input": "1 10 100000007\r\n", "output": ["10"]}, {"input": "5 2 100000007\r\n", "output": ["32"]}, {"input": "4 1 100000007\r\n", "output": ["0"]}, {"input": "4 3 100000007\r\n", "output": ["78"]}, {"input": "6 3 100000007\r\n", "output": ["636"]}, {"input": "250000 26 419059819\r\n", "output": ["246743278"]}, {"input": "250000 21 159237107\r\n", "output": ["124744886"]}, {"input": "250000 16 690557993\r\n", "output": ["30969019"]}, {"input": "123456 26 330502547\r\n", "output": ["122021241"]}, {"input": "232154 3 893627789\r\n", "output": ["492780692"]}, {"input": "1312 25 425538233\r\n", "output": ["44177569"]}, {"input": "13132 14 457083337\r\n", "output": ["445627280"]}, {"input": "13131 14 625308461\r\n", "output": ["313277523"]}, {"input": "131070 26 550798649\r\n", "output": ["290693777"]}, {"input": "131070 15 724141441\r\n", "output": ["476164776"]}, {"input": "245758 26 147046169\r\n", "output": ["128006699"]}, {"input": "245758 15 662045771\r\n", "output": ["558307367"]}, {"input": "196606 21 576053623\r\n", "output": ["269130197"]}, {"input": "249999 25 399293347\r\n", "output": ["66102644"]}, {"input": "249998 22 318340733\r\n", "output": ["293011292"]}]
100
100
100
[{'input': '1 10 100000007\r\n', 'output': ['10']}, {'input': '232154 3 893627789\r\n', 'output': ['492780692']}, {'input': '250000 21 159237107\r\n', 'output': ['124744886']}, {'input': '250000 26 419059819\r\n', 'output': ['246743278']}, {'input': '13131 14 625308461\r\n', 'output': ['313277523']}]
[{'input': '249998 22 318340733\r\n', 'output': ['293011292']}, {'input': '4 3 100000007\r\n', 'output': ['78']}, {'input': '245758 15 662045771\r\n', 'output': ['558307367']}, {'input': '13132 14 457083337\r\n', 'output': ['445627280']}, {'input': '4 2 100000007\r\n', 'output': ['14']}]
[{'input': '4 3 100000007\r\n', 'output': ['78']}, {'input': '250000 26 419059819\r\n', 'output': ['246743278']}, {'input': '131070 15 724141441\r\n', 'output': ['476164776']}, {'input': '4 1 100000007\r\n', 'output': ['0']}, {'input': '4 2 100000007\r\n', 'output': ['14']}]
[{'input': '4 2 100000007\r\n', 'output': ['14']}, {'input': '245758 15 662045771\r\n', 'output': ['558307367']}, {'input': '232154 3 893627789\r\n', 'output': ['492780692']}, {'input': '249998 22 318340733\r\n', 'output': ['293011292']}, {'input': '1312 25 425538233\r\n', 'output': ['44177569']}]
[{'input': '4 3 100000007\r\n', 'output': ['78']}, {'input': '1312 25 425538233\r\n', 'output': ['44177569']}, {'input': '4 2 100000007\r\n', 'output': ['14']}, {'input': '6 3 100000007\r\n', 'output': ['636']}, {'input': '5 2 100000007\r\n', 'output': ['32']}]
100
100
100
100
100
100
100
100
100
100
100
95
95
95
100
115
100
100
97
["47", "16", "78"]
The single line contains an integer n (1 ≤ n ≤ 1000) — the number that needs to be checked.
78cf8bc7660dbd0602bf6e499bc6bb0d
#include <bits/stdc++.h> #define op cin.tie(0);ios_base::sync_with_stdio(0); using namespace std; int n; bool lucky(int x) { while(x) { if(x%10!= 4 && x%10!=7) return false; x/=10; } return true; } int main() { op cin>>n; for(int i=1;i<=n;i++) { if(n%i==0) { if(lucky(i)) { cout<<"YES"; return 0; } } } cout<<"NO"; return 0; }
["YES", "YES", "NO"]
C++
NoteNote that all lucky numbers are almost lucky as any number is evenly divisible by itself.In the first sample 47 is a lucky number. In the second sample 16 is divisible by 4.
In the only line print "YES" (without the quotes), if number n is almost lucky. Otherwise, print "NO" (without the quotes).
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya calls a number almost lucky if it could be evenly divided by some lucky number. Help him find out if the given number n is almost lucky.
[{"input": "47\r\n", "output": ["YES"]}, {"input": "16\r\n", "output": ["YES"]}, {"input": "78\r\n", "output": ["NO"]}, {"input": "48\r\n", "output": ["YES"]}, {"input": "100\r\n", "output": ["YES"]}, {"input": "107\r\n", "output": ["NO"]}, {"input": "77\r\n", "output": ["YES"]}, {"input": "477\r\n", "output": ["YES"]}, {"input": "480\r\n", "output": ["YES"]}, {"input": "1\r\n", "output": ["NO"]}, {"input": "3\r\n", "output": ["NO"]}, {"input": "4\r\n", "output": ["YES"]}, {"input": "49\r\n", "output": ["YES"]}, {"input": "56\r\n", "output": ["YES"]}, {"input": "124\r\n", "output": ["YES"]}, {"input": "1000\r\n", "output": ["YES"]}, {"input": "999\r\n", "output": ["NO"]}, {"input": "298\r\n", "output": ["NO"]}, {"input": "274\r\n", "output": ["NO"]}, {"input": "998\r\n", "output": ["NO"]}, {"input": "42\r\n", "output": ["YES"]}, {"input": "788\r\n", "output": ["YES"]}, {"input": "70\r\n", "output": ["YES"]}, {"input": "444\r\n", "output": ["YES"]}, {"input": "777\r\n", "output": ["YES"]}, {"input": "799\r\n", "output": ["YES"]}, {"input": "25\r\n", "output": ["NO"]}, {"input": "882\r\n", "output": ["YES"]}, {"input": "88\r\n", "output": ["YES"]}, {"input": "11\r\n", "output": ["NO"]}, {"input": "2\r\n", "output": ["NO"]}, {"input": "7\r\n", "output": ["YES"]}, {"input": "8\r\n", "output": ["YES"]}, {"input": "94\r\n", "output": ["YES"]}, {"input": "141\r\n", "output": ["YES"]}]
100
100
100
[{'input': '1\r\n', 'output': ['NO']}, {'input': '999\r\n', 'output': ['NO']}, {'input': '1000\r\n', 'output': ['YES']}, {'input': '94\r\n', 'output': ['YES']}, {'input': '444\r\n', 'output': ['YES']}]
[{'input': '78\r\n', 'output': ['NO']}, {'input': '56\r\n', 'output': ['YES']}, {'input': '8\r\n', 'output': ['YES']}, {'input': '3\r\n', 'output': ['NO']}, {'input': '42\r\n', 'output': ['YES']}]
[{'input': '1000\r\n', 'output': ['YES']}, {'input': '88\r\n', 'output': ['YES']}, {'input': '1\r\n', 'output': ['NO']}, {'input': '70\r\n', 'output': ['YES']}, {'input': '298\r\n', 'output': ['NO']}]
[{'input': '49\r\n', 'output': ['YES']}, {'input': '70\r\n', 'output': ['YES']}, {'input': '999\r\n', 'output': ['NO']}, {'input': '2\r\n', 'output': ['NO']}, {'input': '788\r\n', 'output': ['YES']}]
[{'input': '4\r\n', 'output': ['YES']}, {'input': '7\r\n', 'output': ['YES']}, {'input': '88\r\n', 'output': ['YES']}, {'input': '298\r\n', 'output': ['NO']}, {'input': '77\r\n', 'output': ['YES']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
116
100
100
100
["6 4 3 1", "9 3 8 10"]
The first line contains four space-separated integers n, x, y, c (1 ≤ n, c ≤ 109; 1 ≤ x, y ≤ n; c ≤ n2).
232c5206ee7c1903556c3625e0b0efc6
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n, x, y, c; bool ok(ll t) { ll res = 0; ll rowl = max(1ll, y - t), rowh = min(n, y + t); for (ll row = rowl; row <= rowh; row++) { ll tt = t - abs(y - row); ll coll = max(1ll, x - tt), colh = min(n, x + tt); res += colh - coll + 1; if (res >= c) return 1; } return 0; } int main() { cin >> n >> x >> y >> c; ll lo = 0, hi = 2 * n, mid; while (lo <= hi) { mid = (lo + hi) / 2; if (ok(mid)) hi = mid - 1; else lo = mid + 1; } cout << lo << endl; return 0; }
["0", "2"]
C++
NoteInitially the first test has one painted cell, so the answer is 0. In the second test all events will go as is shown on the figure. .
In a single line print a single integer — the answer to the problem.
Mr. Bender has a digital table of size n × n, each cell can be switched on or off. He wants the field to have at least c switched on squares. When this condition is fulfilled, Mr Bender will be happy.We'll consider the table rows numbered from top to bottom from 1 to n, and the columns — numbered from left to right from 1 to n. Initially there is exactly one switched on cell with coordinates (x, y) (x is the row number, y is the column number), and all other cells are switched off. Then each second we switch on the cells that are off but have the side-adjacent cells that are on.For a cell with coordinates (x, y) the side-adjacent cells are cells with coordinates (x - 1, y), (x + 1, y), (x, y - 1), (x, y + 1).In how many seconds will Mr. Bender get happy?
[{"input": "6 4 3 1\r\n", "output": ["0"]}, {"input": "9 3 8 10\r\n", "output": ["2"]}, {"input": "9 4 3 10\r\n", "output": ["2"]}, {"input": "9 8 2 10\r\n", "output": ["2"]}, {"input": "1 1 1 1\r\n", "output": ["0"]}, {"input": "10 7 2 7\r\n", "output": ["2"]}, {"input": "8 2 6 10\r\n", "output": ["2"]}, {"input": "8 1 2 10\r\n", "output": ["3"]}, {"input": "6 1 4 10\r\n", "output": ["3"]}, {"input": "1000000 951981 612086 60277\r\n", "output": ["174"]}, {"input": "1000000 587964 232616 62357\r\n", "output": ["177"]}, {"input": "1000000 948438 69861 89178\r\n", "output": ["211"]}, {"input": "1000000000 504951981 646612086 602763371\r\n", "output": ["17360"]}, {"input": "1000000000 81587964 595232616 623563697\r\n", "output": ["17657"]}, {"input": "1000000000 55 60 715189365\r\n", "output": ["37707"]}, {"input": "1000000000 85 61 857945620\r\n", "output": ["41279"]}, {"input": "1000000000 55 85 423654797\r\n", "output": ["28970"]}, {"input": "1000000000 63 65 384381709\r\n", "output": ["27600"]}, {"input": "1000000000 44 30 891773002\r\n", "output": ["42159"]}, {"input": "1000000000 6 97 272656295\r\n", "output": ["23250"]}, {"input": "1000000000 999999946 999999941 715189365\r\n", "output": ["37707"]}, {"input": "1000000000 999999916 999999940 857945620\r\n", "output": ["41279"]}, {"input": "1000000000 999999946 999999916 423654797\r\n", "output": ["28970"]}, {"input": "1000000000 999999938 999999936 384381709\r\n", "output": ["27600"]}, {"input": "1000000000 55 999999941 715189365\r\n", "output": ["37707"]}, {"input": "1000000000 85 999999940 857945620\r\n", "output": ["41279"]}, {"input": "1000000000 55 999999916 423654797\r\n", "output": ["28970"]}, {"input": "1000000000 63 999999936 384381709\r\n", "output": ["27600"]}, {"input": "1000000000 44 999999971 891773002\r\n", "output": ["42159"]}, {"input": "1000000000 6 999999904 272656295\r\n", "output": ["23250"]}, {"input": "1000000000 999999946 60 715189365\r\n", "output": ["37707"]}, {"input": "1000000000 999999916 61 857945620\r\n", "output": ["41279"]}, {"input": "1000000000 999999946 85 423654797\r\n", "output": ["28970"]}, {"input": "1000000000 999999938 65 384381709\r\n", "output": ["27600"]}, {"input": "1000000000 999999957 30 891773002\r\n", "output": ["42159"]}, {"input": "548813503 532288332 26800940 350552333\r\n", "output": ["13239"]}, {"input": "847251738 695702891 698306947 648440371\r\n", "output": ["18006"]}, {"input": "891773002 152235342 682786380 386554406\r\n", "output": ["13902"]}, {"input": "812168727 57791401 772019566 644719499\r\n", "output": ["17954"]}, {"input": "71036059 25478942 38920202 19135721\r\n", "output": ["3093"]}, {"input": "549 198 8 262611\r\n", "output": ["635"]}, {"input": "848 409 661 620581\r\n", "output": ["771"]}, {"input": "892 364 824 53858\r\n", "output": ["183"]}, {"input": "813 154 643 141422\r\n", "output": ["299"]}, {"input": "72 40 68 849\r\n", "output": ["25"]}, {"input": "958 768 649 298927\r\n", "output": ["431"]}, {"input": "800 305 317 414868\r\n", "output": ["489"]}, {"input": "721 112 687 232556\r\n", "output": ["556"]}, {"input": "522 228 495 74535\r\n", "output": ["249"]}, {"input": "737 231 246 79279\r\n", "output": ["199"]}, {"input": "6 4 3 36\r\n", "output": ["6"]}, {"input": "9 3 8 55\r\n", "output": ["7"]}, {"input": "9 4 3 73\r\n", "output": ["8"]}, {"input": "9 8 2 50\r\n", "output": ["7"]}, {"input": "1 1 1 1\r\n", "output": ["0"]}, {"input": "10 7 2 7\r\n", "output": ["2"]}, {"input": "8 2 6 20\r\n", "output": ["3"]}, {"input": "8 1 2 64\r\n", "output": ["13"]}, {"input": "6 1 4 15\r\n", "output": ["3"]}, {"input": "8 8 3 1\r\n", "output": ["0"]}]
100
100
100
[{'input': '1000000000 999999938 999999936 384381709\r\n', 'output': ['27600']}, {'input': '737 231 246 79279\r\n', 'output': ['199']}, {'input': '9 8 2 10\r\n', 'output': ['2']}, {'input': '847251738 695702891 698306947 648440371\r\n', 'output': ['18006']}, {'input': '10 7 2 7\r\n', 'output': ['2']}]
[{'input': '1000000000 999999938 65 384381709\r\n', 'output': ['27600']}, {'input': '1 1 1 1\r\n', 'output': ['0']}, {'input': '737 231 246 79279\r\n', 'output': ['199']}, {'input': '958 768 649 298927\r\n', 'output': ['431']}, {'input': '9 3 8 10\r\n', 'output': ['2']}]
[{'input': '1000000000 999999946 60 715189365\r\n', 'output': ['37707']}, {'input': '813 154 643 141422\r\n', 'output': ['299']}, {'input': '1000000000 6 97 272656295\r\n', 'output': ['23250']}, {'input': '737 231 246 79279\r\n', 'output': ['199']}, {'input': '9 3 8 55\r\n', 'output': ['7']}]
[{'input': '8 1 2 64\r\n', 'output': ['13']}, {'input': '10 7 2 7\r\n', 'output': ['2']}, {'input': '1 1 1 1\r\n', 'output': ['0']}, {'input': '71036059 25478942 38920202 19135721\r\n', 'output': ['3093']}, {'input': '8 8 3 1\r\n', 'output': ['0']}]
[{'input': '1 1 1 1\r\n', 'output': ['0']}, {'input': '9 8 2 50\r\n', 'output': ['7']}, {'input': '1000000000 999999946 999999916 423654797\r\n', 'output': ['28970']}, {'input': '1000000000 999999938 999999936 384381709\r\n', 'output': ['27600']}, {'input': '958 768 649 298927\r\n', 'output': ['431']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
117
100
100
100
["1", "2", "3"]
The only line contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$).
8218255989e5eab73ac7107072c3b2af
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; using pii = pair<int, int>; using vi = vector <int>; #define F first #define S second #define pb push_back #define lb lower_bound #define ub upper_bound #define ll long long #define ook order_of_key #define fbo find_by_order #define sq(x) (x) * (x) #define N 2005 ll n, dp[N][N], ans, mod = 1e9 + 7, sum[N]; int main (){ cin >> n; n *= 2; dp[0][0] = 1; for (int i = 0;i < n;i++) for (int j = 0;j <= n - i;j++){ sum[i] = (sum[i] + dp[i][j]) % mod; if (j) dp[i + 1][j - 1] = (dp[i + 1][j - 1] + dp[i][j]) % mod; dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % mod; } for (int i = n - 1;i >= 0;i -= 2) ans = (ans + sum[i]) % mod; cout << ans; }
["1", "3", "9"]
C++
NoteThe pictures below illustrate tries in the first two examples (for clarity, the round brackets are replaced with angle brackets). The maximum matching is highlighted with blue.  
Print exactly one integer — the size of the maximum matching in the trie. Since the answer can be quite large, print it modulo $$$10^9 + 7$$$.
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire bag of catnip into the toys...It took Neko an entire day to turn back to normal. Neko reported to Aki that he saw a lot of weird things, including a trie of all correct bracket sequences of length $$$2n$$$.The definition of correct bracket sequence is as follows: The empty sequence is a correct bracket sequence, If $$$s$$$ is a correct bracket sequence, then $$$(\,s\,)$$$ is a correct bracket sequence, If $$$s$$$ and $$$t$$$ are a correct bracket sequence, then $$$st$$$ is also a correct bracket sequence. For example, the strings "(())", "()()" form a correct bracket sequence, while ")(" and "((" not.Aki then came up with an interesting problem: What is the size of the maximum matching (the largest set of edges such that there are no two edges with a common vertex) in this trie? Since the answer can be quite large, print it modulo $$$10^9 + 7$$$.
[{"input": "1\r\n", "output": ["1"]}, {"input": "2\r\n", "output": ["3"]}, {"input": "3\r\n", "output": ["9"]}, {"input": "4\r\n", "output": ["27"]}, {"input": "5\r\n", "output": ["84"]}, {"input": "6\r\n", "output": ["270"]}, {"input": "7\r\n", "output": ["892"]}, {"input": "8\r\n", "output": ["3012"]}, {"input": "9\r\n", "output": ["10350"]}, {"input": "10\r\n", "output": ["36074"]}, {"input": "11\r\n", "output": ["127218"]}, {"input": "12\r\n", "output": ["453096"]}, {"input": "13\r\n", "output": ["1627377"]}, {"input": "14\r\n", "output": ["5887659"]}, {"input": "15\r\n", "output": ["21436353"]}, {"input": "450\r\n", "output": ["690479399"]}, {"input": "999\r\n", "output": ["742390865"]}, {"input": "1000\r\n", "output": ["143886430"]}, {"input": "16\r\n", "output": ["78484401"]}, {"input": "17\r\n", "output": ["288779727"]}, {"input": "18\r\n", "output": ["67263652"]}, {"input": "19\r\n", "output": ["960081882"]}, {"input": "20\r\n", "output": ["746806193"]}, {"input": "21\r\n", "output": ["94725532"]}, {"input": "22\r\n", "output": ["450571487"]}, {"input": "23\r\n", "output": ["724717660"]}, {"input": "24\r\n", "output": ["60828279"]}, {"input": "25\r\n", "output": ["569244761"]}, {"input": "26\r\n", "output": ["90251153"]}, {"input": "27\r\n", "output": ["304700019"]}, {"input": "28\r\n", "output": ["302293423"]}, {"input": "29\r\n", "output": ["541190422"]}, {"input": "30\r\n", "output": ["390449151"]}, {"input": "900\r\n", "output": ["454329300"]}, {"input": "500\r\n", "output": ["660474384"]}, {"input": "996\r\n", "output": ["666557857"]}, {"input": "997\r\n", "output": ["62038986"]}, {"input": "998\r\n", "output": ["311781222"]}]
100
100
100
[{'input': '10\r\n', 'output': ['36074']}, {'input': '16\r\n', 'output': ['78484401']}, {'input': '5\r\n', 'output': ['84']}, {'input': '27\r\n', 'output': ['304700019']}, {'input': '4\r\n', 'output': ['27']}]
[{'input': '1000\r\n', 'output': ['143886430']}, {'input': '5\r\n', 'output': ['84']}, {'input': '900\r\n', 'output': ['454329300']}, {'input': '999\r\n', 'output': ['742390865']}, {'input': '9\r\n', 'output': ['10350']}]
[{'input': '2\r\n', 'output': ['3']}, {'input': '6\r\n', 'output': ['270']}, {'input': '25\r\n', 'output': ['569244761']}, {'input': '10\r\n', 'output': ['36074']}, {'input': '24\r\n', 'output': ['60828279']}]
[{'input': '998\r\n', 'output': ['311781222']}, {'input': '20\r\n', 'output': ['746806193']}, {'input': '24\r\n', 'output': ['60828279']}, {'input': '1000\r\n', 'output': ['143886430']}, {'input': '22\r\n', 'output': ['450571487']}]
[{'input': '23\r\n', 'output': ['724717660']}, {'input': '8\r\n', 'output': ['3012']}, {'input': '16\r\n', 'output': ['78484401']}, {'input': '10\r\n', 'output': ['36074']}, {'input': '500\r\n', 'output': ['660474384']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
118
100
100
100
["2\n3\n5\n1\n8", "3\n1\n6\n7\n25", "6\n4\n9\n10\n89"]
The first line contains one integer $$$a_1$$$ $$$(1 \le a_1 \le 1\,000)$$$ — the number of players in the first team. The second line contains one integer $$$a_2$$$ $$$(1 \le a_2 \le 1\,000)$$$ — the number of players in the second team. The third line contains one integer $$$k_1$$$ $$$(1 \le k_1 \le 1\,000)$$$ — the maximum number of yellow cards a player from the first team can receive (after receiving that many yellow cards, he leaves the game). The fourth line contains one integer $$$k_2$$$ $$$(1 \le k_2 \le 1\,000)$$$ — the maximum number of yellow cards a player from the second team can receive (after receiving that many yellow cards, he leaves the game). The fifth line contains one integer $$$n$$$ $$$(1 \le n \le a_1 \cdot k_1 + a_2 \cdot k_2)$$$ — the number of yellow cards that have been shown during the match.
2be8e0b8ad4d3de2930576c0209e8b91
#pragma GCC optimize("Ofast", "unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> #define mp(x, y) make_pair(x, y) #define forn(i, a, b) for(size_t i=a; i<b; ++i) #define ford(i, a, b) for(size_t i=b-1; i>=a; --i) #define all(a) a.begin(), a.end() #define sz(a) (size_t)(a).size() #define X first #define Y second #define sqr(x) 1ll*(x)*(x) #define pb push_back #define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; using pld = pair<ld, ld>; using vint = vector<int>; using vll = vector<ll>; using v2int = vector<vint>; using v2ll = vector<vll>; int main() { fio; int a1,a2,k1,k2,n; int MAX=0; cin >>a1>>a2>>k1>>k2>>n; if (k2<k1) { swap(k1,k2); swap(a1,a2); } int t1=a1,t2=a2,nn=n; while (a1>0 && n>=k1) { n-=k1; a1--; } while (a2>0 && n>=k2) { n-=k2; a2--; } MAX=(t1-a1)+(t2-a2); /////////////////// a1=t1; a2=t2; n=nn; int tmp=a1*(k1-1)+a2*(k2-1); cout<<(tmp>=n?0:n-tmp)<<" "<<MAX<<endl; }
["0 4", "4 4", "5 9"]
C++
NoteIn the first example it could be possible that no player left the game, so the first number in the output is $$$0$$$. The maximum possible number of players that could have been forced to leave the game is $$$4$$$ — one player from the first team, and three players from the second.In the second example the maximum possible number of yellow cards has been shown $$$(3 \cdot 6 + 1 \cdot 7 = 25)$$$, so in any case all players were sent off.
Print two integers — the minimum and the maximum number of players that could have been thrown out of the game.
The final match of the Berland Football Cup has been held recently. The referee has shown $$$n$$$ yellow cards throughout the match. At the beginning of the match there were $$$a_1$$$ players in the first team and $$$a_2$$$ players in the second team.The rules of sending players off the game are a bit different in Berland football. If a player from the first team receives $$$k_1$$$ yellow cards throughout the match, he can no longer participate in the match — he's sent off. And if a player from the second team receives $$$k_2$$$ yellow cards, he's sent off. After a player leaves the match, he can no longer receive any yellow cards. Each of $$$n$$$ yellow cards was shown to exactly one player. Even if all players from one team (or even from both teams) leave the match, the game still continues.The referee has lost his records on who has received each yellow card. Help him to determine the minimum and the maximum number of players that could have been thrown out of the game.
[{"input": "2\r\n3\r\n5\r\n1\r\n8\r\n", "output": ["0 4", "0 4\n", "0\r\n4", "0 4\r\n", "0 4\r\n", "0 4 \n", "0\r\n4\r\n"]}, {"input": "3\r\n1\r\n6\r\n7\r\n25\r\n", "output": ["4 4\r\n", "4\r\n4\r\n", "4 4 \n", "4 4\n", "4\r\n4", "4 4\r\n", "4 4"]}, {"input": "6\r\n4\r\n9\r\n10\r\n89\r\n", "output": ["5 9", "5 9\r\n", "5 9 \n", "5\r\n9\r\n", "5 9\r\n", "5\r\n9", "5 9\n"]}, {"input": "10\r\n6\r\n5\r\n3\r\n56\r\n", "output": ["4\r\n13\r\n", "4 13 \n", "4 13\n", "4 13\r\n", "4\r\n13", "4 13", "4 13\r\n"]}, {"input": "1\r\n8\r\n6\r\n1\r\n11\r\n", "output": ["6\r\n8", "6 8", "6 8\n", "6\r\n8\r\n", "6 8\r\n", "6 8\r\n", "6 8 \n"]}, {"input": "8\r\n4\r\n1\r\n2\r\n9\r\n", "output": ["5 8\n", "5 8\r\n", "5 8 \n", "5\r\n8\r\n", "5 8", "5 8\r\n", "5\r\n8"]}, {"input": "1000\r\n1000\r\n1000\r\n1000\r\n1456999\r\n", "output": ["0 1456\r\n", "0 1456\r\n", "0 1456\n", "0 1456 \n", "0\r\n1456\r\n", "0 1456", "0\r\n1456"]}, {"input": "8\r\n2\r\n6\r\n7\r\n34\r\n", "output": ["0 5\r\n", "0 5", "0 5 \n", "0 5\r\n", "0\r\n5\r\n", "0 5\n", "0\r\n5"]}, {"input": "7\r\n6\r\n2\r\n6\r\n11\r\n", "output": ["0 5\r\n", "0 5", "0 5 \n", "0 5\r\n", "0\r\n5\r\n", "0 5\n", "0\r\n5"]}, {"input": "621\r\n739\r\n132\r\n209\r\n236198\r\n", "output": ["1135 1358 \n", "1135\r\n1358\r\n", "1135\r\n1358", "1135 1358\r\n", "1135 1358\n", "1135 1358", "1135 1358\r\n"]}, {"input": "998\r\n967\r\n976\r\n961\r\n1902359\r\n", "output": ["989 1964\r\n", "989 1964\r\n", "989 1964\n", "989\r\n1964", "989 1964", "989\r\n1964\r\n", "989 1964 \n"]}, {"input": "8\r\n8\r\n3\r\n7\r\n61\r\n", "output": ["0 13\r\n", "0 13\r\n", "0\r\n13\r\n", "0\r\n13", "0 13 \n", "0 13\n", "0 13"]}, {"input": "5\r\n8\r\n7\r\n1\r\n38\r\n", "output": ["8 12", "8 12\n", "8\r\n12", "8 12\r\n", "8 12 \n", "8 12\r\n", "8\r\n12\r\n"]}, {"input": "4\r\n7\r\n1\r\n10\r\n60\r\n", "output": ["0\r\n9", "0 9\r\n", "0 9 \n", "0 9", "0 9\n", "0\r\n9\r\n", "0 9\r\n"]}, {"input": "1\r\n7\r\n2\r\n3\r\n5\r\n", "output": ["0 2\n", "0 2 \n", "0\r\n2", "0 2\r\n", "0 2", "0 2\r\n", "0\r\n2\r\n"]}, {"input": "4\r\n5\r\n8\r\n5\r\n54\r\n", "output": ["6\r\n8", "6 8", "6 8\n", "6\r\n8\r\n", "6 8\r\n", "6 8\r\n", "6 8 \n"]}, {"input": "9\r\n9\r\n6\r\n4\r\n28\r\n", "output": ["0\r\n7\r\n", "0 7 \n", "0\r\n7", "0 7\r\n", "0 7\n", "0 7\r\n", "0 7"]}, {"input": "1\r\n1\r\n1\r\n1\r\n1\r\n", "output": ["1\r\n1", "1 1\n", "1 1\r\n", "1\r\n1\r\n", "1 1\r\n", "1 1 \n", "1 1"]}, {"input": "1\r\n1\r\n1\r\n1\r\n2\r\n", "output": ["2 2 \n", "2\r\n2\r\n", "2 2\n", "2 2\r\n", "2 2", "2\r\n2", "2 2\r\n"]}, {"input": "1000\r\n1000\r\n1000\r\n1000\r\n1999999\r\n", "output": ["1999\r\n1999", "1999 1999\r\n", "1999 1999 \n", "1999 1999", "1999\r\n1999\r\n", "1999 1999\n", "1999 1999\r\n"]}, {"input": "1000\r\n1000\r\n1000\r\n1000\r\n2000000\r\n", "output": ["2000 2000\r\n", "2000 2000 \n", "2000 2000\n", "2000 2000", "2000\r\n2000\r\n", "2000\r\n2000", "2000 2000\r\n"]}, {"input": "1000\r\n1000\r\n1000\r\n1000\r\n234567\r\n", "output": ["0\r\n234\r\n", "0 234\n", "0 234\r\n", "0\r\n234", "0 234\r\n", "0 234 \n", "0 234"]}, {"input": "1000\r\n1000\r\n1000\r\n1000\r\n1542000\r\n", "output": ["0 1542\n", "0 1542", "0 1542\r\n", "0\r\n1542\r\n", "0 1542\r\n", "0\r\n1542", "0 1542 \n"]}, {"input": "645\r\n910\r\n871\r\n584\r\n1093020\r\n", "output": ["1340 1554\n", "1340 1554 \n", "1340 1554\r\n", "1340 1554", "1340\r\n1554\r\n", "1340 1554\r\n", "1340\r\n1554"]}, {"input": "69\r\n50\r\n425\r\n358\r\n47212\r\n", "output": ["106 118\r\n", "106 118", "106 118 \n", "106\r\n118", "106\r\n118\r\n", "106 118\r\n", "106 118\n"]}, {"input": "493\r\n599\r\n875\r\n539\r\n754094\r\n", "output": ["950 1091\r\n", "950 1091\r\n", "950\r\n1091", "950 1091\n", "950\r\n1091\r\n", "950 1091", "950 1091 \n"]}, {"input": "45\r\n583\r\n686\r\n390\r\n257651\r\n", "output": ["39 627\n", "39 627\r\n", "39\r\n627\r\n", "39 627\r\n", "39 627 \n", "39 627", "39\r\n627"]}, {"input": "469\r\n236\r\n432\r\n868\r\n407315\r\n", "output": ["564 704\n", "564 704", "564\r\n704", "564 704\r\n", "564 704\r\n", "564\r\n704\r\n", "564 704 \n"]}, {"input": "893\r\n376\r\n689\r\n346\r\n744309\r\n", "output": ["205 1267\r\n", "205 1267\n", "205 1267", "205 1267 \n", "205\r\n1267\r\n", "205\r\n1267", "205 1267\r\n"]}, {"input": "21\r\n924\r\n435\r\n527\r\n495557\r\n", "output": ["419 944 \n", "419 944\r\n", "419 944\n", "419 944\r\n", "419 944", "419\r\n944\r\n", "419\r\n944"]}, {"input": "445\r\n65\r\n989\r\n197\r\n452410\r\n", "output": ["10 509", "10\r\n509", "10\r\n509\r\n", "10 509\r\n", "10 509 \n", "10 509\r\n", "10 509\n"]}, {"input": "869\r\n909\r\n438\r\n379\r\n724194\r\n", "output": ["839 1775\n", "839\r\n1775\r\n", "839 1775\r\n", "839 1775 \n", "839\r\n1775", "839 1775\r\n", "839 1775"]}, {"input": "997\r\n754\r\n992\r\n152\r\n1103189\r\n", "output": ["1308 1750 \n", "1308 1750\r\n", "1308 1750\r\n", "1308\r\n1750", "1308 1750", "1308 1750\n", "1308\r\n1750\r\n"]}, {"input": "421\r\n702\r\n250\r\n334\r\n339096\r\n", "output": ["501 1121", "501 1121\r\n", "501\r\n1121\r\n", "501 1121\n", "501 1121\r\n", "501\r\n1121", "501 1121 \n"]}, {"input": "549\r\n250\r\n995\r\n811\r\n748917\r\n", "output": ["711\r\n798\r\n", "711 798\r\n", "711 798 \n", "711 798", "711 798\r\n", "711\r\n798", "711 798\n"]}, {"input": "269\r\n95\r\n253\r\n185\r\n85627\r\n", "output": ["359\r\n363\r\n", "359 363\n", "359 363 \n", "359\r\n363", "359 363\r\n", "359 363", "359 363\r\n"]}, {"input": "398\r\n235\r\n999\r\n663\r\n552924\r\n", "output": ["150 632\r\n", "150 632\r\n", "150 632 \n", "150 632\n", "150\r\n632\r\n", "150\r\n632", "150 632"]}, {"input": "1\r\n1\r\n7\r\n1\r\n2\r\n", "output": ["0 1 \n", "0\r\n1\r\n", "0 1\n", "0 1", "0 1\r\n", "0 1\r\n", "0\r\n1"]}, {"input": "254\r\n771\r\n827\r\n760\r\n693168\r\n", "output": ["0\r\n900", "0\r\n900\r\n", "0 900\r\n", "0 900\r\n", "0 900\n", "0 900", "0 900 \n"]}, {"input": "708\r\n360\r\n819\r\n836\r\n642301\r\n", "output": ["0\r\n782", "0 782\r\n", "0 782\n", "0\r\n782\r\n", "0 782\r\n", "0 782", "0 782 \n"]}, {"input": "1\r\n1\r\n1\r\n3\r\n4\r\n", "output": ["2 2 \n", "2\r\n2\r\n", "2 2\n", "2 2\r\n", "2 2", "2\r\n2", "2 2\r\n"]}, {"input": "998\r\n967\r\n976\r\n961\r\n1903335\r\n", "output": ["1965 1965\n", "1965\r\n1965\r\n", "1965 1965 \n", "1965 1965\r\n", "1965 1965", "1965\r\n1965", "1965 1965\r\n"]}, {"input": "998\r\n967\r\n976\r\n961\r\n1901392\r\n", "output": ["22 1963\n", "22 1963\r\n", "22\r\n1963\r\n", "22\r\n1963", "22 1963 \n", "22 1963", "22 1963\r\n"]}, {"input": "1000\r\n1000\r\n1000\r\n1000\r\n998\r\n", "output": ["0\r\n0\r\n", "0 0\r\n", "0 0", "0 0\r\n", "0\r\n0", "0 0\n", "0 0 \n"]}]
100
100
100
[{'input': '6\r\n4\r\n9\r\n10\r\n89\r\n', 'output': ['5 9', '5 9\r\n', '5 9 \n', '5\r\n9\r\n', '5 9\r\n', '5\r\n9', '5 9\n']}, {'input': '4\r\n7\r\n1\r\n10\r\n60\r\n', 'output': ['0\r\n9', '0 9\r\n', '0 9 \n', '0 9', '0 9\n', '0\r\n9\r\n', '0 9\r\n']}, {'input': '69\r\n50\r\n425\r\n358\r\n47212\r\n', 'output': ['106 118\r\n', '106 118', '106 118 \n', '106\r\n118', '106\r\n118\r\n', '106 118\r\n', '106 118\n']}, {'input': '549\r\n250\r\n995\r\n811\r\n748917\r\n', 'output': ['711\r\n798\r\n', '711 798\r\n', '711 798 \n', '711 798', '711 798\r\n', '711\r\n798', '711 798\n']}, {'input': '7\r\n6\r\n2\r\n6\r\n11\r\n', 'output': ['0 5\r\n', '0 5', '0 5 \n', '0 5\r\n', '0\r\n5\r\n', '0 5\n', '0\r\n5']}]
[{'input': '1000\r\n1000\r\n1000\r\n1000\r\n2000000\r\n', 'output': ['2000 2000\r\n', '2000 2000 \n', '2000 2000\n', '2000 2000', '2000\r\n2000\r\n', '2000\r\n2000', '2000 2000\r\n']}, {'input': '998\r\n967\r\n976\r\n961\r\n1903335\r\n', 'output': ['1965 1965\n', '1965\r\n1965\r\n', '1965 1965 \n', '1965 1965\r\n', '1965 1965', '1965\r\n1965', '1965 1965\r\n']}, {'input': '445\r\n65\r\n989\r\n197\r\n452410\r\n', 'output': ['10 509', '10\r\n509', '10\r\n509\r\n', '10 509\r\n', '10 509 \n', '10 509\r\n', '10 509\n']}, {'input': '1000\r\n1000\r\n1000\r\n1000\r\n1999999\r\n', 'output': ['1999\r\n1999', '1999 1999\r\n', '1999 1999 \n', '1999 1999', '1999\r\n1999\r\n', '1999 1999\n', '1999 1999\r\n']}, {'input': '5\r\n8\r\n7\r\n1\r\n38\r\n', 'output': ['8 12', '8 12\n', '8\r\n12', '8 12\r\n', '8 12 \n', '8 12\r\n', '8\r\n12\r\n']}]
[{'input': '621\r\n739\r\n132\r\n209\r\n236198\r\n', 'output': ['1135 1358 \n', '1135\r\n1358\r\n', '1135\r\n1358', '1135 1358\r\n', '1135 1358\n', '1135 1358', '1135 1358\r\n']}, {'input': '21\r\n924\r\n435\r\n527\r\n495557\r\n', 'output': ['419 944 \n', '419 944\r\n', '419 944\n', '419 944\r\n', '419 944', '419\r\n944\r\n', '419\r\n944']}, {'input': '997\r\n754\r\n992\r\n152\r\n1103189\r\n', 'output': ['1308 1750 \n', '1308 1750\r\n', '1308 1750\r\n', '1308\r\n1750', '1308 1750', '1308 1750\n', '1308\r\n1750\r\n']}, {'input': '998\r\n967\r\n976\r\n961\r\n1903335\r\n', 'output': ['1965 1965\n', '1965\r\n1965\r\n', '1965 1965 \n', '1965 1965\r\n', '1965 1965', '1965\r\n1965', '1965 1965\r\n']}, {'input': '893\r\n376\r\n689\r\n346\r\n744309\r\n', 'output': ['205 1267\r\n', '205 1267\n', '205 1267', '205 1267 \n', '205\r\n1267\r\n', '205\r\n1267', '205 1267\r\n']}]
[{'input': '4\r\n7\r\n1\r\n10\r\n60\r\n', 'output': ['0\r\n9', '0 9\r\n', '0 9 \n', '0 9', '0 9\n', '0\r\n9\r\n', '0 9\r\n']}, {'input': '4\r\n5\r\n8\r\n5\r\n54\r\n', 'output': ['6\r\n8', '6 8', '6 8\n', '6\r\n8\r\n', '6 8\r\n', '6 8\r\n', '6 8 \n']}, {'input': '1000\r\n1000\r\n1000\r\n1000\r\n998\r\n', 'output': ['0\r\n0\r\n', '0 0\r\n', '0 0', '0 0\r\n', '0\r\n0', '0 0\n', '0 0 \n']}, {'input': '621\r\n739\r\n132\r\n209\r\n236198\r\n', 'output': ['1135 1358 \n', '1135\r\n1358\r\n', '1135\r\n1358', '1135 1358\r\n', '1135 1358\n', '1135 1358', '1135 1358\r\n']}, {'input': '269\r\n95\r\n253\r\n185\r\n85627\r\n', 'output': ['359\r\n363\r\n', '359 363\n', '359 363 \n', '359\r\n363', '359 363\r\n', '359 363', '359 363\r\n']}]
[{'input': '1\r\n1\r\n1\r\n3\r\n4\r\n', 'output': ['2 2 \n', '2\r\n2\r\n', '2 2\n', '2 2\r\n', '2 2', '2\r\n2', '2 2\r\n']}, {'input': '254\r\n771\r\n827\r\n760\r\n693168\r\n', 'output': ['0\r\n900', '0\r\n900\r\n', '0 900\r\n', '0 900\r\n', '0 900\n', '0 900', '0 900 \n']}, {'input': '998\r\n967\r\n976\r\n961\r\n1901392\r\n', 'output': ['22 1963\n', '22 1963\r\n', '22\r\n1963\r\n', '22\r\n1963', '22 1963 \n', '22 1963', '22 1963\r\n']}, {'input': '893\r\n376\r\n689\r\n346\r\n744309\r\n', 'output': ['205 1267\r\n', '205 1267\n', '205 1267', '205 1267 \n', '205\r\n1267\r\n', '205\r\n1267', '205 1267\r\n']}, {'input': '421\r\n702\r\n250\r\n334\r\n339096\r\n', 'output': ['501 1121', '501 1121\r\n', '501\r\n1121\r\n', '501 1121\n', '501 1121\r\n', '501\r\n1121', '501 1121 \n']}]
100
100
100
100
100
100
100
100
100
100
91.67
83.33
83.33
91.67
91.67
119
100
100
88.334
["2 2 3", "4 2 3"]
The first line contains three integers k1, k2 and k3 (1 ≤ ki ≤ 1500) — time intervals of the garlands.
df48af9f5e68cb6efc1214f7138accf9
#include <bits/stdc++.h> using namespace std; int mx,b,c; double arr[15000],a; bool chek; int main() { for(int i=1; i<=3; i++){ cin>>a; if(a==1)arr[1]+=(1/a); if(!((int)a%2))arr[2]+=(2/a); if(!((int)a%3))arr[3]+=(3/a); } if((arr[1]) || (arr[2]>=2) || (arr[3]>=3)){ cout<<"YES\n"; }else{ cout<<"NO\n"; } //chek= ((b*c)+(a*c)+(b*a))/(a*b*c); /*if(chek){ cout<<"YES\n"; }else{ cout<<"NO\n"; } cin>>arr[0]>>arr[1]>>arr[2]; sort(arr,arr+3); mx=arr[2]-1; if(!mx){ cout<<"YES\n"; return 0; } chek = (mx/arr[0])+(mx/arr[1]); if(chek>=mx){ cout<<"YES\n"; }else{ cout<<"NO\n"; }*/ return 0; }
["YES", "NO"]
C++
NoteIn the first example Mishka can choose x1 = 1, x2 = 2, x3 = 1. The first garland will be lit during seconds 1, 3, 5, 7, ..., the second — 2, 4, 6, 8, ..., which already cover all the seconds after the 2-nd one. It doesn't even matter what x3 is chosen. Our choice will lead third to be lit during seconds 1, 4, 7, 10, ..., though.In the second example there is no way to choose such moments of time, there always be some seconds when no garland is lit.
If Mishka can choose moments of time to switch on the garlands in such a way that each second after switching the garlands on at least one garland will be lit, print YES. Otherwise, print NO.
Mishka is decorating the Christmas tree. He has got three garlands, and all of them will be put on the tree. After that Mishka will switch these garlands on.When a garland is switched on, it periodically changes its state — sometimes it is lit, sometimes not. Formally, if i-th garland is switched on during x-th second, then it is lit only during seconds x, x + ki, x + 2ki, x + 3ki and so on.Mishka wants to switch on the garlands in such a way that during each second after switching the garlands on there would be at least one lit garland. Formally, Mishka wants to choose three integers x1, x2 and x3 (not necessarily distinct) so that he will switch on the first garland during x1-th second, the second one — during x2-th second, and the third one — during x3-th second, respectively, and during each second starting from max(x1, x2, x3) at least one garland will be lit.Help Mishka by telling him if it is possible to do this!
[{"input": "2 2 3\r\n", "output": ["YES"]}, {"input": "4 2 3\r\n", "output": ["NO"]}, {"input": "1499 1498 1500\r\n", "output": ["NO"]}, {"input": "1500 1500 1500\r\n", "output": ["NO"]}, {"input": "100 4 1\r\n", "output": ["YES"]}, {"input": "4 2 4\r\n", "output": ["YES"]}, {"input": "3 3 3\r\n", "output": ["YES"]}, {"input": "2 3 6\r\n", "output": ["NO"]}, {"input": "2 3 3\r\n", "output": ["NO"]}, {"input": "4 4 2\r\n", "output": ["YES"]}, {"input": "1 1 1\r\n", "output": ["YES"]}, {"input": "2 11 2\r\n", "output": ["YES"]}, {"input": "4 4 4\r\n", "output": ["NO"]}, {"input": "4 4 5\r\n", "output": ["NO"]}, {"input": "3 3 2\r\n", "output": ["NO"]}, {"input": "3 6 6\r\n", "output": ["NO"]}, {"input": "2 3 2\r\n", "output": ["YES"]}, {"input": "1 1 3\r\n", "output": ["YES"]}, {"input": "3 3 4\r\n", "output": ["NO"]}, {"input": "2 4 4\r\n", "output": ["YES"]}, {"input": "2 2 2\r\n", "output": ["YES"]}, {"input": "2 10 10\r\n", "output": ["NO"]}, {"input": "3 4 4\r\n", "output": ["NO"]}, {"input": "2 5 5\r\n", "output": ["NO"]}, {"input": "2 4 5\r\n", "output": ["NO"]}, {"input": "228 2 2\r\n", "output": ["YES"]}, {"input": "2 998 1000\r\n", "output": ["NO"]}, {"input": "2 6 6\r\n", "output": ["NO"]}, {"input": "6 4 7\r\n", "output": ["NO"]}, {"input": "2 5 2\r\n", "output": ["YES"]}, {"input": "2 100 100\r\n", "output": ["NO"]}, {"input": "7 7 2\r\n", "output": ["NO"]}, {"input": "3 3 6\r\n", "output": ["NO"]}, {"input": "82 3 82\r\n", "output": ["NO"]}, {"input": "2 3 5\r\n", "output": ["NO"]}, {"input": "1 218 924\r\n", "output": ["YES"]}, {"input": "4 4 123\r\n", "output": ["NO"]}, {"input": "4 4 3\r\n", "output": ["NO"]}, {"input": "3 4 2\r\n", "output": ["NO"]}, {"input": "2 2 5\r\n", "output": ["YES"]}, {"input": "2 10 2\r\n", "output": ["YES"]}, {"input": "5 2 2\r\n", "output": ["YES"]}, {"input": "3 3 9\r\n", "output": ["NO"]}, {"input": "1 5 5\r\n", "output": ["YES"]}, {"input": "2 4 6\r\n", "output": ["NO"]}, {"input": "15 3 3\r\n", "output": ["NO"]}, {"input": "1 5 10\r\n", "output": ["YES"]}, {"input": "2 3 14\r\n", "output": ["NO"]}, {"input": "1265 2 593\r\n", "output": ["NO"]}, {"input": "2 2 567\r\n", "output": ["YES"]}, {"input": "1 6 5\r\n", "output": ["YES"]}, {"input": "2 2 7\r\n", "output": ["YES"]}, {"input": "2 2 1500\r\n", "output": ["YES"]}, {"input": "3 6 9\r\n", "output": ["NO"]}, {"input": "1 46 79\r\n", "output": ["YES"]}, {"input": "4 3 3\r\n", "output": ["NO"]}, {"input": "2 4 8\r\n", "output": ["NO"]}, {"input": "1493 1489 1487\r\n", "output": ["NO"]}, {"input": "1 2 3\r\n", "output": ["YES"]}, {"input": "1 2 5\r\n", "output": ["YES"]}, {"input": "1 2 8\r\n", "output": ["YES"]}, {"input": "3 4 5\r\n", "output": ["NO"]}, {"input": "2 2 4\r\n", "output": ["YES"]}, {"input": "3 2 3\r\n", "output": ["NO"]}, {"input": "7 2 2\r\n", "output": ["YES"]}, {"input": "3 2 2\r\n", "output": ["YES"]}, {"input": "6 7 4\r\n", "output": ["NO"]}]
100
100
100
[{'input': '5 2 2\r\n', 'output': ['YES']}, {'input': '2 3 14\r\n', 'output': ['NO']}, {'input': '1 5 5\r\n', 'output': ['YES']}, {'input': '7 2 2\r\n', 'output': ['YES']}, {'input': '1 1 3\r\n', 'output': ['YES']}]
[{'input': '2 10 2\r\n', 'output': ['YES']}, {'input': '2 10 10\r\n', 'output': ['NO']}, {'input': '4 4 123\r\n', 'output': ['NO']}, {'input': '2 5 5\r\n', 'output': ['NO']}, {'input': '3 3 2\r\n', 'output': ['NO']}]
[{'input': '1 2 3\r\n', 'output': ['YES']}, {'input': '2 3 14\r\n', 'output': ['NO']}, {'input': '2 998 1000\r\n', 'output': ['NO']}, {'input': '6 4 7\r\n', 'output': ['NO']}, {'input': '1 1 3\r\n', 'output': ['YES']}]
[{'input': '2 998 1000\r\n', 'output': ['NO']}, {'input': '1 5 10\r\n', 'output': ['YES']}, {'input': '3 4 4\r\n', 'output': ['NO']}, {'input': '4 2 3\r\n', 'output': ['NO']}, {'input': '2 2 4\r\n', 'output': ['YES']}]
[{'input': '3 3 6\r\n', 'output': ['NO']}, {'input': '15 3 3\r\n', 'output': ['NO']}, {'input': '6 7 4\r\n', 'output': ['NO']}, {'input': '2 10 2\r\n', 'output': ['YES']}, {'input': '3 3 2\r\n', 'output': ['NO']}]
100
100
100
100
100
100
100
100
100
100
92.86
78.57
85.71
92.86
78.57
120
100
100
85.714
["4\n1 1 1 4", "5\n1 1 5 2 1"]
The first line of the input contains integer n (1 ≤ n ≤ 24). Next line contains n positive integers: the i-th number represents ci (1 ≤ ci ≤ n).
ed0925cfaee961a3ceebd13b3c96a15a
#include <bits/stdc++.h> using namespace std; int C[25],A[25]; int N; int dfs(int idx,int rem) { if(idx>N) { for(int i = 1;i<=N;i++) { if(C[i]) return 0; } return 1; } if(!A[idx]) return dfs(idx+1,A[idx+1]-1); for(int i = min(A[idx],rem);i>0;i--) { if(C[i]) { C[i]-=1,A[idx]-=i; if(dfs(idx,i)) return 1; A[idx]+=i,C[i]+=1; } } return 0; } int main() { cin>>N; C[N] = -1; for(int i = 1;i<=N;i++) { cin>>A[i]; C[A[i]]+=1; A[i]-=1; } puts(dfs(1,A[1] - 1)?"YES":"NO"); return 0; }
["YES", "NO"]
C++
null
Output on the first line "YES" (without quotes) if there exist at least one tree following Iahub's restrictions, otherwise output "NO" (without quotes).
Iahub and Iahubina went to a picnic in a forest full of trees. Less than 5 minutes passed before Iahub remembered of trees from programming. Moreover, he invented a new problem and Iahubina has to solve it, otherwise Iahub won't give her the food. Iahub asks Iahubina: can you build a rooted tree, such that each internal node (a node with at least one son) has at least two sons; node i has ci nodes in its subtree? Iahubina has to guess the tree. Being a smart girl, she realized that it's possible no tree can follow Iahub's restrictions. In this way, Iahub will eat all the food. You need to help Iahubina: determine if there's at least one tree following Iahub's restrictions. The required tree must contain n nodes.
[{"input": "4\r\n1 1 1 4\r\n", "output": ["YES"]}, {"input": "5\r\n1 1 5 2 1\r\n", "output": ["NO"]}, {"input": "13\r\n1 1 1 1 1 1 1 1 1 4 4 4 13\r\n", "output": ["YES"]}, {"input": "4\r\n1 1 1 3\r\n", "output": ["NO"]}, {"input": "24\r\n1 1 1 1 1 1 1 1 1 1 1 1 24 1 1 1 1 1 1 1 1 1 1 1\r\n", "output": ["YES"]}, {"input": "24\r\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24\r\n", "output": ["NO"]}, {"input": "10\r\n1 1 1 1 7 1 1 1 4 10\r\n", "output": ["YES"]}, {"input": "24\r\n1 1 3 1 1 10 2 9 13 1 8 1 4 1 3 24 1 1 1 1 4 1 3 1\r\n", "output": ["NO"]}, {"input": "24\r\n2 3 20 1 4 9 1 3 1 2 1 3 1 2 1 1 1 2 1 2 4 24 2 1\r\n", "output": ["NO"]}, {"input": "24\r\n8 5 3 1 1 5 10 1 1 1 1 5 1 2 7 3 4 1 1 24 1 1 2 8\r\n", "output": ["NO"]}, {"input": "24\r\n1 1 1 3 4 1 24 1 1 3 1 1 1 5 14 2 17 1 2 2 5 1 1 6\r\n", "output": ["NO"]}, {"input": "1\r\n1\r\n", "output": ["YES"]}, {"input": "17\r\n6 1 1 1 3 1 1 17 6 1 4 1 1 1 3 1 1\r\n", "output": ["YES"]}, {"input": "23\r\n1 1 1 1 3 7 3 1 1 1 3 7 1 3 1 15 1 3 7 3 23 1 1\r\n", "output": ["YES"]}, {"input": "24\r\n1 24 1 1 1 3 8 1 1 3 1 1 6 1 1 1 1 3 5 1 3 7 13 1\r\n", "output": ["YES"]}, {"input": "16\r\n1 1 1 1 1 1 1 1 1 1 1 1 16 1 1 1\r\n", "output": ["YES"]}, {"input": "21\r\n1 1 1 6 1 1 13 21 1 1 3 1 8 1 19 3 3 1 1 1 1\r\n", "output": ["YES"]}, {"input": "22\r\n1 1 1 6 1 1 13 21 1 1 2 1 8 1 19 3 3 1 1 1 1 2\r\n", "output": ["NO"]}, {"input": "19\r\n9 7 1 8 1 1 1 13 1 1 3 3 19 1 1 1 1 1 1\r\n", "output": ["NO"]}, {"input": "18\r\n6 1 1 3 1 1 1 1 1 1 4 1 8 1 1 18 1 5\r\n", "output": ["YES"]}, {"input": "14\r\n4 1 1 1 3 1 1 1 1 14 1 5 1 3\r\n", "output": ["YES"]}, {"input": "2\r\n1 2\r\n", "output": ["NO"]}, {"input": "24\r\n3 3 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24\r\n", "output": ["NO"]}, {"input": "20\r\n20 9 4 4 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n", "output": ["YES"]}, {"input": "12\r\n12 7 4 3 3 1 1 1 1 1 1 1\r\n", "output": ["YES"]}]
100
100
100
[{'input': '24\r\n1 1 1 1 1 1 1 1 1 1 1 1 24 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['YES']}, {'input': '24\r\n3 3 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24\r\n', 'output': ['NO']}, {'input': '19\r\n9 7 1 8 1 1 1 13 1 1 3 3 19 1 1 1 1 1 1\r\n', 'output': ['NO']}, {'input': '14\r\n4 1 1 1 3 1 1 1 1 14 1 5 1 3\r\n', 'output': ['YES']}, {'input': '20\r\n20 9 4 4 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['YES']}]
[{'input': '2\r\n1 2\r\n', 'output': ['NO']}, {'input': '21\r\n1 1 1 6 1 1 13 21 1 1 3 1 8 1 19 3 3 1 1 1 1\r\n', 'output': ['YES']}, {'input': '13\r\n1 1 1 1 1 1 1 1 1 4 4 4 13\r\n', 'output': ['YES']}, {'input': '10\r\n1 1 1 1 7 1 1 1 4 10\r\n', 'output': ['YES']}, {'input': '24\r\n3 3 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24\r\n', 'output': ['NO']}]
[{'input': '5\r\n1 1 5 2 1\r\n', 'output': ['NO']}, {'input': '21\r\n1 1 1 6 1 1 13 21 1 1 3 1 8 1 19 3 3 1 1 1 1\r\n', 'output': ['YES']}, {'input': '22\r\n1 1 1 6 1 1 13 21 1 1 2 1 8 1 19 3 3 1 1 1 1 2\r\n', 'output': ['NO']}, {'input': '24\r\n8 5 3 1 1 5 10 1 1 1 1 5 1 2 7 3 4 1 1 24 1 1 2 8\r\n', 'output': ['NO']}, {'input': '10\r\n1 1 1 1 7 1 1 1 4 10\r\n', 'output': ['YES']}]
[{'input': '12\r\n12 7 4 3 3 1 1 1 1 1 1 1\r\n', 'output': ['YES']}, {'input': '2\r\n1 2\r\n', 'output': ['NO']}, {'input': '21\r\n1 1 1 6 1 1 13 21 1 1 3 1 8 1 19 3 3 1 1 1 1\r\n', 'output': ['YES']}, {'input': '20\r\n20 9 4 4 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['YES']}, {'input': '4\r\n1 1 1 4\r\n', 'output': ['YES']}]
[{'input': '1\r\n1\r\n', 'output': ['YES']}, {'input': '16\r\n1 1 1 1 1 1 1 1 1 1 1 1 16 1 1 1\r\n', 'output': ['YES']}, {'input': '19\r\n9 7 1 8 1 1 1 13 1 1 3 3 19 1 1 1 1 1 1\r\n', 'output': ['NO']}, {'input': '24\r\n1 1 1 1 1 1 1 1 1 1 1 1 24 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['YES']}, {'input': '4\r\n1 1 1 4\r\n', 'output': ['YES']}]
100
100
100
100
100
95.83
91.67
95.83
95.83
95.83
94.44
88.89
94.44
94.44
94.44
121
100
94.998
93.33
["5 2", "7 4"]
The single line contains two space-separated integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ min(8, n)) — the number of the houses and the number k from the statement.
cc838bc14408f14f984a349fea9e9694
#include <cmath> #include <cstring> #include <cstdio> #include <cstdlib> #include <map> #include <set> #include <string> #include <vector> #include <iostream> #include <algorithm> using namespace std; const long long MAXN = 2000; const long long mod = 1000000007; long long C[MAXN][MAXN], nn[MAXN], f[MAXN]; long long a[MAXN]; long long n, k; long long res = 0, s = 0; long long next(long long a[], long long l, long long r, long long up) { a[r + 1] = 0; a[l]++; for(long long i = l; i <= r; i++) if (a[i] > up) { a[i] = 1; a[i + 1]++; } if (a[r + 1]) return 0; return 1; } long long pow(long long a, long long b) { long long res = 1; for(long long i = 1; i <= b; i++) res = res * a % mod; return res; } int main() { cin >> n >> k; for(long long i = 0; i <= n; i++) C[i][0] = 1; for(long long i = 1; i <= n; i++) for(long long j = 1; j <= n; j++) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod; nn[0] = 1; //for(long long i = 1; i <= n; i++, prlong longf("\n")) // for(long long j = 1; j <= n; j++) // prlong longf("%I64d ", C[i][j]); for(long long i = 1; i <= n; i++) nn[i] = nn[i - 1] * i % mod; res = pow(n - k, n - k); //prlong longf("%I64d\n", res); for(long long i = 1; i <= k; i++) { long long tmp = C[k - 1][i - 1] * nn[i - 1] % mod; long long left = k - i; for(long long j = i + 1; j <= k; j++) a[j] = 1; long long tmp2 = 0; while(1) { long long flag = 1; for(long long j = i + 1; j <= k; j++) { long long x = j, ok = 0; for(long long l = 1; l <= k; l++) { x = a[x]; if (x <= i) ok = 1; } if (!ok) { flag = 0; break; } } tmp2 += flag; if (!next(a, i + 1, k, k)) break; } s += tmp2 * tmp % mod; s %= mod; } cout << res * s % mod << endl; return 0; }
["54", "1728"]
C++
null
In a single line print a single integer — the answer to the problem modulo 1000000007 (109 + 7).
Little penguin Polo loves his home village. The village has n houses, indexed by integers from 1 to n. Each house has a plaque containing an integer, the i-th house has a plaque containing integer pi (1 ≤ pi ≤ n).Little penguin Polo loves walking around this village. The walk looks like that. First he stands by a house number x. Then he goes to the house whose number is written on the plaque of house x (that is, to house px), then he goes to the house whose number is written on the plaque of house px (that is, to house ppx), and so on.We know that: When the penguin starts walking from any house indexed from 1 to k, inclusive, he can walk to house number 1. When the penguin starts walking from any house indexed from k + 1 to n, inclusive, he definitely cannot walk to house number 1. When the penguin starts walking from house number 1, he can get back to house number 1 after some non-zero number of walks from a house to a house. You need to find the number of ways you may write the numbers on the houses' plaques so as to fulfill the three above described conditions. Print the remainder after dividing this number by 1000000007 (109 + 7).
[{"input": "5 2\r\n", "output": ["54"]}, {"input": "7 4\r\n", "output": ["1728"]}, {"input": "8 5\r\n", "output": ["16875"]}, {"input": "8 1\r\n", "output": ["823543"]}, {"input": "10 7\r\n", "output": ["3176523"]}, {"input": "12 8\r\n", "output": ["536870912"]}, {"input": "50 2\r\n", "output": ["628702797"]}, {"input": "100 8\r\n", "output": ["331030906"]}, {"input": "1000 8\r\n", "output": ["339760446"]}, {"input": "999 7\r\n", "output": ["490075342"]}, {"input": "685 7\r\n", "output": ["840866481"]}, {"input": "975 8\r\n", "output": ["531455228"]}, {"input": "475 5\r\n", "output": ["449471303"]}, {"input": "227 6\r\n", "output": ["407444135"]}, {"input": "876 8\r\n", "output": ["703293724"]}, {"input": "1000 1\r\n", "output": ["760074701"]}, {"input": "1000 2\r\n", "output": ["675678679"]}, {"input": "1000 3\r\n", "output": ["330155123"]}, {"input": "1000 4\r\n", "output": ["660270610"]}, {"input": "1000 5\r\n", "output": ["583047503"]}, {"input": "1000 6\r\n", "output": ["834332109"]}, {"input": "657 3\r\n", "output": ["771999480"]}, {"input": "137 5\r\n", "output": ["160909830"]}, {"input": "8 8\r\n", "output": ["2097152"]}, {"input": "9 8\r\n", "output": ["2097152"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "2 1\r\n", "output": ["1"]}, {"input": "2 2\r\n", "output": ["2"]}, {"input": "3 3\r\n", "output": ["9"]}, {"input": "473 4\r\n", "output": ["145141007"]}]
100
100
100
[{'input': '50 2\r\n', 'output': ['628702797']}, {'input': '975 8\r\n', 'output': ['531455228']}, {'input': '2 2\r\n', 'output': ['2']}, {'input': '5 2\r\n', 'output': ['54']}, {'input': '7 4\r\n', 'output': ['1728']}]
[{'input': '685 7\r\n', 'output': ['840866481']}, {'input': '1000 2\r\n', 'output': ['675678679']}, {'input': '50 2\r\n', 'output': ['628702797']}, {'input': '1000 1\r\n', 'output': ['760074701']}, {'input': '1000 8\r\n', 'output': ['339760446']}]
[{'input': '876 8\r\n', 'output': ['703293724']}, {'input': '10 7\r\n', 'output': ['3176523']}, {'input': '7 4\r\n', 'output': ['1728']}, {'input': '1000 3\r\n', 'output': ['330155123']}, {'input': '475 5\r\n', 'output': ['449471303']}]
[{'input': '12 8\r\n', 'output': ['536870912']}, {'input': '685 7\r\n', 'output': ['840866481']}, {'input': '2 2\r\n', 'output': ['2']}, {'input': '473 4\r\n', 'output': ['145141007']}, {'input': '50 2\r\n', 'output': ['628702797']}]
[{'input': '9 8\r\n', 'output': ['2097152']}, {'input': '2 2\r\n', 'output': ['2']}, {'input': '50 2\r\n', 'output': ['628702797']}, {'input': '227 6\r\n', 'output': ['407444135']}, {'input': '975 8\r\n', 'output': ['531455228']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
122
100
100
100
["1 1 1", "3 1 0"]
The first line contains three space-separated integers a, b and c (0 ≤ a, b, c ≤ 231; a + b + c &gt; 0) — the number of red, green and blue pixels, correspondingly.
b8008caf788336775cb8ebb76478b04c
#include<bits/stdc++.h> using namespace std; long long a[3]; int main() { cin>>a[0]>>a[1]>>a[2]; sort(a,a+3); if ((a[0]+a[1])%2==0) cout<<a[1]; else cout<<a[2]; }
["1", "3"]
C++
NoteIn the first test sample the country needs only one fight to achieve peace and prosperity. Besides, it can be any fight whatsoever. For example, let's assume that the green and the blue pixels fight, then the surviving pixel will be red. As a result, after the fight there are two red pixels. There won't be other pixels.In the second sample the following sequence of fights is possible: red and blue, green and red, red and blue. As a result, after all fights there is one green pixel left.
Print a single number — the minimum number of pixel fights before the country becomes peaceful and prosperous. If making the country peaceful and prosperous is impossible, print -1.
Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the total number of pixels decreases by one). Besides, if pixels of colors x and y (x ≠ y) meet in a violent fight, then the pixel that survives the fight immediately changes its color to z (z ≠ x; z ≠ y). Pixels of the same color are friends, so they don't fight.The King of Flatland knows that his land will be peaceful and prosperous when the pixels are of the same color. For each of the three colors you know the number of pixels of this color that inhabit Flatland. Help the king and determine whether fights can bring peace and prosperity to the country and if it is possible, find the minimum number of fights needed to make the land peaceful and prosperous.
[{"input": "1 1 1\r\n", "output": ["1"]}, {"input": "3 1 0\r\n", "output": ["3"]}, {"input": "1 4 4\r\n", "output": ["4"]}, {"input": "5 10 6\r\n", "output": ["10"]}, {"input": "6 8 10\r\n", "output": ["8"]}, {"input": "1 10 2\r\n", "output": ["10"]}, {"input": "10 6 8\r\n", "output": ["8"]}, {"input": "18 67 5\r\n", "output": ["67"]}, {"input": "67 81 1\r\n", "output": ["67"]}, {"input": "51 10 91\r\n", "output": ["91"]}, {"input": "48 6 7\r\n", "output": ["48"]}, {"input": "8 97 83\r\n", "output": ["97"]}, {"input": "2 7 95\r\n", "output": ["95"]}, {"input": "772486757 1747374885 377299255\r\n", "output": ["772486757"]}, {"input": "1358352906 27037371 1947040615\r\n", "output": ["1947040615"]}, {"input": "1944219055 454183506 1369298327\r\n", "output": ["1944219055"]}, {"input": "382601556 881329640 791556039\r\n", "output": ["881329640"]}, {"input": "246543403 71853598 1504509195\r\n", "output": ["1504509195"]}, {"input": "50606342 2 1134945035\r\n", "output": ["50606342"]}, {"input": "9 530792195 6\r\n", "output": ["530792195"]}, {"input": "1016450951 2 9\r\n", "output": ["1016450951"]}, {"input": "3 10 1007169359\r\n", "output": ["1007169359"]}, {"input": "0 1 0\r\n", "output": ["0"]}, {"input": "1 0 0\r\n", "output": ["0"]}, {"input": "0 0 1\r\n", "output": ["0"]}, {"input": "3 2 0\r\n", "output": ["2"]}, {"input": "0 3 2\r\n", "output": ["2"]}, {"input": "3 0 2\r\n", "output": ["2"]}, {"input": "10 10 0\r\n", "output": ["10"]}, {"input": "0 0 10\r\n", "output": ["0"]}, {"input": "2 2 0\r\n", "output": ["2"]}, {"input": "0 2 10\r\n", "output": ["2"]}, {"input": "5 0 5\r\n", "output": ["5"]}, {"input": "5 9 0\r\n", "output": ["9"]}, {"input": "2147483648 2147483648 2147483648\r\n", "output": ["2147483648"]}, {"input": "2147483648 2147483647 2147483648\r\n", "output": ["2147483648"]}, {"input": "2147483648 0 0\r\n", "output": ["0"]}, {"input": "2147483648 2147483648 0\r\n", "output": ["2147483648"]}, {"input": "2147483648 0 2147483647\r\n", "output": ["2147483648"]}, {"input": "2147483630 2147483642 2147483610\r\n", "output": ["2147483630"]}, {"input": "1 4 3\r\n", "output": ["3"]}, {"input": "1 2 3\r\n", "output": ["3"]}, {"input": "1 0 1\r\n", "output": ["1"]}, {"input": "92134834 23742837 92374737\r\n", "output": ["92374737"]}, {"input": "92134834 23742837 92374738\r\n", "output": ["92374738"]}, {"input": "92134834 23742837 92374739\r\n", "output": ["92374739"]}, {"input": "9214834 2742837 9234739\r\n", "output": ["9234739"]}, {"input": "914835 2742837 9234739\r\n", "output": ["2742837"]}, {"input": "1 2 2147483648\r\n", "output": ["2147483648"]}, {"input": "0 0 58\r\n", "output": ["0"]}]
100
100
100
[{'input': '382601556 881329640 791556039\r\n', 'output': ['881329640']}, {'input': '6 8 10\r\n', 'output': ['8']}, {'input': '1 2 2147483648\r\n', 'output': ['2147483648']}, {'input': '8 97 83\r\n', 'output': ['97']}, {'input': '5 10 6\r\n', 'output': ['10']}]
[{'input': '5 9 0\r\n', 'output': ['9']}, {'input': '2 7 95\r\n', 'output': ['95']}, {'input': '3 1 0\r\n', 'output': ['3']}, {'input': '92134834 23742837 92374739\r\n', 'output': ['92374739']}, {'input': '0 2 10\r\n', 'output': ['2']}]
[{'input': '2147483648 0 2147483647\r\n', 'output': ['2147483648']}, {'input': '1 4 4\r\n', 'output': ['4']}, {'input': '772486757 1747374885 377299255\r\n', 'output': ['772486757']}, {'input': '1 0 1\r\n', 'output': ['1']}, {'input': '5 0 5\r\n', 'output': ['5']}]
[{'input': '1 1 1\r\n', 'output': ['1']}, {'input': '2147483630 2147483642 2147483610\r\n', 'output': ['2147483630']}, {'input': '48 6 7\r\n', 'output': ['48']}, {'input': '92134834 23742837 92374737\r\n', 'output': ['92374737']}, {'input': '9 530792195 6\r\n', 'output': ['530792195']}]
[{'input': '3 0 2\r\n', 'output': ['2']}, {'input': '772486757 1747374885 377299255\r\n', 'output': ['772486757']}, {'input': '3 1 0\r\n', 'output': ['3']}, {'input': '10 6 8\r\n', 'output': ['8']}, {'input': '6 8 10\r\n', 'output': ['8']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
123
100
100
100
["3 10 3 3", "3 10 1 3", "100 100 1 1000"]
The first line contains four space-separated integers k, a, b, v (2 ≤ k ≤ 1000; 1 ≤ a, b, v ≤ 1000) — the maximum number of sections in the box, the number of nuts, the number of divisors and the capacity of each section of the box.
7cff20b1c63a694baca69bdf4bdb2652
#include <bits/stdc++.h> using namespace std; int k, a, v, b, st, dr, piv; int check(int x){ int nr = min(x * (k-1), b); return ((x + nr) * v); } int main(){ // ifstream in("tst.in"); // ofstream out("tst.out"); cin >> k >> a >> b >> v; st = 1; dr = 10000; while(st <= dr){ piv = (st + dr) / 2; if(check(piv) >= a) dr = piv - 1; else st = piv + 1; } cout << st; return 0; }
["2", "3", "1"]
C++
NoteIn the first sample you can act like this: Put two divisors to the first box. Now the first box has three sections and we can put three nuts into each section. Overall, the first box will have nine nuts. Do not put any divisors into the second box. Thus, the second box has one section for the last nut. In the end we've put all the ten nuts into boxes.The second sample is different as we have exactly one divisor and we put it to the first box. The next two boxes will have one section each.
Print a single integer — the answer to the problem.
You have a nuts and lots of boxes. The boxes have a wonderful feature: if you put x (x ≥ 0) divisors (the spacial bars that can divide a box) to it, you get a box, divided into x + 1 sections.You are minimalist. Therefore, on the one hand, you are against dividing some box into more than k sections. On the other hand, you are against putting more than v nuts into some section of the box. What is the minimum number of boxes you have to use if you want to put all the nuts in boxes, and you have b divisors?Please note that you need to minimize the number of used boxes, not sections. You do not have to minimize the number of used divisors.
[{"input": "3 10 3 3\r\n", "output": ["2"]}, {"input": "3 10 1 3\r\n", "output": ["3"]}, {"input": "100 100 1 1000\r\n", "output": ["1"]}, {"input": "5 347 20 1\r\n", "output": ["327"]}, {"input": "6 978 10 5\r\n", "output": ["186"]}, {"input": "6 856 50 35\r\n", "output": ["5"]}, {"input": "8 399 13 36\r\n", "output": ["2"]}, {"input": "4 787 48 4\r\n", "output": ["149"]}, {"input": "4 714 7 6\r\n", "output": ["112"]}, {"input": "7 915 12 24\r\n", "output": ["27"]}, {"input": "8 995 3 28\r\n", "output": ["33"]}, {"input": "10 267 4 48\r\n", "output": ["2"]}, {"input": "10 697 1 34\r\n", "output": ["20"]}, {"input": "7 897 49 42\r\n", "output": ["4"]}, {"input": "10 849 3 28\r\n", "output": ["28"]}, {"input": "477 492 438 690\r\n", "output": ["1"]}, {"input": "461 790 518 105\r\n", "output": ["1"]}, {"input": "510 996 830 417\r\n", "output": ["1"]}, {"input": "763 193 388 346\r\n", "output": ["1"]}, {"input": "958 380 405 434\r\n", "output": ["1"]}, {"input": "346 991 4 4\r\n", "output": ["244"]}, {"input": "648 990 5 2\r\n", "output": ["490"]}, {"input": "810 1000 6 5\r\n", "output": ["194"]}, {"input": "683 995 10 1\r\n", "output": ["985"]}, {"input": "307 999 10 7\r\n", "output": ["133"]}, {"input": "974 999 3 4\r\n", "output": ["247"]}, {"input": "60 1000 2 2\r\n", "output": ["498"]}, {"input": "634 993 9 3\r\n", "output": ["322"]}, {"input": "579 990 8 9\r\n", "output": ["102"]}, {"input": "306 993 9 9\r\n", "output": ["102"]}, {"input": "845 996 1 1\r\n", "output": ["995"]}, {"input": "872 997 1 1\r\n", "output": ["996"]}, {"input": "2 990 1 1\r\n", "output": ["989"]}, {"input": "489 992 1 1\r\n", "output": ["991"]}, {"input": "638 1000 1 1\r\n", "output": ["999"]}, {"input": "2 4 1000 1\r\n", "output": ["2"]}]
100
100
100
[{'input': '763 193 388 346\r\n', 'output': ['1']}, {'input': '7 897 49 42\r\n', 'output': ['4']}, {'input': '6 856 50 35\r\n', 'output': ['5']}, {'input': '10 849 3 28\r\n', 'output': ['28']}, {'input': '3 10 1 3\r\n', 'output': ['3']}]
[{'input': '5 347 20 1\r\n', 'output': ['327']}, {'input': '763 193 388 346\r\n', 'output': ['1']}, {'input': '634 993 9 3\r\n', 'output': ['322']}, {'input': '461 790 518 105\r\n', 'output': ['1']}, {'input': '810 1000 6 5\r\n', 'output': ['194']}]
[{'input': '4 787 48 4\r\n', 'output': ['149']}, {'input': '477 492 438 690\r\n', 'output': ['1']}, {'input': '346 991 4 4\r\n', 'output': ['244']}, {'input': '683 995 10 1\r\n', 'output': ['985']}, {'input': '461 790 518 105\r\n', 'output': ['1']}]
[{'input': '10 849 3 28\r\n', 'output': ['28']}, {'input': '10 697 1 34\r\n', 'output': ['20']}, {'input': '4 714 7 6\r\n', 'output': ['112']}, {'input': '579 990 8 9\r\n', 'output': ['102']}, {'input': '8 399 13 36\r\n', 'output': ['2']}]
[{'input': '683 995 10 1\r\n', 'output': ['985']}, {'input': '5 347 20 1\r\n', 'output': ['327']}, {'input': '10 849 3 28\r\n', 'output': ['28']}, {'input': '10 697 1 34\r\n', 'output': ['20']}, {'input': '6 856 50 35\r\n', 'output': ['5']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
124
100
100
100
["2 10\n8 9", "3 5\n4 4 4"]
The first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ k) denoting marks received by Noora before Leha's hack.
f22267bf3fad0bf342ecf4c27ad3a900
#include<iostream> #include<cstdio> #include<string> #include<cmath> using namespace std; const int ok=500; int n,k,a[ok]; double sum,cnt; int av; int main() { scanf("%d%d",&n,&k); for(int i=1;i<=n;i++) { scanf("%d",&a[i]); sum+=a[i]; } int n1=n; cnt=sum*1.0/n; av=round(cnt); while(av!=k) { sum+=k; n++; cnt=sum*1.0/n; av=round(cnt); } printf("%d",n-n1); return 0; }
["4", "3"]
C++
NoteConsider the first example testcase.Maximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to . Consequently, new final mark is 10. Less number of marks won't fix the situation.In the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.
Print a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.
Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.In school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. For instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.To graduate with «A» certificate, Noora has to have mark k.Noora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.
[{"input": "2 10\r\n8 9\r\n", "output": ["4"]}, {"input": "3 5\r\n4 4 4\r\n", "output": ["3"]}, {"input": "3 10\r\n10 8 9\r\n", "output": ["3"]}, {"input": "2 23\r\n21 23\r\n", "output": ["2"]}, {"input": "5 10\r\n5 10 10 9 10\r\n", "output": ["7"]}, {"input": "12 50\r\n18 10 26 22 22 23 14 21 27 18 25 12\r\n", "output": ["712"]}, {"input": "38 12\r\n2 7 10 8 5 3 5 6 3 6 5 1 9 7 7 8 3 4 4 4 5 2 3 6 6 1 6 7 4 4 8 7 4 5 3 6 6 6\r\n", "output": ["482"]}, {"input": "63 86\r\n32 31 36 29 36 26 28 38 39 32 29 26 33 38 36 38 36 28 43 48 28 33 25 39 39 27 34 25 37 28 40 26 30 31 42 32 36 44 29 36 30 35 48 40 26 34 30 33 33 46 42 24 36 38 33 51 33 41 38 29 29 32 28\r\n", "output": ["6469"]}, {"input": "100 38\r\n30 24 38 31 31 33 32 32 29 34 29 22 27 23 34 25 32 30 30 26 16 27 38 33 38 38 37 34 32 27 33 23 33 32 24 24 30 36 29 30 33 30 29 30 36 33 33 35 28 24 30 32 38 29 30 36 31 30 27 38 31 36 15 37 32 27 29 24 38 33 28 29 34 21 37 35 32 31 27 25 27 28 31 31 36 38 35 35 36 29 35 22 38 31 38 28 31 27 34 31\r\n", "output": ["1340"]}, {"input": "33 69\r\n60 69 68 69 69 60 64 60 62 59 54 47 60 62 69 69 69 58 67 69 62 69 68 53 69 69 66 66 57 58 65 69 61\r\n", "output": ["329"]}, {"input": "39 92\r\n19 17 16 19 15 30 21 25 14 17 19 19 23 16 14 15 17 19 29 15 11 25 19 14 18 20 10 16 11 15 18 20 20 17 18 16 12 17 16\r\n", "output": ["5753"]}, {"input": "68 29\r\n29 29 29 29 29 28 29 29 29 27 29 29 29 29 29 29 29 23 29 29 26 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 26 29 29 29 29 29 29 29 29 29 29 29 29 22 29 29 29 29 29 29 29 29 29 29 29 29 29 28 29 29 29 29\r\n", "output": ["0"]}, {"input": "75 30\r\n22 18 21 26 23 18 28 30 24 24 19 25 28 30 23 29 18 23 23 30 26 30 17 30 18 19 25 26 26 15 27 23 30 21 19 26 25 30 25 28 20 22 22 21 26 17 23 23 24 15 25 19 18 22 30 30 29 21 30 28 28 30 27 25 24 15 22 19 30 21 20 30 18 20 25\r\n", "output": ["851"]}, {"input": "78 43\r\n2 7 6 5 5 6 4 5 3 4 6 8 4 5 5 4 3 1 2 4 4 6 5 6 4 4 6 4 8 4 6 5 6 1 4 5 6 3 2 5 2 5 3 4 8 8 3 3 4 4 6 6 5 4 5 5 7 9 3 9 6 4 7 3 6 9 6 5 1 7 2 5 6 3 6 2 5 4\r\n", "output": ["5884"]}, {"input": "82 88\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1\r\n", "output": ["14170"]}, {"input": "84 77\r\n28 26 36 38 37 44 48 34 40 22 42 35 40 37 30 31 33 35 36 55 47 36 33 47 40 38 27 38 36 33 35 31 47 33 30 38 38 47 49 24 38 37 28 43 39 36 34 33 29 38 36 43 48 38 36 34 33 34 35 31 26 33 39 37 37 37 35 52 47 30 24 46 38 26 43 46 41 50 33 40 36 41 37 30\r\n", "output": ["6650"]}, {"input": "94 80\r\n21 19 15 16 27 16 20 18 19 19 15 15 20 19 19 21 20 19 13 17 15 9 17 15 23 15 12 18 12 13 15 12 14 13 14 17 20 20 14 21 15 6 10 23 24 8 18 18 13 23 17 22 17 19 19 18 17 24 8 16 18 20 24 19 10 19 15 10 13 14 19 15 16 19 20 15 14 21 16 16 14 14 22 19 12 11 14 13 19 32 16 16 13 20\r\n", "output": ["11786"]}, {"input": "96 41\r\n13 32 27 34 28 34 30 26 21 24 29 20 25 34 25 16 27 15 22 22 34 22 25 19 23 17 17 22 26 24 23 20 21 27 19 33 13 24 22 18 30 30 27 14 26 24 20 20 22 11 19 31 19 29 18 28 30 22 17 15 28 32 17 24 17 24 24 19 26 23 22 29 18 22 23 29 19 32 26 23 22 22 24 23 27 30 24 25 21 21 33 19 35 27 34 28\r\n", "output": ["3182"]}, {"input": "1 26\r\n26\r\n", "output": ["0"]}, {"input": "99 39\r\n25 28 30 28 32 34 31 28 29 28 29 30 33 19 33 31 27 33 29 24 27 30 25 38 28 34 35 31 34 37 30 22 21 24 34 27 34 33 34 33 26 26 36 19 30 22 35 30 21 28 23 35 33 29 21 22 36 31 34 32 34 32 30 32 27 33 38 25 35 26 39 27 29 29 19 33 28 29 34 38 26 30 36 26 29 30 26 34 22 32 29 38 25 27 24 17 25 28 26\r\n", "output": ["1807"]}, {"input": "100 12\r\n7 6 6 3 5 5 9 8 7 7 4 7 12 6 9 5 6 3 4 7 9 10 7 7 5 3 9 6 9 9 6 7 4 10 4 8 8 6 9 8 6 5 7 4 10 7 5 6 8 9 3 4 8 5 4 8 6 10 5 8 7 5 9 8 5 8 5 6 9 11 4 9 5 5 11 4 6 6 7 3 8 9 6 7 10 4 7 6 9 4 8 11 5 4 10 8 5 10 11 4\r\n", "output": ["946"]}, {"input": "100 18\r\n1 2 2 2 2 2 1 1 1 2 3 1 3 1 1 4 2 4 1 2 1 2 1 3 2 1 2 1 1 1 2 1 2 2 1 1 4 3 1 1 2 1 3 3 2 1 2 2 1 1 1 1 3 1 1 2 2 1 1 1 5 1 2 1 3 2 2 1 4 2 2 1 1 1 1 1 1 1 1 2 2 1 2 1 1 1 2 1 2 2 2 1 1 3 1 1 2 1 1 2\r\n", "output": ["3164"]}, {"input": "100 27\r\n16 20 21 10 16 17 18 25 19 18 20 12 11 21 21 23 20 26 20 21 27 16 25 18 25 21 27 12 20 27 18 17 27 13 21 26 12 22 15 21 25 21 18 27 24 15 16 18 23 21 24 27 19 17 24 14 21 16 24 26 13 14 25 18 27 26 22 16 27 27 17 25 17 12 22 10 19 27 19 20 23 22 25 23 17 25 14 20 22 10 22 27 21 20 15 26 24 27 12 16\r\n", "output": ["1262"]}, {"input": "100 29\r\n20 18 23 24 14 14 16 23 22 17 18 22 21 21 19 19 14 11 18 19 16 22 25 20 14 13 21 24 18 16 18 29 17 25 12 10 18 28 11 16 17 14 15 20 17 20 18 22 10 16 16 20 18 19 29 18 25 27 17 19 24 15 24 25 16 23 19 16 16 20 19 15 12 21 20 13 21 15 15 23 16 23 17 13 17 21 13 18 17 18 18 20 16 12 19 15 27 14 11 18\r\n", "output": ["2024"]}, {"input": "100 30\r\n16 10 20 11 14 27 15 17 22 26 24 17 15 18 19 22 22 15 21 22 14 21 22 22 21 22 15 17 17 22 18 19 26 18 22 20 22 25 18 18 17 23 18 18 20 13 19 30 17 24 22 19 29 20 20 21 17 18 26 25 22 19 15 18 18 20 19 19 18 18 24 16 19 17 12 21 20 16 23 21 16 17 26 23 25 28 22 20 9 21 17 24 15 19 17 21 29 13 18 15\r\n", "output": ["1984"]}, {"input": "100 59\r\n56 58 53 59 59 48 59 54 46 59 59 58 48 59 55 59 59 50 59 56 59 59 59 59 59 59 59 57 59 53 45 53 50 59 50 55 58 54 59 56 54 59 59 59 59 48 56 59 59 57 59 59 48 43 55 57 39 59 46 55 55 52 58 57 51 59 59 59 59 53 59 43 51 54 46 59 57 43 50 59 47 58 59 59 59 55 46 56 55 59 56 47 56 56 46 51 47 48 59 55\r\n", "output": ["740"]}, {"input": "100 81\r\n6 7 6 6 7 6 6 6 3 9 4 5 4 3 4 6 6 6 1 3 9 5 2 3 8 5 6 9 6 6 6 5 4 4 7 7 3 6 11 7 6 4 8 7 12 6 4 10 2 4 9 11 7 4 7 7 8 8 6 7 9 8 4 5 8 13 6 6 6 8 6 2 5 6 7 5 4 4 4 4 2 6 4 8 3 4 7 7 6 7 7 10 5 10 6 7 4 11 8 4\r\n", "output": ["14888"]}, {"input": "100 100\r\n30 35 23 43 28 49 31 32 30 44 32 37 33 34 38 28 43 32 33 32 50 32 41 38 33 20 40 36 29 21 42 25 23 34 43 32 37 31 30 27 36 32 45 37 33 29 38 34 35 33 28 19 37 33 28 41 31 29 41 27 32 39 30 34 37 40 33 38 35 32 32 34 35 34 28 39 28 34 40 45 31 25 42 28 29 31 33 21 36 33 34 37 40 42 39 30 36 34 34 40\r\n", "output": ["13118"]}, {"input": "100 100\r\n71 87 100 85 89 98 90 90 71 65 76 75 85 100 81 100 91 80 73 89 86 78 82 89 77 92 78 90 100 81 85 89 73 100 66 60 72 88 91 73 93 76 88 81 86 78 83 77 74 93 97 94 85 78 82 78 91 91 100 78 89 76 78 82 81 78 83 88 87 83 78 98 85 97 98 89 88 75 76 86 74 81 70 76 86 84 99 100 89 94 72 84 82 88 83 89 78 99 87 76\r\n", "output": ["3030"]}, {"input": "100 100\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n", "output": ["19700"]}, {"input": "100 100\r\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100\r\n", "output": ["0"]}, {"input": "100 100\r\n1 1 2 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n", "output": ["19696"]}, {"input": "100 100\r\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 99\r\n", "output": ["0"]}, {"input": "100 100\r\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 98 100 100 100 100 98 100 100 100 100 100 100 99 98 100 100 93 100 100 98 100 100 100 100 93 100 96 100 100 100 94 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 95 88 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100\r\n", "output": ["0"]}, {"input": "100 100\r\n95 100 100 100 100 100 100 100 100 100 100 100 100 100 87 100 100 100 94 100 100 100 100 100 100 100 100 100 100 100 100 99 100 100 100 100 100 100 100 100 100 100 90 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 97 100 100 100 96 100 98 100 100 100 100 100 96 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 97 100 100 100 100\r\n", "output": ["2"]}, {"input": "100 1\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n", "output": ["0"]}, {"input": "100 2\r\n2 1 1 2 1 1 1 1 2 2 2 2 1 1 1 2 1 1 1 2 2 2 2 1 1 1 1 2 2 2 1 2 2 2 2 1 2 2 1 1 1 1 1 1 2 2 1 2 1 1 1 2 1 2 2 2 2 1 1 1 2 2 1 2 1 1 1 2 1 2 2 1 1 1 2 2 1 1 2 1 1 2 1 1 1 2 1 1 1 1 2 1 1 1 1 2 1 2 1 1\r\n", "output": ["16"]}, {"input": "3 5\r\n5 5 5\r\n", "output": ["0"]}, {"input": "7 7\r\n1 1 1 1 1 1 1\r\n", "output": ["77"]}, {"input": "1 1\r\n1\r\n", "output": ["0"]}, {"input": "4 10\r\n10 10 10 10\r\n", "output": ["0"]}, {"input": "1 10\r\n10\r\n", "output": ["0"]}, {"input": "10 1\r\n1 1 1 1 1 1 1 1 1 1\r\n", "output": ["0"]}, {"input": "3 10\r\n10 10 10\r\n", "output": ["0"]}, {"input": "2 4\r\n3 4\r\n", "output": ["0"]}, {"input": "1 2\r\n2\r\n", "output": ["0"]}, {"input": "3 4\r\n4 4 4\r\n", "output": ["0"]}, {"input": "3 2\r\n2 2 1\r\n", "output": ["0"]}, {"input": "5 5\r\n5 5 5 5 5\r\n", "output": ["0"]}, {"input": "3 3\r\n3 3 3\r\n", "output": ["0"]}, {"input": "2 9\r\n8 9\r\n", "output": ["0"]}, {"input": "3 10\r\n9 10 10\r\n", "output": ["0"]}, {"input": "1 3\r\n3\r\n", "output": ["0"]}, {"input": "2 2\r\n1 2\r\n", "output": ["0"]}, {"input": "2 10\r\n10 10\r\n", "output": ["0"]}, {"input": "23 14\r\n7 11 13 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14\r\n", "output": ["0"]}, {"input": "2 10\r\n9 10\r\n", "output": ["0"]}, {"input": "2 2\r\n2 2\r\n", "output": ["0"]}, {"input": "10 5\r\n5 5 5 5 5 5 5 5 5 4\r\n", "output": ["0"]}, {"input": "3 5\r\n4 5 5\r\n", "output": ["0"]}, {"input": "5 4\r\n4 4 4 4 4\r\n", "output": ["0"]}, {"input": "2 10\r\n10 9\r\n", "output": ["0"]}, {"input": "4 5\r\n3 5 5 5\r\n", "output": ["0"]}, {"input": "10 5\r\n5 5 5 5 5 5 5 5 5 5\r\n", "output": ["0"]}, {"input": "3 10\r\n10 10 9\r\n", "output": ["0"]}, {"input": "5 1\r\n1 1 1 1 1\r\n", "output": ["0"]}, {"input": "2 1\r\n1 1\r\n", "output": ["0"]}, {"input": "4 10\r\n9 10 10 10\r\n", "output": ["0"]}, {"input": "5 2\r\n2 2 2 2 2\r\n", "output": ["0"]}, {"input": "2 5\r\n4 5\r\n", "output": ["0"]}, {"input": "5 10\r\n10 10 10 10 10\r\n", "output": ["0"]}, {"input": "2 6\r\n6 6\r\n", "output": ["0"]}, {"input": "2 9\r\n9 9\r\n", "output": ["0"]}, {"input": "3 10\r\n10 9 10\r\n", "output": ["0"]}, {"input": "4 40\r\n39 40 40 40\r\n", "output": ["0"]}, {"input": "3 4\r\n3 4 4\r\n", "output": ["0"]}, {"input": "9 9\r\n9 9 9 9 9 9 9 9 9\r\n", "output": ["0"]}, {"input": "1 4\r\n4\r\n", "output": ["0"]}, {"input": "4 7\r\n1 1 1 1\r\n", "output": ["44"]}, {"input": "1 5\r\n5\r\n", "output": ["0"]}, {"input": "3 1\r\n1 1 1\r\n", "output": ["0"]}, {"input": "1 100\r\n100\r\n", "output": ["0"]}, {"input": "2 7\r\n3 5\r\n", "output": ["10"]}, {"input": "3 6\r\n6 6 6\r\n", "output": ["0"]}, {"input": "4 2\r\n1 2 2 2\r\n", "output": ["0"]}, {"input": "4 5\r\n4 5 5 5\r\n", "output": ["0"]}, {"input": "5 5\r\n1 1 1 1 1\r\n", "output": ["35"]}, {"input": "66 2\r\n1 2 2 2 2 1 1 2 1 2 2 2 2 2 2 1 2 1 2 1 2 1 2 1 2 1 1 1 1 2 2 1 2 2 1 1 2 1 2 2 1 1 1 2 1 2 1 2 1 2 1 2 2 2 2 1 2 2 1 2 1 1 1 2 2 1\r\n", "output": ["0"]}, {"input": "2 2\r\n2 1\r\n", "output": ["0"]}, {"input": "5 5\r\n5 5 5 4 5\r\n", "output": ["0"]}, {"input": "3 7\r\n1 1 1\r\n", "output": ["33"]}, {"input": "2 5\r\n5 5\r\n", "output": ["0"]}, {"input": "1 7\r\n1\r\n", "output": ["11"]}, {"input": "6 7\r\n1 1 1 1 1 1\r\n", "output": ["66"]}, {"input": "99 97\r\n15 80 78 69 12 84 36 51 89 77 88 10 1 19 67 85 6 36 8 70 14 45 88 97 22 13 75 57 83 27 13 97 9 90 68 51 76 37 5 2 16 92 11 48 13 77 35 19 15 74 22 29 21 12 28 42 56 5 32 41 62 75 71 71 68 72 24 77 11 28 78 27 53 88 74 66 1 42 18 16 18 39 75 38 81 5 13 39 40 75 13 36 53 83 9 54 57 63 64\r\n", "output": ["10077"]}, {"input": "8 7\r\n1 1 1 1 1 1 1 1\r\n", "output": ["88"]}, {"input": "3 2\r\n2 2 2\r\n", "output": ["0"]}, {"input": "6 5\r\n5 5 5 5 5 5\r\n", "output": ["0"]}, {"input": "10 5\r\n5 5 5 5 5 5 5 4 1 1\r\n", "output": ["8"]}, {"input": "1 5\r\n1\r\n", "output": ["7"]}, {"input": "10 10\r\n10 10 10 10 10 10 10 10 10 10\r\n", "output": ["0"]}, {"input": "2 3\r\n2 3\r\n", "output": ["0"]}, {"input": "1 9\r\n9\r\n", "output": ["0"]}, {"input": "74 2\r\n2 2 2 2 1 2 2 1 1 1 2 2 1 2 2 2 2 1 2 1 1 1 2 1 1 2 2 1 2 1 1 2 1 1 2 2 2 2 2 2 2 2 1 2 2 2 1 2 2 1 1 2 1 1 1 1 1 1 2 2 2 1 1 1 1 1 2 2 2 2 2 2 1 2\r\n", "output": ["0"]}, {"input": "5 5\r\n5 5 5 5 4\r\n", "output": ["0"]}]
100
100
100
[{'input': '5 10\r\n10 10 10 10 10\r\n', 'output': ['0']}, {'input': '100 100\r\n71 87 100 85 89 98 90 90 71 65 76 75 85 100 81 100 91 80 73 89 86 78 82 89 77 92 78 90 100 81 85 89 73 100 66 60 72 88 91 73 93 76 88 81 86 78 83 77 74 93 97 94 85 78 82 78 91 91 100 78 89 76 78 82 81 78 83 88 87 83 78 98 85 97 98 89 88 75 76 86 74 81 70 76 86 84 99 100 89 94 72 84 82 88 83 89 78 99 87 76\r\n', 'output': ['3030']}, {'input': '3 10\r\n10 9 10\r\n', 'output': ['0']}, {'input': '96 41\r\n13 32 27 34 28 34 30 26 21 24 29 20 25 34 25 16 27 15 22 22 34 22 25 19 23 17 17 22 26 24 23 20 21 27 19 33 13 24 22 18 30 30 27 14 26 24 20 20 22 11 19 31 19 29 18 28 30 22 17 15 28 32 17 24 17 24 24 19 26 23 22 29 18 22 23 29 19 32 26 23 22 22 24 23 27 30 24 25 21 21 33 19 35 27 34 28\r\n', 'output': ['3182']}, {'input': '100 100\r\n30 35 23 43 28 49 31 32 30 44 32 37 33 34 38 28 43 32 33 32 50 32 41 38 33 20 40 36 29 21 42 25 23 34 43 32 37 31 30 27 36 32 45 37 33 29 38 34 35 33 28 19 37 33 28 41 31 29 41 27 32 39 30 34 37 40 33 38 35 32 32 34 35 34 28 39 28 34 40 45 31 25 42 28 29 31 33 21 36 33 34 37 40 42 39 30 36 34 34 40\r\n', 'output': ['13118']}]
[{'input': '3 6\r\n6 6 6\r\n', 'output': ['0']}, {'input': '78 43\r\n2 7 6 5 5 6 4 5 3 4 6 8 4 5 5 4 3 1 2 4 4 6 5 6 4 4 6 4 8 4 6 5 6 1 4 5 6 3 2 5 2 5 3 4 8 8 3 3 4 4 6 6 5 4 5 5 7 9 3 9 6 4 7 3 6 9 6 5 1 7 2 5 6 3 6 2 5 4\r\n', 'output': ['5884']}, {'input': '12 50\r\n18 10 26 22 22 23 14 21 27 18 25 12\r\n', 'output': ['712']}, {'input': '99 39\r\n25 28 30 28 32 34 31 28 29 28 29 30 33 19 33 31 27 33 29 24 27 30 25 38 28 34 35 31 34 37 30 22 21 24 34 27 34 33 34 33 26 26 36 19 30 22 35 30 21 28 23 35 33 29 21 22 36 31 34 32 34 32 30 32 27 33 38 25 35 26 39 27 29 29 19 33 28 29 34 38 26 30 36 26 29 30 26 34 22 32 29 38 25 27 24 17 25 28 26\r\n', 'output': ['1807']}, {'input': '1 5\r\n1\r\n', 'output': ['7']}]
[{'input': '1 5\r\n1\r\n', 'output': ['7']}, {'input': '2 1\r\n1 1\r\n', 'output': ['0']}, {'input': '96 41\r\n13 32 27 34 28 34 30 26 21 24 29 20 25 34 25 16 27 15 22 22 34 22 25 19 23 17 17 22 26 24 23 20 21 27 19 33 13 24 22 18 30 30 27 14 26 24 20 20 22 11 19 31 19 29 18 28 30 22 17 15 28 32 17 24 17 24 24 19 26 23 22 29 18 22 23 29 19 32 26 23 22 22 24 23 27 30 24 25 21 21 33 19 35 27 34 28\r\n', 'output': ['3182']}, {'input': '2 3\r\n2 3\r\n', 'output': ['0']}, {'input': '4 40\r\n39 40 40 40\r\n', 'output': ['0']}]
[{'input': '5 2\r\n2 2 2 2 2\r\n', 'output': ['0']}, {'input': '7 7\r\n1 1 1 1 1 1 1\r\n', 'output': ['77']}, {'input': '2 5\r\n5 5\r\n', 'output': ['0']}, {'input': '1 2\r\n2\r\n', 'output': ['0']}, {'input': '5 4\r\n4 4 4 4 4\r\n', 'output': ['0']}]
[{'input': '100 1\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n', 'output': ['0']}, {'input': '1 100\r\n100\r\n', 'output': ['0']}, {'input': '10 5\r\n5 5 5 5 5 5 5 4 1 1\r\n', 'output': ['8']}, {'input': '1 10\r\n10\r\n', 'output': ['0']}, {'input': '4 2\r\n1 2 2 2\r\n', 'output': ['0']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
125
100
100
100
["12345", "09"]
The first line contains nonempty sequence consisting of digits from 0 to 9 — Masha's phone number. The sequence length does not exceed 50.
2dd8bb6e8182278d037aa3a59ca3517b
#include <bits/stdc++.h> using namespace std; #define MX (int)1e6+1 #define pb push_back #define ip pair<int,int> #define ll long long #define INF 70 const ll mod = 1e9 + 7; #define fastIO ios_base::sync_with_stdio(0);cin.tie(0); ll dp[55][10][10],n; string input; ll solver(int pos,int fav,int last){ if(pos==n)return 1; ll &ret=dp[pos][fav][last]; if(~ret)return ret; ret=0; if(pos==0){ for(int i=0;i<=9;i++){ ret+=solver(pos+1,i,i); } return ret; } int choice1=(input[pos]-'0'+last)/2; int choice2=(input[pos]-'0'+last+1)/2; ret+=solver(pos+1,fav,choice1); if(choice2!=choice1)ret+=solver(pos+1,fav,choice2); return ret; } int main() {fastIO memset(dp,-1, sizeof(dp)); cin>>input; n=input.length(); ll ans=solver(0,0,0); for(int i=1;i<n;i++){ if(abs(input[i]-input[i-1])>1)return cout<<ans,0; } cout<<ans-1; return 0;}
["48", "15"]
C++
null
Output the single number — the number of phone numbers Masha will dial.
Alas, finding one's true love is not easy. Masha has been unsuccessful in that yet. Her friend Dasha told Masha about a way to determine the phone number of one's Prince Charming through arithmancy. The phone number is divined like that. First one needs to write down one's own phone numbers. For example, let's suppose that Masha's phone number is 12345. After that one should write her favorite digit from 0 to 9 under the first digit of her number. That will be the first digit of the needed number. For example, Masha's favorite digit is 9. The second digit is determined as a half sum of the second digit of Masha's number and the already written down first digit from her beloved one's number. In this case the arithmetic average equals to (2 + 9) / 2 = 5.5. Masha can round the number up or down, depending on her wishes. For example, she chooses the digit 5. Having written down the resulting digit under the second digit of her number, Masha moves to finding the third digit in the same way, i.e. finding the half sum the the third digit of her number and the second digit of the new number. The result is (5 + 3) / 2 = 4. In this case the answer is unique. Thus, every i-th digit is determined as an arithmetic average of the i-th digit of Masha's number and the i - 1-th digit of her true love's number. If needed, the digit can be rounded up or down. For example, Masha can get: 12345 95444 Unfortunately, when Masha tried dialing the number, she got disappointed: as it turned out, the number was unavailable or outside the coverage area. But Masha won't give up. Perhaps, she rounded to a wrong digit or chose the first digit badly. That's why she keeps finding more and more new numbers and calling them. Count the number of numbers Masha calls. Masha calls all the possible numbers that can be found by the described means of arithmancy, except for, perhaps, her own one.
[{"input": "12345\r\n", "output": ["48"]}, {"input": "09\r\n", "output": ["15"]}, {"input": "3\r\n", "output": ["9"]}, {"input": "55\r\n", "output": ["14"]}, {"input": "737\r\n", "output": ["23"]}, {"input": "21583\r\n", "output": ["55"]}, {"input": "33408349\r\n", "output": ["133"]}, {"input": "0180990956\r\n", "output": ["473"]}, {"input": "433488906230138\r\n", "output": ["1399"]}, {"input": "00046142930690780976\r\n", "output": ["35257"]}, {"input": "317579445234107659439645596\r\n", "output": ["145866"]}, {"input": "95066916647678224147260013920\r\n", "output": ["446529"]}, {"input": "36460576924876475371008334246121610\r\n", "output": ["31319157"]}, {"input": "429622625617508557672595893160462042433748844995\r\n", "output": ["284175107"]}, {"input": "17601120900014764776764048700928872725171605903217\r\n", "output": ["10428170619"]}, {"input": "39884857105160870767160905699169880375621726152715\r\n", "output": ["244663375"]}, {"input": "52056884218028089650567882557609167736461846591193\r\n", "output": ["1358962463"]}, {"input": "74239501210975375541963549337949373386030687741681\r\n", "output": ["3422420940"]}, {"input": "96591550315931484452350406227169651758570705180260\r\n", "output": ["6869183484"]}, {"input": "10764487327809690332754482187409867297140746339768\r\n", "output": ["3435387051"]}, {"input": "44444444444444444444444444444444444444444444444444\r\n", "output": ["631"]}, {"input": "9876543210\r\n", "output": ["157"]}, {"input": "23321232101010000101232344554334\r\n", "output": ["5316368"]}, {"input": "3232345665654567888878887898999998788766654567878\r\n", "output": ["2520209072"]}, {"input": "78776656654555655544443212222101121000000000100000\r\n", "output": ["164642009"]}, {"input": "78767765544454334445445555455676565433343455432332\r\n", "output": ["11031574582"]}, {"input": "67676566654565654332111011212211111223433222110012\r\n", "output": ["5882859948"]}]
100
100
100
[{'input': '55\r\n', 'output': ['14']}, {'input': '737\r\n', 'output': ['23']}, {'input': '23321232101010000101232344554334\r\n', 'output': ['5316368']}, {'input': '9876543210\r\n', 'output': ['157']}, {'input': '36460576924876475371008334246121610\r\n', 'output': ['31319157']}]
[{'input': '74239501210975375541963549337949373386030687741681\r\n', 'output': ['3422420940']}, {'input': '17601120900014764776764048700928872725171605903217\r\n', 'output': ['10428170619']}, {'input': '95066916647678224147260013920\r\n', 'output': ['446529']}, {'input': '21583\r\n', 'output': ['55']}, {'input': '9876543210\r\n', 'output': ['157']}]
[{'input': '74239501210975375541963549337949373386030687741681\r\n', 'output': ['3422420940']}, {'input': '10764487327809690332754482187409867297140746339768\r\n', 'output': ['3435387051']}, {'input': '39884857105160870767160905699169880375621726152715\r\n', 'output': ['244663375']}, {'input': '67676566654565654332111011212211111223433222110012\r\n', 'output': ['5882859948']}, {'input': '737\r\n', 'output': ['23']}]
[{'input': '78767765544454334445445555455676565433343455432332\r\n', 'output': ['11031574582']}, {'input': '0180990956\r\n', 'output': ['473']}, {'input': '9876543210\r\n', 'output': ['157']}, {'input': '21583\r\n', 'output': ['55']}, {'input': '36460576924876475371008334246121610\r\n', 'output': ['31319157']}]
[{'input': '74239501210975375541963549337949373386030687741681\r\n', 'output': ['3422420940']}, {'input': '12345\r\n', 'output': ['48']}, {'input': '78776656654555655544443212222101121000000000100000\r\n', 'output': ['164642009']}, {'input': '317579445234107659439645596\r\n', 'output': ['145866']}, {'input': '39884857105160870767160905699169880375621726152715\r\n', 'output': ['244663375']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
126
100
100
100
["2 3\n1 1", "3 2\n0 0", "1 10\n5 3"]
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n, k \le 100\,000$$$) — the number of fast food restaurants on the circle and the distance between the neighboring restaurants, respectively. The second line contains two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le \frac{k}{2}$$$) — the distances to the nearest fast food restaurants from the initial city and from the city Sergey made the first stop at, respectively.
5bb4adff1b332f43144047955eefba0c
#include <bits/stdc++.h> using namespace std; #define mod 1000000007 #define ll long long #define N 100005 #define all(v) v.begin(),v.end() #define pii pair<int,int> #define print(x) cout << #x << "=" << x << "\t"; ll n; ll k; ll a; ll b; ll ma = -1e18; ll mi = 1e18; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> k >> a >> b; for(ll i=0;i<=n;i++) { ll l = i * k + b + a; if (l <= 0) continue; ll g = __gcd(n * k, l); ll lcm = n * k / g; ma = max(ma, lcm); mi = min(mi, lcm); } for(ll i=0;i<=n;i++) { ll l = (i + 1) * k - b + a; ll g = __gcd(n * k, l); ll lcm = n * k / g; ma = max(ma, lcm); mi = min(mi, lcm); } for(ll i=0;i<=n;i++) { ll l = (i + 1) * k - a + b; ll g = __gcd(n * k, l); ll lcm = n * k / g; ma = max(ma, lcm); mi = min(mi, lcm); } for(ll i=0;i<=n;i++) { ll l = (i + 2) * k - a - b; ll g = __gcd(n * k, l); ll lcm = n * k / g; ma = max(ma, lcm); mi = min(mi, lcm); } cout << mi << " " << ma; return 0; }
["1 6", "1 3", "5 5"]
C++
NoteIn the first example the restaurants are located in the cities $$$1$$$ and $$$4$$$, the initial city $$$s$$$ could be $$$2$$$, $$$3$$$, $$$5$$$, or $$$6$$$. The next city Sergey stopped at could also be at cities $$$2, 3, 5, 6$$$. Let's loop through all possible combinations of these cities. If both $$$s$$$ and the city of the first stop are at the city $$$2$$$ (for example, $$$l = 6$$$), then Sergey is at $$$s$$$ after the first stop already, so $$$x = 1$$$. In other pairs Sergey needs $$$1, 2, 3$$$, or $$$6$$$ stops to return to $$$s$$$, so $$$y = 6$$$.In the second example Sergey was at cities with fast food restaurant both initially and after the first stop, so $$$l$$$ is $$$2$$$, $$$4$$$, or $$$6$$$. Thus $$$x = 1$$$, $$$y = 3$$$.In the third example there is only one restaurant, so the possible locations of $$$s$$$ and the first stop are: $$$(6, 8)$$$ and $$$(6, 4)$$$. For the first option $$$l = 2$$$, for the second $$$l = 8$$$. In both cases Sergey needs $$$x=y=5$$$ stops to go to $$$s$$$.
Print the two integers $$$x$$$ and $$$y$$$.
Recently a Golden Circle of Beetlovers was found in Byteland. It is a circle route going through $$$n \cdot k$$$ cities. The cities are numerated from $$$1$$$ to $$$n \cdot k$$$, the distance between the neighboring cities is exactly $$$1$$$ km.Sergey does not like beetles, he loves burgers. Fortunately for him, there are $$$n$$$ fast food restaurants on the circle, they are located in the $$$1$$$-st, the $$$(k + 1)$$$-st, the $$$(2k + 1)$$$-st, and so on, the $$$((n-1)k + 1)$$$-st cities, i.e. the distance between the neighboring cities with fast food restaurants is $$$k$$$ km.Sergey began his journey at some city $$$s$$$ and traveled along the circle, making stops at cities each $$$l$$$ km ($$$l &gt; 0$$$), until he stopped in $$$s$$$ once again. Sergey then forgot numbers $$$s$$$ and $$$l$$$, but he remembers that the distance from the city $$$s$$$ to the nearest fast food restaurant was $$$a$$$ km, and the distance from the city he stopped at after traveling the first $$$l$$$ km from $$$s$$$ to the nearest fast food restaurant was $$$b$$$ km. Sergey always traveled in the same direction along the circle, but when he calculated distances to the restaurants, he considered both directions.Now Sergey is interested in two integers. The first integer $$$x$$$ is the minimum number of stops (excluding the first) Sergey could have done before returning to $$$s$$$. The second integer $$$y$$$ is the maximum number of stops (excluding the first) Sergey could have done before returning to $$$s$$$.
[{"input": "2 3\r\n1 1\r\n", "output": ["1 6"]}, {"input": "3 2\r\n0 0\r\n", "output": ["1 3"]}, {"input": "1 10\r\n5 3\r\n", "output": ["5 5"]}, {"input": "3 3\r\n1 0\r\n", "output": ["9 9"]}, {"input": "4 3\r\n1 1\r\n", "output": ["1 12"]}, {"input": "5 5\r\n2 2\r\n", "output": ["1 25"]}, {"input": "6 3\r\n1 1\r\n", "output": ["1 18"]}, {"input": "3 10\r\n1 3\r\n", "output": ["5 15"]}, {"input": "2 1\r\n0 0\r\n", "output": ["1 2"]}, {"input": "1 100\r\n0 0\r\n", "output": ["1 1"]}, {"input": "39 17\r\n8 5\r\n", "output": ["17 663"]}, {"input": "147 149\r\n74 33\r\n", "output": ["149 21903"]}, {"input": "100000 100\r\n21 29\r\n", "output": ["64 2500000"]}, {"input": "100000 100000\r\n50000 50000\r\n", "output": ["1 100000"]}, {"input": "16127 18181\r\n6581 2408\r\n", "output": ["18181 293204987"]}, {"input": "96557 28657\r\n2964 7036\r\n", "output": ["28657 2767033949"]}, {"input": "96557 4\r\n0 2\r\n", "output": ["2 193114"]}, {"input": "2 98763\r\n10021 19979\r\n", "output": ["32921 197526"]}, {"input": "10 99990\r\n3 7\r\n", "output": ["9999 499950"]}, {"input": "99999 23782\r\n0 0\r\n", "output": ["1 99999"]}, {"input": "14621 29242\r\n7 13\r\n", "output": ["213773641 213773641"]}, {"input": "23981 21841\r\n10376 10637\r\n", "output": ["21841 523769021"]}, {"input": "21013 45013\r\n693 307\r\n", "output": ["45013 945858169"]}, {"input": "36739 36739\r\n18369 18369\r\n", "output": ["1 1349754121"]}, {"input": "65536 32768\r\n6427 13573\r\n", "output": ["67108864 1073741824"]}, {"input": "99871 99877\r\n5273 34727\r\n", "output": ["99877 9974815867"]}, {"input": "99871 99873\r\n2979 17955\r\n", "output": ["11097 1108268487"]}, {"input": "99873 99876\r\n24862 13862\r\n", "output": ["1189 2493728937"]}, {"input": "99079 99053\r\n49479 49521\r\n", "output": ["99053 9814072187"]}, {"input": "95911 95917\r\n47946 47954\r\n", "output": ["95917 9199495387"]}, {"input": "89527 91159\r\n44571 44990\r\n", "output": ["91159 8161191793"]}, {"input": "98752 97209\r\n41218 39020\r\n", "output": ["21427641 3199861056"]}, {"input": "100000 100000\r\n10 1\r\n", "output": ["10000000000 10000000000"]}, {"input": "100000 100000\r\n0 1\r\n", "output": ["10000000000 10000000000"]}, {"input": "97979 85648\r\n41517 20663\r\n", "output": ["21412 4195852696"]}, {"input": "100000 99737\r\n34242 43667\r\n", "output": ["99737 9973700000"]}, {"input": "806 654\r\n118 76\r\n", "output": ["109 263562"]}]
100
100
100
[{'input': '4 3\r\n1 1\r\n', 'output': ['1 12']}, {'input': '36739 36739\r\n18369 18369\r\n', 'output': ['1 1349754121']}, {'input': '100000 100000\r\n0 1\r\n', 'output': ['10000000000 10000000000']}, {'input': '2 1\r\n0 0\r\n', 'output': ['1 2']}, {'input': '3 3\r\n1 0\r\n', 'output': ['9 9']}]
[{'input': '1 10\r\n5 3\r\n', 'output': ['5 5']}, {'input': '16127 18181\r\n6581 2408\r\n', 'output': ['18181 293204987']}, {'input': '1 100\r\n0 0\r\n', 'output': ['1 1']}, {'input': '3 10\r\n1 3\r\n', 'output': ['5 15']}, {'input': '99079 99053\r\n49479 49521\r\n', 'output': ['99053 9814072187']}]
[{'input': '3 2\r\n0 0\r\n', 'output': ['1 3']}, {'input': '89527 91159\r\n44571 44990\r\n', 'output': ['91159 8161191793']}, {'input': '98752 97209\r\n41218 39020\r\n', 'output': ['21427641 3199861056']}, {'input': '23981 21841\r\n10376 10637\r\n', 'output': ['21841 523769021']}, {'input': '3 10\r\n1 3\r\n', 'output': ['5 15']}]
[{'input': '4 3\r\n1 1\r\n', 'output': ['1 12']}, {'input': '95911 95917\r\n47946 47954\r\n', 'output': ['95917 9199495387']}, {'input': '3 2\r\n0 0\r\n', 'output': ['1 3']}, {'input': '96557 28657\r\n2964 7036\r\n', 'output': ['28657 2767033949']}, {'input': '99871 99877\r\n5273 34727\r\n', 'output': ['99877 9974815867']}]
[{'input': '99999 23782\r\n0 0\r\n', 'output': ['1 99999']}, {'input': '4 3\r\n1 1\r\n', 'output': ['1 12']}, {'input': '89527 91159\r\n44571 44990\r\n', 'output': ['91159 8161191793']}, {'input': '3 10\r\n1 3\r\n', 'output': ['5 15']}, {'input': '99873 99876\r\n24862 13862\r\n', 'output': ['1189 2493728937']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
127
100
100
100
["9 9 5 5 2 1", "100 100 52 50 46 56"]
The first line contains six integers n, m, x, y, a, b (1 ≤ n, m ≤ 109, 0 ≤ x ≤ n, 0 ≤ y ≤ m, 1 ≤ a ≤ n, 1 ≤ b ≤ m).
8f1211b995f35462ae83b2be27f54585
#include <iostream> #include <stdio.h> #include <algorithm> #include <string.h> #include <set> using namespace std; #define ll long long int n,m,x,y,a,b; int main() { // freopen("in.txt","r",stdin); cin>>n>>m>>x>>y>>a>>b; ll t=__gcd(a,b); a/=t; b/=t; ll lx,ly; lx=n/a*a; ly=m/b*b; if(lx*b>a*ly) { lx=ly/b*a; }else ly=lx/a*b; // cout<<a<<endl; // cout<<b<<endl; // cout<<lx<<endl; // cout<<ly<<endl; ll x2=x+(lx>>1); ll y2=y+(ly>>1); ll x1=x2-lx; ll y1=y2-ly; ll mx=x1<0?-x1:x2>n?n-x2:0; ll my=y1<0?-y1:y2>m?m-y2:0; printf("%lld %lld %lld %lld\n",x1+mx,y1+my,x2+mx,y2+my); // mx=my=0; // prllf("%d %d %d %d\n",x1+mx,y1+my,x2+mx,y2+my); return 0; }
["1 3 9 7", "17 8 86 92"]
C++
null
Print four integers x1, y1, x2, y2, which represent the founded sub-rectangle whose left-bottom point is (x1, y1) and right-up point is (x2, y2).
You are given a rectangle grid. That grid's size is n × m. Let's denote the coordinate system on the grid. So, each point on the grid will have coordinates — a pair of integers (x, y) (0 ≤ x ≤ n, 0 ≤ y ≤ m).Your task is to find a maximum sub-rectangle on the grid (x1, y1, x2, y2) so that it contains the given point (x, y), and its length-width ratio is exactly (a, b). In other words the following conditions must hold: 0 ≤ x1 ≤ x ≤ x2 ≤ n, 0 ≤ y1 ≤ y ≤ y2 ≤ m, .The sides of this sub-rectangle should be parallel to the axes. And values x1, y1, x2, y2 should be integers. If there are multiple solutions, find the rectangle which is closest to (x, y). Here "closest" means the Euclid distance between (x, y) and the center of the rectangle is as small as possible. If there are still multiple solutions, find the lexicographically minimum one. Here "lexicographically minimum" means that we should consider the sub-rectangle as sequence of integers (x1, y1, x2, y2), so we can choose the lexicographically minimum one.
[{"input": "9 9 5 5 2 1\r\n", "output": ["1 3 9 7"]}, {"input": "100 100 52 50 46 56\r\n", "output": ["17 8 86 92"]}, {"input": "100 100 16 60 42 75\r\n", "output": ["0 0 56 100"]}, {"input": "100 100 28 22 47 50\r\n", "output": ["0 0 94 100"]}, {"input": "100 100 44 36 96 21\r\n", "output": ["0 25 96 46"]}, {"input": "100 100 56 46 1 47\r\n", "output": ["55 0 57 94"]}, {"input": "100 100 20 53 6 22\r\n", "output": ["6 1 33 100"]}, {"input": "100 100 32 63 2 41\r\n", "output": ["30 18 34 100"]}, {"input": "100 100 48 73 63 16\r\n", "output": ["16 65 79 81"]}, {"input": "100 100 13 59 14 20\r\n", "output": ["0 0 70 100"]}, {"input": "36830763 28058366 30827357 20792295 11047103 20670351\r\n", "output": ["25303805 7388015 36350908 28058366"]}, {"input": "87453374 60940601 74141787 32143714 78082907 33553425\r\n", "output": ["9370467 15367001 87453374 48920426"]}, {"input": "71265727 62692710 12444778 3479306 21442685 5463351\r\n", "output": ["0 0 64328055 16390053"]}, {"input": "48445042 43730155 14655564 6244917 43454856 2866363\r\n", "output": ["0 4811735 43454856 7678098"]}, {"input": "85759276 82316701 8242517 1957176 10225118 547026\r\n", "output": ["0 0 81800944 4376208"]}, {"input": "64748258 21983760 9107246 2437546 11247507 8924750\r\n", "output": ["0 0 22495014 17849500"]}, {"input": "6561833 24532010 2773123 457562 6225818 23724637\r\n", "output": ["0 0 6225818 23724637"]}, {"input": "33417574 19362112 17938303 4013355 10231192 2596692\r\n", "output": ["166200 0 33417574 8439249"]}, {"input": "98540143 28776614 12080542 1456439 96484500 3125739\r\n", "output": ["0 0 96484500 3125739"]}, {"input": "75549175 99860242 42423626 6574859 73199290 26030615\r\n", "output": ["2349885 0 75549175 26030615"]}, {"input": "4309493 76088457 2523467 46484812 909115 53662610\r\n", "output": ["1887086 960803 3159847 76088457"]}, {"input": "99373741 10548319 82293354 9865357 58059929 5328757\r\n", "output": ["41313812 5219562 99373741 10548319"]}, {"input": "81460 7041354 53032 1297536 41496 5748697\r\n", "output": ["27916 0 78148 6958949"]}, {"input": "5664399 63519726 1914884 13554302 2435218 44439020\r\n", "output": ["697275 0 3132493 44439020"]}, {"input": "19213492 76256257 10302871 19808004 19174729 55280126\r\n", "output": ["38763 0 19213492 55280126"]}, {"input": "61430678 95017800 11901852 27772249 25202227 87778634\r\n", "output": ["0 0 25202227 87778634"]}, {"input": "1063740 2675928 277215 2022291 204933 298547\r\n", "output": ["0 1183193 1024665 2675928"]}, {"input": "71580569 68590917 4383746 13851161 9868376 8579752\r\n", "output": ["0 0 71545726 62203202"]}, {"input": "17818532 82586436 8482338 54895799 12444902 11112345\r\n", "output": ["2259887 49339626 14704789 60451971"]}, {"input": "63651025 50179036 16141802 24793214 28944209 13993078\r\n", "output": ["0 10800136 57888418 38786292"]}, {"input": "11996821 42550832 8901163 19214381 3510233 20406511\r\n", "output": ["4976355 0 11996821 40813022"]}, {"input": "27048166 72584165 4785744 2001800 24615554 27645416\r\n", "output": ["0 0 24615554 27645416"]}, {"input": "47001271 53942737 7275347 1652337 33989593 48660013\r\n", "output": ["0 0 33989593 48660013"]}, {"input": "51396415 50182729 20810973 38206844 17823753 2905275\r\n", "output": ["0 34333144 47530008 42080544"]}, {"input": "27087649 52123970 20327636 19640608 8481031 14569965\r\n", "output": ["1644556 0 27087649 43709895"]}, {"input": "41635044 16614992 36335190 11150551 30440245 13728274\r\n", "output": ["11194799 2886718 41635044 16614992"]}, {"input": "97253692 35192249 21833856 26094161 41611668 32149284\r\n", "output": ["0 363858 45079307 35192249"]}, {"input": "60300478 3471217 11842517 3192374 27980820 507119\r\n", "output": ["0 2456979 55961640 3471217"]}, {"input": "69914272 30947694 58532705 25740028 30431847 27728130\r\n", "output": ["39482425 3219564 69914272 30947694"]}, {"input": "83973381 91192149 19059738 26429459 49573749 78006738\r\n", "output": ["0 0 49573749 78006738"]}, {"input": "1000000000 1000000000 286536427 579261823 230782719 575570138\r\n", "output": ["171145067 291476754 401927786 867046892"]}, {"input": "1000000000 1000000000 42362139 725664533 91213476 617352813\r\n", "output": ["0 176862916 121617968 1000000000"]}, {"input": "1000000000 1000000000 503220555 167034539 244352073 511651840\r\n", "output": ["276322201 0 730118908 950210560"]}, {"input": "1000000000 1000000000 259046267 313437250 252266478 848401810\r\n", "output": ["132913028 0 385179506 848401810"]}, {"input": "1000000000 1000000000 867388331 312356312 405405075 887925029\r\n", "output": ["594594925 0 1000000000 887925029"]}, {"input": "1000000000 1000000000 623214043 753726318 970868535 929707704\r\n", "output": ["29131465 70292296 1000000000 1000000000"]}, {"input": "1000000000 1000000000 84072459 754904836 124007132 824006731\r\n", "output": ["22068893 175993269 146076025 1000000000"]}, {"input": "1000000000 1000000000 839898171 196274842 131921537 865789406\r\n", "output": ["773937402 0 905858939 865789406"]}, {"input": "1000000000 1000000000 448240235 342677552 992352294 907572080\r\n", "output": ["0 0 992352294 907572080"]}, {"input": "1000000000 1000000000 837887296 643696230 478881476 45404539\r\n", "output": ["42237048 598291691 1000000000 689100769"]}, {"input": "1000000000 500 1000 400 11 122\r\n", "output": ["978 12 1022 500"]}, {"input": "1000000000 1000000000 1000000000 1000000000 1 1\r\n", "output": ["0 0 1000000000 1000000000"]}, {"input": "1000000000 1000000000 1000000000 1000000000 1000000000 1\r\n", "output": ["0 999999999 1000000000 1000000000"]}, {"input": "1000000000 999999999 1000 1000 1000000000 999999999\r\n", "output": ["0 0 1000000000 999999999"]}, {"input": "70 10 20 5 5 3\r\n", "output": ["12 0 27 9"]}, {"input": "1000000000 1000000000 500000000 500000000 500000000 500000001\r\n", "output": ["250000000 249999999 750000000 750000000"]}]
100
100
100
[{'input': '4309493 76088457 2523467 46484812 909115 53662610\r\n', 'output': ['1887086 960803 3159847 76088457']}, {'input': '100 100 32 63 2 41\r\n', 'output': ['30 18 34 100']}, {'input': '27087649 52123970 20327636 19640608 8481031 14569965\r\n', 'output': ['1644556 0 27087649 43709895']}, {'input': '100 100 16 60 42 75\r\n', 'output': ['0 0 56 100']}, {'input': '87453374 60940601 74141787 32143714 78082907 33553425\r\n', 'output': ['9370467 15367001 87453374 48920426']}]
[{'input': '100 100 20 53 6 22\r\n', 'output': ['6 1 33 100']}, {'input': '81460 7041354 53032 1297536 41496 5748697\r\n', 'output': ['27916 0 78148 6958949']}, {'input': '1063740 2675928 277215 2022291 204933 298547\r\n', 'output': ['0 1183193 1024665 2675928']}, {'input': '27087649 52123970 20327636 19640608 8481031 14569965\r\n', 'output': ['1644556 0 27087649 43709895']}, {'input': '97253692 35192249 21833856 26094161 41611668 32149284\r\n', 'output': ['0 363858 45079307 35192249']}]
[{'input': '33417574 19362112 17938303 4013355 10231192 2596692\r\n', 'output': ['166200 0 33417574 8439249']}, {'input': '1000000000 1000000000 1000000000 1000000000 1000000000 1\r\n', 'output': ['0 999999999 1000000000 1000000000']}, {'input': '48445042 43730155 14655564 6244917 43454856 2866363\r\n', 'output': ['0 4811735 43454856 7678098']}, {'input': '100 100 13 59 14 20\r\n', 'output': ['0 0 70 100']}, {'input': '1000000000 1000000000 84072459 754904836 124007132 824006731\r\n', 'output': ['22068893 175993269 146076025 1000000000']}]
[{'input': '1000000000 1000000000 1000000000 1000000000 1 1\r\n', 'output': ['0 0 1000000000 1000000000']}, {'input': '100 100 28 22 47 50\r\n', 'output': ['0 0 94 100']}, {'input': '11996821 42550832 8901163 19214381 3510233 20406511\r\n', 'output': ['4976355 0 11996821 40813022']}, {'input': '33417574 19362112 17938303 4013355 10231192 2596692\r\n', 'output': ['166200 0 33417574 8439249']}, {'input': '1000000000 1000000000 837887296 643696230 478881476 45404539\r\n', 'output': ['42237048 598291691 1000000000 689100769']}]
[{'input': '1000000000 1000000000 867388331 312356312 405405075 887925029\r\n', 'output': ['594594925 0 1000000000 887925029']}, {'input': '48445042 43730155 14655564 6244917 43454856 2866363\r\n', 'output': ['0 4811735 43454856 7678098']}, {'input': '1000000000 1000000000 84072459 754904836 124007132 824006731\r\n', 'output': ['22068893 175993269 146076025 1000000000']}, {'input': '41635044 16614992 36335190 11150551 30440245 13728274\r\n', 'output': ['11194799 2886718 41635044 16614992']}, {'input': '100 100 44 36 96 21\r\n', 'output': ['0 25 96 46']}]
100
100
100
100
100
100
100
100
100
100
100
90
100
90
100
128
100
100
96
["2 4 2", "6 13 1", "1 4 3"]
A single line contains three space-separated integers a, b, k (1 ≤ a, b, k ≤ 106; a ≤ b).
3e1751a2990134f2132d743afe02a10e
#include <iostream> using namespace std; int a,b,k,q[1000006]; bool pr[1000006]; int main (){ cin >> a >> b >> k; pr[1] = 1; for (int i = 2; i*i <= b; i++){ if (pr[i] == 0){ for(int j = i*i; j <= b; j+=i) pr[j] = 1; } } for (int i = 1; i <= b; i++){ q[i]+=q[i - 1]; if (pr[i] == 0) q[i]++; } int x = k,l,y = b - a + 1,ans = -1; if (x > y) {cout<<-1; return 0;} while (x < y){ l = (x + y) >> 1; int w = 0; for (int i = a; i <= b - l + 1; i++) if (q[i + l - 1] - q[i - 1] < k) {w = -1; break;} if (w == 0) {y = l; ans = l;} else x = l + 1; } l = x; int w = 0; for (int i = a; i <= b - l + 1; i++) if (q[i + l - 1] - q[i - 1] < k) {w = -1; break;} if (w == 0) ans = l; cout<<ans; }
["3", "4", "-1"]
C++
null
In a single line print a single integer — the required minimum l. If there's no solution, print -1.
You've decided to carry out a survey in the theory of prime numbers. Let us remind you that a prime number is a positive integer that has exactly two distinct positive integer divisors.Consider positive integers a, a + 1, ..., b (a ≤ b). You want to find the minimum integer l (1 ≤ l ≤ b - a + 1) such that for any integer x (a ≤ x ≤ b - l + 1) among l integers x, x + 1, ..., x + l - 1 there are at least k prime numbers. Find and print the required minimum l. If no value l meets the described limitations, print -1.
[{"input": "2 4 2\r\n", "output": ["3"]}, {"input": "6 13 1\r\n", "output": ["4"]}, {"input": "1 4 3\r\n", "output": ["-1"]}, {"input": "5 8 2\r\n", "output": ["4"]}, {"input": "8 10 3\r\n", "output": ["-1"]}, {"input": "1 5 2\r\n", "output": ["3"]}, {"input": "6 8 3\r\n", "output": ["-1"]}, {"input": "21 29 2\r\n", "output": ["9"]}, {"input": "17 27 3\r\n", "output": ["11"]}, {"input": "1 1000000 10000\r\n", "output": ["137970"]}, {"input": "690059 708971 10000\r\n", "output": ["-1"]}, {"input": "12357 534133 2\r\n", "output": ["138"]}, {"input": "838069 936843 3\r\n", "output": ["142"]}, {"input": "339554 696485 4\r\n", "output": ["168"]}, {"input": "225912 522197 5\r\n", "output": ["190"]}, {"input": "404430 864261 6\r\n", "output": ["236"]}, {"input": "689973 807140 7\r\n", "output": ["236"]}, {"input": "177146 548389 8\r\n", "output": ["240"]}, {"input": "579857 857749 9\r\n", "output": ["300"]}, {"input": "35648 527231 10\r\n", "output": ["280"]}, {"input": "2 1000000 10000\r\n", "output": ["137970"]}, {"input": "1 999999 9999\r\n", "output": ["137958"]}, {"input": "5 5 10\r\n", "output": ["-1"]}, {"input": "11 11 6\r\n", "output": ["-1"]}, {"input": "4 4 95\r\n", "output": ["-1"]}, {"input": "1 1000000 1000000\r\n", "output": ["-1"]}, {"input": "1 1000000 78498\r\n", "output": ["999999"]}, {"input": "1 1000000 78499\r\n", "output": ["-1"]}, {"input": "3459 94738 1\r\n", "output": ["72"]}, {"input": "1 1000000 1\r\n", "output": ["114"]}, {"input": "1 1000000 78497\r\n", "output": ["999998"]}, {"input": "1 1000000 78490\r\n", "output": ["999978"]}, {"input": "1000 10000 13\r\n", "output": ["168"]}, {"input": "100000 1000000 7821\r\n", "output": ["108426"]}, {"input": "20 1000000 40000\r\n", "output": ["539580"]}, {"input": "1000 900000 50000\r\n", "output": ["659334"]}, {"input": "10000 1000000 60000\r\n", "output": ["793662"]}, {"input": "9999 99999 8000\r\n", "output": ["86572"]}, {"input": "50 150 20\r\n", "output": ["100"]}, {"input": "999953 999953 1\r\n", "output": ["1"]}, {"input": "999953 999953 2\r\n", "output": ["-1"]}, {"input": "999931 999953 2\r\n", "output": ["23"]}, {"input": "999906 999984 4\r\n", "output": ["52"]}, {"input": "999940 999983 3\r\n", "output": ["26"]}, {"input": "1 1 1\r\n", "output": ["-1"]}, {"input": "1 1 1000000\r\n", "output": ["-1"]}, {"input": "1 2 1\r\n", "output": ["2"]}, {"input": "1 3 1\r\n", "output": ["2"]}, {"input": "1 3 2\r\n", "output": ["3"]}, {"input": "1 4 2\r\n", "output": ["3"]}, {"input": "1 5 3\r\n", "output": ["5"]}, {"input": "2 5 2\r\n", "output": ["3"]}, {"input": "3 5 1\r\n", "output": ["2"]}]
100
100
100
[{'input': '4 4 95\r\n', 'output': ['-1']}, {'input': '12357 534133 2\r\n', 'output': ['138']}, {'input': '5 5 10\r\n', 'output': ['-1']}, {'input': '579857 857749 9\r\n', 'output': ['300']}, {'input': '1000 900000 50000\r\n', 'output': ['659334']}]
[{'input': '20 1000000 40000\r\n', 'output': ['539580']}, {'input': '1 1000000 78499\r\n', 'output': ['-1']}, {'input': '8 10 3\r\n', 'output': ['-1']}, {'input': '6 8 3\r\n', 'output': ['-1']}, {'input': '1 2 1\r\n', 'output': ['2']}]
[{'input': '404430 864261 6\r\n', 'output': ['236']}, {'input': '2 5 2\r\n', 'output': ['3']}, {'input': '689973 807140 7\r\n', 'output': ['236']}, {'input': '100000 1000000 7821\r\n', 'output': ['108426']}, {'input': '5 5 10\r\n', 'output': ['-1']}]
[{'input': '690059 708971 10000\r\n', 'output': ['-1']}, {'input': '1 5 2\r\n', 'output': ['3']}, {'input': '21 29 2\r\n', 'output': ['9']}, {'input': '1000 10000 13\r\n', 'output': ['168']}, {'input': '1 4 3\r\n', 'output': ['-1']}]
[{'input': '404430 864261 6\r\n', 'output': ['236']}, {'input': '2 5 2\r\n', 'output': ['3']}, {'input': '1 5 2\r\n', 'output': ['3']}, {'input': '177146 548389 8\r\n', 'output': ['240']}, {'input': '690059 708971 10000\r\n', 'output': ['-1']}]
100
100
100
100
100
100
100
100
100
100
92.31
96.15
92.31
96.15
96.15
129
100
100
94.614
["5 2 433416647", "10 3 409693891", "65 4 177545087"]
The single line of the input contains three integers n, d and mod (1 ≤ n ≤ 1000, 2 ≤ d ≤ 10, 108 ≤ mod ≤ 109)  — the number of vertices in the tree, the degree of internal vertices and the prime modulo.
bdd0fc1d6dbab5eeb5aea135fdfffc9d
#include <bits/stdc++.h> using namespace std; const int maxn=1005; const int maxd=11; long long n,d,mod,dp[maxn][maxd],pd[maxn][maxd],f,t[maxd]; inline long long ksm(long long x,long long n) { long long ret=1; while (n) { if (n&1) ret=ret*x%mod; n>>=1; x=x*x%mod; } return ret; } inline long long solve() { dp[1][0]=1; for (int i=1;i<=n/2;++i) {//if (i%(d-1)==0) { f=(i==1)?1:dp[i][d-1]; for (int j=1;j<=n;++j) for (int k=0;k<=d;++k) pd[j][k]=0; t[0]=1; for (int j=1;j<=d;++j) t[j]=t[j-1]*(f+j-1)%mod*ksm(j,mod-2)%mod; for (int j=0;j<=d;++j) for (int k=0;k<=d;++k) if (j+k<=d) for (int l=1;l<=n;++l) if (l+i*k<=n) pd[l+i*k][j+k]=(pd[l+i*k][j+k]+dp[l][j]*t[k])%mod; for (int j=0;j<=n;++j) for (int k=0;k<=d;++k) //if (pd[j][k]) dp[j][k]=pd[j][k]; } long long ret=dp[n][d]; if (n%2==0) ret=((ret-dp[n/2][d-1]*(dp[n/2][d-1]-1)/2)%mod+mod)%mod; return ret; } int main() { scanf("%I64d%I64d%I64d",&n,&d,&mod); if (n<=2) puts("1"); else printf("%I64d\n",solve()); return 0; }
["1", "2", "910726"]
C++
null
Print the number of trees over the modulo mod.
A tree is a connected graph without cycles.Two trees, consisting of n vertices each, are called isomorphic if there exists a permutation p: {1, ..., n} → {1, ..., n} such that the edge (u, v) is present in the first tree if and only if the edge (pu, pv) is present in the second tree.Vertex of the tree is called internal if its degree is greater than or equal to two.Count the number of different non-isomorphic trees, consisting of n vertices, such that the degree of each internal vertex is exactly d. Print the answer over the given prime modulo mod.
[{"input": "5 2 433416647\r\n", "output": ["1"]}, {"input": "10 3 409693891\r\n", "output": ["2"]}, {"input": "65 4 177545087\r\n", "output": ["910726"]}, {"input": "2 2 434448163\r\n", "output": ["1"]}, {"input": "2 3 434448163\r\n", "output": ["1"]}, {"input": "2 4 434448163\r\n", "output": ["1"]}, {"input": "2 5 434448163\r\n", "output": ["1"]}, {"input": "180 3 434448163\r\n", "output": ["106622108"]}, {"input": "104 7 434448163\r\n", "output": ["47207"]}, {"input": "106 9 434448163\r\n", "output": ["1296"]}, {"input": "1 4 904448911\r\n", "output": ["1"]}, {"input": "2 6 904448911\r\n", "output": ["1"]}, {"input": "2 7 904448911\r\n", "output": ["1"]}, {"input": "2 8 904448911\r\n", "output": ["1"]}, {"input": "102 4 904448911\r\n", "output": ["0"]}, {"input": "2 9 904448911\r\n", "output": ["1"]}, {"input": "2 10 904448911\r\n", "output": ["1"]}, {"input": "100 2 944036243\r\n", "output": ["1"]}, {"input": "101 4 944036243\r\n", "output": ["467334192"]}, {"input": "102 5 944036243\r\n", "output": ["74266477"]}, {"input": "102 6 944036243\r\n", "output": ["748711"]}, {"input": "100 8 944036243\r\n", "output": ["3128"]}, {"input": "101 10 944036243\r\n", "output": ["235"]}, {"input": "1 2 727733989\r\n", "output": ["1"]}, {"input": "1 3 727733989\r\n", "output": ["1"]}, {"input": "1 5 727733989\r\n", "output": ["1"]}, {"input": "1 6 727733989\r\n", "output": ["1"]}, {"input": "1 7 727733989\r\n", "output": ["1"]}, {"input": "1 8 727733989\r\n", "output": ["1"]}, {"input": "1 9 837744727\r\n", "output": ["1"]}, {"input": "1 10 837744727\r\n", "output": ["1"]}, {"input": "999 3 837744727\r\n", "output": ["0"]}, {"input": "1000 5 970400047\r\n", "output": ["0"]}, {"input": "1000 6 970400047\r\n", "output": ["0"]}, {"input": "1000 7 970400047\r\n", "output": ["0"]}, {"input": "1000 8 750160753\r\n", "output": ["0"]}, {"input": "1000 9 750160753\r\n", "output": ["0"]}, {"input": "1000 10 750160753\r\n", "output": ["0"]}, {"input": "1000 2 750160753\r\n", "output": ["1"]}, {"input": "1000 3 750160753\r\n", "output": ["16572167"]}, {"input": "998 4 817408561\r\n", "output": ["443073705"]}, {"input": "998 5 680633279\r\n", "output": ["233182629"]}, {"input": "997 6 680633279\r\n", "output": ["148277591"]}, {"input": "998 7 930423869\r\n", "output": ["167343048"]}, {"input": "996 8 990767311\r\n", "output": ["350615945"]}, {"input": "994 9 390528763\r\n", "output": ["211625777"]}, {"input": "992 10 762763321\r\n", "output": ["571064998"]}, {"input": "983 10 762763321\r\n", "output": ["663665406"]}, {"input": "989 8 990767311\r\n", "output": ["976760285"]}, {"input": "992 6 680633279\r\n", "output": ["451750559"]}, {"input": "995 4 817408561\r\n", "output": ["36421881"]}, {"input": "999 2 750160753\r\n", "output": ["1"]}]
100
100
100
[{'input': '5 2 433416647\r\n', 'output': ['1']}, {'input': '104 7 434448163\r\n', 'output': ['47207']}, {'input': '996 8 990767311\r\n', 'output': ['350615945']}, {'input': '1 2 727733989\r\n', 'output': ['1']}, {'input': '995 4 817408561\r\n', 'output': ['36421881']}]
[{'input': '1 4 904448911\r\n', 'output': ['1']}, {'input': '1000 3 750160753\r\n', 'output': ['16572167']}, {'input': '1000 2 750160753\r\n', 'output': ['1']}, {'input': '106 9 434448163\r\n', 'output': ['1296']}, {'input': '999 2 750160753\r\n', 'output': ['1']}]
[{'input': '999 2 750160753\r\n', 'output': ['1']}, {'input': '65 4 177545087\r\n', 'output': ['910726']}, {'input': '102 4 904448911\r\n', 'output': ['0']}, {'input': '5 2 433416647\r\n', 'output': ['1']}, {'input': '2 2 434448163\r\n', 'output': ['1']}]
[{'input': '1000 5 970400047\r\n', 'output': ['0']}, {'input': '1 8 727733989\r\n', 'output': ['1']}, {'input': '998 5 680633279\r\n', 'output': ['233182629']}, {'input': '989 8 990767311\r\n', 'output': ['976760285']}, {'input': '180 3 434448163\r\n', 'output': ['106622108']}]
[{'input': '992 10 762763321\r\n', 'output': ['571064998']}, {'input': '1 3 727733989\r\n', 'output': ['1']}, {'input': '1000 3 750160753\r\n', 'output': ['16572167']}, {'input': '102 6 944036243\r\n', 'output': ['748711']}, {'input': '2 3 434448163\r\n', 'output': ['1']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
96.88
130
100
100
99.376
["5 11", "6 16"]
The only line of the input contains two integers $$$n$$$ and $$$S$$$ ($$$1 \le n \le 100\,000$$$, $$$1 \le S \le 10^9$$$)
04c067326ec897091c3dbcf4d134df96
#include <iostream> #include <cstdio> #include <cctype> #define il inline #define vd void #define rep(i,x,y) for(register int i=x;i<=y;++i) #define drp(i,x,y) for(register int i=x;i>=y;--i) using namespace std; const int Len=2333333; char buf[Len],*p1=buf,*p2=buf,duf[Len],*q1=duf; il char gc(); il int rd(); il vd pc(char c); il vd rt(int x); il vd flush(); int n,s; int main(){//sjn AK IOI cin>>n>>s; int ans=s/n; if(s%n) ++ans; cout<<ans; return flush(),0; } il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;} il int rd(){char c; while(!isdigit(c=gc())&&c!='-'); int f=c=='-'?c=gc(),1:0,x=c^48; while(isdigit(c=gc())) x=((x+(x<<2))<<1)+(c^48); return f?-x:x; } il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;} il vd rt(int x){x<0?pc('-'),x=-x:0,pc((x>=10?rt(x/10),x%10:x)+48);} il vd flush(){fwrite(duf,1,q1-duf,stdout);}
["3", "3"]
C++
NoteIn the first example, some of the possible ways to get sum $$$11$$$ with $$$3$$$ coins are: $$$(3, 4, 4)$$$ $$$(2, 4, 5)$$$ $$$(1, 5, 5)$$$ $$$(3, 3, 5)$$$ It is impossible to get sum $$$11$$$ with less than $$$3$$$ coins.In the second example, some of the possible ways to get sum $$$16$$$ with $$$3$$$ coins are: $$$(5, 5, 6)$$$ $$$(4, 6, 6)$$$ It is impossible to get sum $$$16$$$ with less than $$$3$$$ coins.
Print exactly one integer — the minimum number of coins required to obtain sum $$$S$$$.
You have unlimited number of coins with values $$$1, 2, \ldots, n$$$. You want to select some set of coins having the total value of $$$S$$$. It is allowed to have multiple coins with the same value in the set. What is the minimum number of coins required to get sum $$$S$$$?
[{"input": "5 11\r\n", "output": ["3"]}, {"input": "6 16\r\n", "output": ["3"]}, {"input": "14 28\r\n", "output": ["2"]}, {"input": "5 29\r\n", "output": ["6"]}, {"input": "10 24\r\n", "output": ["3"]}, {"input": "1 30\r\n", "output": ["30"]}, {"input": "14969 66991573\r\n", "output": ["4476"]}, {"input": "1 1000000000\r\n", "output": ["1000000000"]}, {"input": "100000 1\r\n", "output": ["1"]}, {"input": "10 46\r\n", "output": ["5"]}, {"input": "11 35\r\n", "output": ["4"]}, {"input": "12 45\r\n", "output": ["4"]}, {"input": "15 34\r\n", "output": ["3"]}, {"input": "31859 629091638\r\n", "output": ["19747"]}, {"input": "15666 689919612\r\n", "output": ["44040"]}, {"input": "90681 254480989\r\n", "output": ["2807"]}, {"input": "69018 523197828\r\n", "output": ["7581"]}, {"input": "1352 434805201\r\n", "output": ["321602"]}, {"input": "73439 384841883\r\n", "output": ["5241"]}, {"input": "42482 352232377\r\n", "output": ["8292"]}, {"input": "57862 374476819\r\n", "output": ["6472"]}, {"input": "41711 440229650\r\n", "output": ["10555"]}, {"input": "46602 894472145\r\n", "output": ["19194"]}, {"input": "47832 942980453\r\n", "output": ["19715"]}, {"input": "22951 747845288\r\n", "output": ["32585"]}, {"input": "76998 722886555\r\n", "output": ["9389"]}, {"input": "68666 512525633\r\n", "output": ["7465"]}, {"input": "66269 356663481\r\n", "output": ["5383"]}, {"input": "56624 922065652\r\n", "output": ["16285"]}, {"input": "31618 26008350\r\n", "output": ["823"]}, {"input": "90952 904040054\r\n", "output": ["9940"]}, {"input": "49630 947487392\r\n", "output": ["19092"]}, {"input": "45084 431878651\r\n", "output": ["9580"]}, {"input": "7156 806580442\r\n", "output": ["112714"]}, {"input": "2 193379347\r\n", "output": ["96689674"]}, {"input": "6 823813339\r\n", "output": ["137302224"]}, {"input": "5 939845324\r\n", "output": ["187969065"]}, {"input": "7 236413222\r\n", "output": ["33773318"]}, {"input": "10 695784696\r\n", "output": ["69578470"]}, {"input": "3 877026418\r\n", "output": ["292342140"]}, {"input": "8 550991517\r\n", "output": ["68873940"]}, {"input": "6 899779610\r\n", "output": ["149963269"]}, {"input": "12 394018478\r\n", "output": ["32834874"]}, {"input": "66 63576176\r\n", "output": ["963276"]}, {"input": "66 982670621\r\n", "output": ["14888949"]}, {"input": "8 750191967\r\n", "output": ["93773996"]}, {"input": "10 349992600\r\n", "output": ["34999260"]}, {"input": "65 281828001\r\n", "output": ["4335816"]}, {"input": "53 468285594\r\n", "output": ["8835578"]}, {"input": "83 361125900\r\n", "output": ["4350915"]}, {"input": "15 191203328\r\n", "output": ["12746889"]}, {"input": "100000 1000000000\r\n", "output": ["10000"]}, {"input": "2 999999999\r\n", "output": ["500000000"]}, {"input": "2 1000000000\r\n", "output": ["500000000"]}, {"input": "4821 917142246\r\n", "output": ["190240"]}]
100
100
100
[{'input': '5 11\r\n', 'output': ['3']}, {'input': '2 999999999\r\n', 'output': ['500000000']}, {'input': '11 35\r\n', 'output': ['4']}, {'input': '47832 942980453\r\n', 'output': ['19715']}, {'input': '12 45\r\n', 'output': ['4']}]
[{'input': '4821 917142246\r\n', 'output': ['190240']}, {'input': '12 394018478\r\n', 'output': ['32834874']}, {'input': '90952 904040054\r\n', 'output': ['9940']}, {'input': '1 1000000000\r\n', 'output': ['1000000000']}, {'input': '66269 356663481\r\n', 'output': ['5383']}]
[{'input': '73439 384841883\r\n', 'output': ['5241']}, {'input': '2 999999999\r\n', 'output': ['500000000']}, {'input': '7 236413222\r\n', 'output': ['33773318']}, {'input': '45084 431878651\r\n', 'output': ['9580']}, {'input': '6 16\r\n', 'output': ['3']}]
[{'input': '1 1000000000\r\n', 'output': ['1000000000']}, {'input': '45084 431878651\r\n', 'output': ['9580']}, {'input': '8 750191967\r\n', 'output': ['93773996']}, {'input': '5 11\r\n', 'output': ['3']}, {'input': '10 46\r\n', 'output': ['5']}]
[{'input': '3 877026418\r\n', 'output': ['292342140']}, {'input': '83 361125900\r\n', 'output': ['4350915']}, {'input': '8 750191967\r\n', 'output': ['93773996']}, {'input': '45084 431878651\r\n', 'output': ['9580']}, {'input': '8 550991517\r\n', 'output': ['68873940']}]
100
100
100
100
100
100
100
100
100
100
50
100
50
100
50
131
100
100
70
["1 3", "3 2", "5 0"]
The first line of the input contains two space-separated integers n and m (0 ≤ n, m ≤ 1 000 000, n + m &gt; 0) — the number of students using two-block pieces and the number of students using three-block pieces, respectively.
23f2c8cac07403899199abdcfd947a5a
#include <iostream> #include <stdio.h> #include <algorithm> #include <vector> #include <cmath> #include <map> #include <stack> #include <queue> #include <stdlib.h> #include <string.h> #include <string> #define sqr(x) (x)*(x) #define fi first #define se second #define ONLINE_JUDGE using namespace std; typedef long long ll; const int mod=int(1e9+7); int n,m; int main(){ #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif //ONLINE_JUDGE scanf("%d%d",&n,&m); for (int i=0; ; i++){ if (i/2>=n && i/3>=m && i/2+i/3-i/6>=n+m){ printf("%d",i); break; } } #ifndef ONLINE_JUDGE fclose(stdin); fclose(stdout); #endif // ONLINE_JUDGE return 0; }
["9", "8", "10"]
C++
NoteIn the first case, the student using two-block pieces can make a tower of height 4, and the students using three-block pieces can make towers of height 3, 6, and 9 blocks. The tallest tower has a height of 9 blocks.In the second case, the students can make towers of heights 2, 4, and 8 with two-block pieces and towers of heights 3 and 6 with three-block pieces, for a maximum height of 8 blocks.
Print a single integer, denoting the minimum possible height of the tallest tower.
Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks.The students don’t want to use too many blocks, but they also want to be unique, so no two students’ towers may contain the same number of blocks. Find the minimum height necessary for the tallest of the students' towers.
[{"input": "1 3\r\n", "output": ["9"]}, {"input": "3 2\r\n", "output": ["8"]}, {"input": "5 0\r\n", "output": ["10"]}, {"input": "4 2\r\n", "output": ["9"]}, {"input": "0 1000000\r\n", "output": ["3000000"]}, {"input": "1000000 1\r\n", "output": ["2000000"]}, {"input": "1083 724\r\n", "output": ["2710"]}, {"input": "1184 868\r\n", "output": ["3078"]}, {"input": "1285 877\r\n", "output": ["3243"]}, {"input": "820189 548173\r\n", "output": ["2052543"]}, {"input": "968867 651952\r\n", "output": ["2431228"]}, {"input": "817544 553980\r\n", "output": ["2057286"]}, {"input": "813242 543613\r\n", "output": ["2035282"]}, {"input": "961920 647392\r\n", "output": ["2413968"]}, {"input": "825496 807050\r\n", "output": ["2448819"]}, {"input": "974174 827926\r\n", "output": ["2703150"]}, {"input": "969872 899794\r\n", "output": ["2804499"]}, {"input": "818549 720669\r\n", "output": ["2308827"]}, {"input": "967227 894524\r\n", "output": ["2792626"]}, {"input": "185253 152723\r\n", "output": ["506964"]}, {"input": "195173 150801\r\n", "output": ["518961"]}, {"input": "129439 98443\r\n", "output": ["341823"]}, {"input": "163706 157895\r\n", "output": ["482402"]}, {"input": "197973 140806\r\n", "output": ["508168"]}, {"input": "1000000 1000000\r\n", "output": ["3000000"]}, {"input": "1000000 999999\r\n", "output": ["2999998"]}, {"input": "999999 1000000\r\n", "output": ["3000000"]}, {"input": "500000 500100\r\n", "output": ["1500300"]}, {"input": "500000 166000\r\n", "output": ["1000000"]}, {"input": "500000 499000\r\n", "output": ["1498500"]}, {"input": "500000 167000\r\n", "output": ["1000500"]}, {"input": "1 1000000\r\n", "output": ["3000000"]}, {"input": "2 999123\r\n", "output": ["2997369"]}, {"input": "10 988723\r\n", "output": ["2966169"]}, {"input": "234 298374\r\n", "output": ["895122"]}, {"input": "2365 981235\r\n", "output": ["2943705"]}, {"input": "12345 981732\r\n", "output": ["2945196"]}, {"input": "108752 129872\r\n", "output": ["389616"]}, {"input": "984327 24352\r\n", "output": ["1968654"]}, {"input": "928375 1253\r\n", "output": ["1856750"]}, {"input": "918273 219\r\n", "output": ["1836546"]}, {"input": "987521 53\r\n", "output": ["1975042"]}, {"input": "123456 1\r\n", "output": ["246912"]}, {"input": "789123 0\r\n", "output": ["1578246"]}, {"input": "143568 628524\r\n", "output": ["1885572"]}, {"input": "175983 870607\r\n", "output": ["2611821"]}, {"input": "6 4\r\n", "output": ["15"]}, {"input": "6 3\r\n", "output": ["14"]}, {"input": "7 3\r\n", "output": ["15"]}, {"input": "5 4\r\n", "output": ["14"]}, {"input": "5 3\r\n", "output": ["12"]}, {"input": "8 5\r\n", "output": ["20"]}, {"input": "1 0\r\n", "output": ["2"]}, {"input": "19170 15725\r\n", "output": ["52342"]}, {"input": "3000 2000\r\n", "output": ["7500"]}, {"input": "7 4\r\n", "output": ["16"]}, {"input": "50 30\r\n", "output": ["120"]}, {"input": "300 200\r\n", "output": ["750"]}, {"input": "9 4\r\n", "output": ["20"]}, {"input": "4 3\r\n", "output": ["10"]}, {"input": "1 1\r\n", "output": ["3"]}, {"input": "8 6\r\n", "output": ["21"]}, {"input": "10 6\r\n", "output": ["24"]}, {"input": "65 56\r\n", "output": ["182"]}, {"input": "13 10\r\n", "output": ["34"]}, {"input": "14 42\r\n", "output": ["126"]}, {"input": "651 420\r\n", "output": ["1606"]}, {"input": "8 9\r\n", "output": ["27"]}, {"input": "15 10\r\n", "output": ["38"]}, {"input": "999999 888888\r\n", "output": ["2833330"]}, {"input": "192056 131545\r\n", "output": ["485402"]}, {"input": "32 16\r\n", "output": ["72"]}, {"input": "18 12\r\n", "output": ["45"]}, {"input": "1000000 666667\r\n", "output": ["2500000"]}, {"input": "0 1\r\n", "output": ["3"]}, {"input": "9 5\r\n", "output": ["21"]}, {"input": "1515 1415\r\n", "output": ["4395"]}, {"input": "300000 200000\r\n", "output": ["750000"]}]
100
100
100
[{'input': '500000 499000\r\n', 'output': ['1498500']}, {'input': '3 2\r\n', 'output': ['8']}, {'input': '999999 1000000\r\n', 'output': ['3000000']}, {'input': '300000 200000\r\n', 'output': ['750000']}, {'input': '651 420\r\n', 'output': ['1606']}]
[{'input': '300000 200000\r\n', 'output': ['750000']}, {'input': '10 988723\r\n', 'output': ['2966169']}, {'input': '14 42\r\n', 'output': ['126']}, {'input': '10 6\r\n', 'output': ['24']}, {'input': '918273 219\r\n', 'output': ['1836546']}]
[{'input': '163706 157895\r\n', 'output': ['482402']}, {'input': '32 16\r\n', 'output': ['72']}, {'input': '500000 167000\r\n', 'output': ['1000500']}, {'input': '974174 827926\r\n', 'output': ['2703150']}, {'input': '967227 894524\r\n', 'output': ['2792626']}]
[{'input': '15 10\r\n', 'output': ['38']}, {'input': '7 4\r\n', 'output': ['16']}, {'input': '300000 200000\r\n', 'output': ['750000']}, {'input': '1000000 666667\r\n', 'output': ['2500000']}, {'input': '0 1000000\r\n', 'output': ['3000000']}]
[{'input': '10 6\r\n', 'output': ['24']}, {'input': '4 3\r\n', 'output': ['10']}, {'input': '961920 647392\r\n', 'output': ['2413968']}, {'input': '651 420\r\n', 'output': ['1606']}, {'input': '4 2\r\n', 'output': ['9']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
132
100
100
100
["3000"]
The only line of the input contains one integer n (1 ≤ n ≤ 1018) — the prediction on the number of people who will buy the game.
8551308e5ff435e0fc507b89a912408a
#include<bits/stdc++.h> using namespace std ; long long n, ans ; int main() { cin >> n ; if(2520 > n) cout << 0 << endl; else { cout << n / 2520 << endl; } }
["1"]
C++
null
Output one integer showing how many numbers from 1 to n are divisible by all numbers from 2 to 10.
IT City company developing computer games invented a new way to reward its employees. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number of sales is divisible by all numbers from 2 to 10 every developer of this game gets a small bonus.A game designer Petya knows that the company is just about to release a new game that was partly developed by him. On the basis of his experience he predicts that n people will buy the game during the first month. Now Petya wants to determine how many times he will get the bonus. Help him to know it.
[{"input": "3000\r\n", "output": ["1"]}, {"input": "2520\r\n", "output": ["1"]}, {"input": "2519\r\n", "output": ["0"]}, {"input": "2521\r\n", "output": ["1"]}, {"input": "1\r\n", "output": ["0"]}, {"input": "314159265\r\n", "output": ["124666"]}, {"input": "718281828459045235\r\n", "output": ["285032471610732"]}, {"input": "1000000000000000000\r\n", "output": ["396825396825396"]}, {"input": "987654321234567890\r\n", "output": ["391926317950225"]}, {"input": "3628800\r\n", "output": ["1440"]}, {"input": "504000000000000000\r\n", "output": ["200000000000000"]}]
100
100
100
[{'input': '2521\r\n', 'output': ['1']}, {'input': '2519\r\n', 'output': ['0']}, {'input': '314159265\r\n', 'output': ['124666']}, {'input': '504000000000000000\r\n', 'output': ['200000000000000']}, {'input': '987654321234567890\r\n', 'output': ['391926317950225']}]
[{'input': '2519\r\n', 'output': ['0']}, {'input': '314159265\r\n', 'output': ['124666']}, {'input': '3000\r\n', 'output': ['1']}, {'input': '3628800\r\n', 'output': ['1440']}, {'input': '2521\r\n', 'output': ['1']}]
[{'input': '3000\r\n', 'output': ['1']}, {'input': '2520\r\n', 'output': ['1']}, {'input': '2519\r\n', 'output': ['0']}, {'input': '3628800\r\n', 'output': ['1440']}, {'input': '314159265\r\n', 'output': ['124666']}]
[{'input': '3628800\r\n', 'output': ['1440']}, {'input': '2520\r\n', 'output': ['1']}, {'input': '987654321234567890\r\n', 'output': ['391926317950225']}, {'input': '718281828459045235\r\n', 'output': ['285032471610732']}, {'input': '2519\r\n', 'output': ['0']}]
[{'input': '3628800\r\n', 'output': ['1440']}, {'input': '718281828459045235\r\n', 'output': ['285032471610732']}, {'input': '987654321234567890\r\n', 'output': ['391926317950225']}, {'input': '314159265\r\n', 'output': ['124666']}, {'input': '2520\r\n', 'output': ['1']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
50
133
100
100
90
["2 4", "0 10", "107 109"]
The first and only line of input contains two space-separated integers a and b (0 ≤ a ≤ b ≤ 1018).
2ed5a7a6176ed9b0bda1de21aad13d60
#include <bits/stdc++.h> using namespace std ; typedef long long ll; ll a, b, ans; int main () { cin >> a >> b; if(a == b) { cout << 1; return 0; } long long x = b - a; //cout << x << '\n'; if (x >= 5){ cout << 0; return 0; } if (x == 1){ cout << b % 10; return 0; } ans = 1; for (long long i = a + 1; i <= b; ++i){ ans *= i; ans %= 10; } cout << ans % 10; return 0; } /* 998244355 998244359 */
["2", "0", "2"]
C++
NoteIn the first example, the last digit of is 2;In the second example, the last digit of is 0;In the third example, the last digit of is 2.
Output one line containing a single decimal digit — the last digit of the value that interests Koyomi.
Even if the world is full of counterfeits, I still regard it as wonderful.Pile up herbs and incense, and arise again from the flames and ashes of its predecessor — as is known to many, the phoenix does it like this.The phoenix has a rather long lifespan, and reincarnates itself once every a! years. Here a! denotes the factorial of integer a, that is, a! = 1 × 2 × ... × a. Specifically, 0! = 1.Koyomi doesn't care much about this, but before he gets into another mess with oddities, he is interested in the number of times the phoenix will reincarnate in a timespan of b! years, that is, . Note that when b ≥ a this value is always integer.As the answer can be quite large, it would be enough for Koyomi just to know the last digit of the answer in decimal representation. And you're here to provide Koyomi with this knowledge.
[{"input": "2 4\r\n", "output": ["2"]}, {"input": "0 10\r\n", "output": ["0"]}, {"input": "107 109\r\n", "output": ["2"]}, {"input": "10 13\r\n", "output": ["6"]}, {"input": "998244355 998244359\r\n", "output": ["4"]}, {"input": "999999999000000000 1000000000000000000\r\n", "output": ["0"]}, {"input": "2 3\r\n", "output": ["3"]}, {"input": "3 15\r\n", "output": ["0"]}, {"input": "24 26\r\n", "output": ["0"]}, {"input": "14 60\r\n", "output": ["0"]}, {"input": "11 79\r\n", "output": ["0"]}, {"input": "1230 1232\r\n", "output": ["2"]}, {"input": "2633 2634\r\n", "output": ["4"]}, {"input": "535 536\r\n", "output": ["6"]}, {"input": "344319135 396746843\r\n", "output": ["0"]}, {"input": "696667767 696667767\r\n", "output": ["1"]}, {"input": "419530302 610096911\r\n", "output": ["0"]}, {"input": "238965115 821731161\r\n", "output": ["0"]}, {"input": "414626436 728903812\r\n", "output": ["0"]}, {"input": "274410639 293308324\r\n", "output": ["0"]}, {"input": "650636673091305697 650636673091305702\r\n", "output": ["0"]}, {"input": "651240548333620923 651240548333620924\r\n", "output": ["4"]}, {"input": "500000000000000000 1000000000000000000\r\n", "output": ["0"]}, {"input": "999999999999999999 1000000000000000000\r\n", "output": ["0"]}, {"input": "1000000000000000000 1000000000000000000\r\n", "output": ["1"]}, {"input": "0 4\r\n", "output": ["4"]}, {"input": "50000000062000007 50000000062000011\r\n", "output": ["0"]}, {"input": "0 0\r\n", "output": ["1"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "0 2\r\n", "output": ["2"]}, {"input": "10000000000012 10000000000015\r\n", "output": ["0"]}, {"input": "5 5\r\n", "output": ["1"]}, {"input": "12 23\r\n", "output": ["0"]}, {"input": "0 11\r\n", "output": ["0"]}, {"input": "11111234567890 11111234567898\r\n", "output": ["0"]}, {"input": "0 3\r\n", "output": ["6"]}, {"input": "1 2\r\n", "output": ["2"]}, {"input": "999999999999999997 999999999999999999\r\n", "output": ["2"]}, {"input": "4 5\r\n", "output": ["5"]}, {"input": "0 1\r\n", "output": ["1"]}, {"input": "101 1002\r\n", "output": ["0"]}, {"input": "0 100000000000000001\r\n", "output": ["0"]}, {"input": "99999999999999997 99999999999999999\r\n", "output": ["2"]}, {"input": "14 15\r\n", "output": ["5"]}, {"input": "8 19\r\n", "output": ["0"]}, {"input": "12 22\r\n", "output": ["0"]}, {"input": "999999999999996 999999999999999\r\n", "output": ["4"]}, {"input": "1 3\r\n", "output": ["6"]}, {"input": "124 125\r\n", "output": ["5"]}, {"input": "11 32\r\n", "output": ["0"]}, {"input": "0 5\r\n", "output": ["0"]}, {"input": "0 999999\r\n", "output": ["0"]}, {"input": "151151151515 151151151526\r\n", "output": ["0"]}, {"input": "6 107\r\n", "output": ["0"]}, {"input": "5 16\r\n", "output": ["0"]}, {"input": "7 16\r\n", "output": ["0"]}, {"input": "6 19\r\n", "output": ["0"]}, {"input": "11113111111111 13111111111111\r\n", "output": ["0"]}, {"input": "1 1000\r\n", "output": ["0"]}, {"input": "24 25\r\n", "output": ["5"]}, {"input": "0 100000000000\r\n", "output": ["0"]}, {"input": "1 22\r\n", "output": ["0"]}, {"input": "999999999999999996 999999999999999999\r\n", "output": ["4"]}]
100
100
100
[{'input': '101 1002\r\n', 'output': ['0']}, {'input': '6 107\r\n', 'output': ['0']}, {'input': '1 3\r\n', 'output': ['6']}, {'input': '11111234567890 11111234567898\r\n', 'output': ['0']}, {'input': '1 2\r\n', 'output': ['2']}]
[{'input': '1 22\r\n', 'output': ['0']}, {'input': '124 125\r\n', 'output': ['5']}, {'input': '535 536\r\n', 'output': ['6']}, {'input': '999999999999999999 1000000000000000000\r\n', 'output': ['0']}, {'input': '10 13\r\n', 'output': ['6']}]
[{'input': '0 999999\r\n', 'output': ['0']}, {'input': '6 19\r\n', 'output': ['0']}, {'input': '0 2\r\n', 'output': ['2']}, {'input': '999999999999999997 999999999999999999\r\n', 'output': ['2']}, {'input': '50000000062000007 50000000062000011\r\n', 'output': ['0']}]
[{'input': '0 2\r\n', 'output': ['2']}, {'input': '124 125\r\n', 'output': ['5']}, {'input': '50000000062000007 50000000062000011\r\n', 'output': ['0']}, {'input': '6 107\r\n', 'output': ['0']}, {'input': '1 1000\r\n', 'output': ['0']}]
[{'input': '1000000000000000000 1000000000000000000\r\n', 'output': ['1']}, {'input': '0 2\r\n', 'output': ['2']}, {'input': '124 125\r\n', 'output': ['5']}, {'input': '2 3\r\n', 'output': ['3']}, {'input': '1 22\r\n', 'output': ['0']}]
100
100
100
100
100
88.89
88.89
77.78
88.89
100
87.5
87.5
75
87.5
100
134
100
88.89
87.5
["3 2 1", "4 2 2", "3 2 2"]
The single line of the input contains integers n, w and b (3 ≤ n ≤ 4000, 2 ≤ w ≤ 4000, 1 ≤ b ≤ 4000) — the number of days, the number of good events and the number of not-so-good events. It is guaranteed that w + b ≥ n.
63e93a161bbff623323e66c98d5e20ac
#include <algorithm> #include <cstring> #include <cstdlib> #include <cstdio> #define N 4010 #define mo 1000000009 #define int64 long long #define For(i,x,y) for (i=x;i<=y;i++) using namespace std; int i,j,k,n,m,w,b; int64 f1[N],f2[N],an; inline int64 C(int n,int m) { if (m>n) return 0; if (!m) return 1; return f1[n]*f2[m]%mo*f2[n-m]%mo; } int main() { f1[0]=1; For(i,1,N-1) f1[i]=f1[i-1]*i%mo; f2[0]=f2[1]=1; For(i,2,N-1) f2[i]=(-f2[mo%i]*(mo/i)%mo+mo)%mo; For(i,2,N-1) f2[i]=f2[i]*f2[i-1]%mo; scanf("%d%d%d",&n,&w,&b); For(i,1,n-2) an=(an+f1[w]*f1[b]%mo*C(b-1,i-1)%mo*C(w-1,n-i-1)%mo*(n-i-1))%mo; printf("%I64d",an); return 0; }
["2", "4", "4"]
C++
NoteWe'll represent the good events by numbers starting from 1 and the not-so-good events — by letters starting from 'a'. Vertical lines separate days.In the first sample the possible ways are: "1|a|2" and "2|a|1". In the second sample the possible ways are: "1|a|b|2", "2|a|b|1", "1|b|a|2" and "2|b|a|1". In the third sample the possible ways are: "1|ab|2", "2|ab|1", "1|ba|2" and "2|ba|1".
Print the required number of ways modulo 1000000009 (109 + 9).
Polycarpus is sure that his life fits the description: "first there is a white stripe, then a black one, then a white one again". So, Polycarpus is sure that this rule is going to fulfill during the next n days. Polycarpus knows that he is in for w good events and b not-so-good events. At least one event is going to take place during each day. As each day is unequivocally characterizes as a part of a white or a black stripe, then each day is going to have events of the same type only (ether good or not-so-good).What is the number of distinct ways this scenario can develop over the next n days if Polycarpus is in for a white stripe (a stripe that has good events only, the stripe's length is at least 1 day), the a black stripe (a stripe that has not-so-good events only, the stripe's length is at least 1 day) and a white stripe again (a stripe that has good events only, the stripe's length is at least 1 day). Each of n days will belong to one of the three stripes only.Note that even the events of the same type are distinct from each other. Even if some events occur on the same day, they go in some order (there are no simultaneous events).Write a code that prints the number of possible configurations to sort the events into days. See the samples for clarifications on which scenarios should be considered distinct. Print the answer modulo 1000000009 (109 + 9).
[{"input": "3 2 1\r\n", "output": ["2"]}, {"input": "4 2 2\r\n", "output": ["4"]}, {"input": "3 2 2\r\n", "output": ["4"]}, {"input": "3 3 1\r\n", "output": ["12"]}, {"input": "3 3 3\r\n", "output": ["72"]}, {"input": "4 2 3\r\n", "output": ["24"]}, {"input": "4 3 2\r\n", "output": ["48"]}, {"input": "10 10 10\r\n", "output": ["318389383"]}, {"input": "10 7 5\r\n", "output": ["130636800"]}, {"input": "10 4 9\r\n", "output": ["135283173"]}, {"input": "100 200 300\r\n", "output": ["316471646"]}, {"input": "200 100 300\r\n", "output": ["949581532"]}, {"input": "239 300 231\r\n", "output": ["774612666"]}, {"input": "300 300 300\r\n", "output": ["375912430"]}, {"input": "300 2 300\r\n", "output": ["775907030"]}, {"input": "300 300 1\r\n", "output": ["775907030"]}, {"input": "3 300 300\r\n", "output": ["496527918"]}, {"input": "3 2 300\r\n", "output": ["196174631"]}, {"input": "3 300 1\r\n", "output": ["828107078"]}, {"input": "4000 1000 3000\r\n", "output": ["876839920"]}, {"input": "4000 2000 2000\r\n", "output": ["310481606"]}, {"input": "4000 100 3900\r\n", "output": ["221262673"]}, {"input": "4000 2 3998\r\n", "output": ["686088712"]}, {"input": "3 2 4000\r\n", "output": ["938379934"]}, {"input": "3 4000 4000\r\n", "output": ["680114446"]}, {"input": "4000 4000 1\r\n", "output": ["63263244"]}, {"input": "4000 3998 2\r\n", "output": ["296557186"]}, {"input": "4000 4000 4000\r\n", "output": ["997463324"]}, {"input": "4000 4000 100\r\n", "output": ["994443885"]}, {"input": "4000 100 4000\r\n", "output": ["908339579"]}]
100
100
100
[{'input': '300 300 1\r\n', 'output': ['775907030']}, {'input': '10 10 10\r\n', 'output': ['318389383']}, {'input': '3 3 3\r\n', 'output': ['72']}, {'input': '3 300 1\r\n', 'output': ['828107078']}, {'input': '4000 1000 3000\r\n', 'output': ['876839920']}]
[{'input': '4000 3998 2\r\n', 'output': ['296557186']}, {'input': '4000 100 3900\r\n', 'output': ['221262673']}, {'input': '4 2 3\r\n', 'output': ['24']}, {'input': '300 300 1\r\n', 'output': ['775907030']}, {'input': '4000 2 3998\r\n', 'output': ['686088712']}]
[{'input': '3 4000 4000\r\n', 'output': ['680114446']}, {'input': '4000 100 4000\r\n', 'output': ['908339579']}, {'input': '3 3 3\r\n', 'output': ['72']}, {'input': '4000 2 3998\r\n', 'output': ['686088712']}, {'input': '10 4 9\r\n', 'output': ['135283173']}]
[{'input': '300 300 1\r\n', 'output': ['775907030']}, {'input': '300 300 300\r\n', 'output': ['375912430']}, {'input': '4000 2000 2000\r\n', 'output': ['310481606']}, {'input': '3 2 1\r\n', 'output': ['2']}, {'input': '10 4 9\r\n', 'output': ['135283173']}]
[{'input': '3 2 1\r\n', 'output': ['2']}, {'input': '4 2 3\r\n', 'output': ['24']}, {'input': '4000 4000 1\r\n', 'output': ['63263244']}, {'input': '3 3 1\r\n', 'output': ['12']}, {'input': '4000 3998 2\r\n', 'output': ['296557186']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
135
100
100
100
["11\n00000000008", "22\n0011223344556677889988", "11\n31415926535"]
The first line contains an integer $$$n$$$ — the number of cards with digits that you have ($$$1 \leq n \leq 100$$$). The second line contains a string of $$$n$$$ digits (characters "0", "1", ..., "9") $$$s_1, s_2, \ldots, s_n$$$. The string will not contain any other characters, such as leading or trailing spaces.
259d01b81bef5536b969247ff2c2d776
#include<bits/stdc++.h> using namespace std; int num=0,n; char ch; int main() { scanf("%d\n",&n); for (int i=1;i<=n;i++) { scanf("%c",&ch); if (ch=='8') num++; } if (num==0) printf("0"); else { if (num*11<=n) printf("%d",num); else printf("%d",n/11); } return 0; }
["1", "2", "0"]
C++
NoteIn the first example, one phone number, "8000000000", can be made from these cards.In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789".In the third example you can't make any phone number from the given cards.
If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0.
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit.For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not.You have $$$n$$$ cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct.
[{"input": "11\r\n00000000008\r\n", "output": ["1"]}, {"input": "22\r\n0011223344556677889988\r\n", "output": ["2"]}, {"input": "11\r\n31415926535\r\n", "output": ["0"]}, {"input": "99\r\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\r\n", "output": ["9"]}, {"input": "100\r\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\r\n", "output": ["9"]}, {"input": "99\r\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\r\n", "output": ["0"]}, {"input": "100\r\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\r\n", "output": ["1"]}, {"input": "100\r\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\r\n", "output": ["9"]}, {"input": "10\r\n8888888888\r\n", "output": ["0"]}, {"input": "20\r\n88888888888888888888\r\n", "output": ["1"]}, {"input": "30\r\n888888888888888888888888888888\r\n", "output": ["2"]}, {"input": "40\r\n8888888888888888888888888888888888888888\r\n", "output": ["3"]}, {"input": "50\r\n88888888888888888888888888888888888888888888888888\r\n", "output": ["4"]}, {"input": "60\r\n888888888888888888888888888888888888888888888888888888888888\r\n", "output": ["5"]}, {"input": "70\r\n8888888888888888888888888888888888888888888888888888888888888888888888\r\n", "output": ["6"]}, {"input": "80\r\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\r\n", "output": ["7"]}, {"input": "90\r\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\r\n", "output": ["8"]}, {"input": "11\r\n24572366390\r\n", "output": ["0"]}, {"input": "21\r\n582586788289484878588\r\n", "output": ["1"]}, {"input": "31\r\n0868889888343881888987888838808\r\n", "output": ["2"]}, {"input": "41\r\n78888884888874788841882882888088888588888\r\n", "output": ["3"]}, {"input": "51\r\n882889888888689888850888388887688788888888888858888\r\n", "output": ["4"]}, {"input": "61\r\n8880888836888988888988888887388888888888868898887888818888888\r\n", "output": ["5"]}, {"input": "71\r\n88888888888888888888888188888805848888788088888883888883187888838888888\r\n", "output": ["6"]}, {"input": "81\r\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\r\n", "output": ["7"]}, {"input": "91\r\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\r\n", "output": ["8"]}, {"input": "100\r\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\r\n", "output": ["9"]}, {"input": "22\r\n4215079217017196952791\r\n", "output": ["0"]}, {"input": "32\r\n88257478884887437239023185588797\r\n", "output": ["2"]}, {"input": "42\r\n885887846290886288816884858898812858495482\r\n", "output": ["3"]}, {"input": "52\r\n8878588869084488848898838898788838337877898817818888\r\n", "output": ["4"]}, {"input": "62\r\n18888883884288488882387888486858887882838885288886472818688888\r\n", "output": ["5"]}, {"input": "72\r\n888488888888823288848804883838888888887888888888228888218488897809784868\r\n", "output": ["6"]}, {"input": "82\r\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\r\n", "output": ["7"]}, {"input": "92\r\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\r\n", "output": ["8"]}, {"input": "100\r\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\r\n", "output": ["9"]}, {"input": "33\r\n270375004567749549929235905225024\r\n", "output": ["0"]}, {"input": "43\r\n7404899846883344886153727489084158470112581\r\n", "output": ["3"]}, {"input": "53\r\n85838985300863473289888099788588319484149888886832906\r\n", "output": ["4"]}, {"input": "63\r\n728385948188688801288285888788852829888898565895847689806684688\r\n", "output": ["5"]}, {"input": "73\r\n2185806538483837898808836883483888818818988881880688028788888081888907898\r\n", "output": ["6"]}, {"input": "83\r\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\r\n", "output": ["7"]}, {"input": "93\r\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\r\n", "output": ["8"]}, {"input": "100\r\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\r\n", "output": ["9"]}, {"input": "44\r\n15920309219313427633220119270900111650391207\r\n", "output": ["0"]}, {"input": "54\r\n438283821340622774637957966575424773837418828888614203\r\n", "output": ["4"]}, {"input": "64\r\n8885984815868480968883818886281846682409262501034555933863969284\r\n", "output": ["5"]}, {"input": "74\r\n70988894874867688968816582886488688881063425288316858438189808828755218508\r\n", "output": ["6"]}, {"input": "84\r\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\r\n", "output": ["7"]}, {"input": "94\r\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\r\n", "output": ["8"]}, {"input": "100\r\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\r\n", "output": ["9"]}, {"input": "55\r\n7271714707719515303911625619272900050990324951111943573\r\n", "output": ["0"]}, {"input": "65\r\n44542121362830719677175203560438858260878894083124543850593761845\r\n", "output": ["5"]}, {"input": "75\r\n878909759892888846183608689257806813376950958863798487856148633095072259838\r\n", "output": ["6"]}, {"input": "85\r\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\r\n", "output": ["7"]}, {"input": "95\r\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\r\n", "output": ["8"]}, {"input": "100\r\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\r\n", "output": ["9"]}, {"input": "66\r\n747099435917145962031075767196746707764157706291155762576312312094\r\n", "output": ["0"]}, {"input": "76\r\n7900795570936733366353829649382870728119825830883973668601071678041634916557\r\n", "output": ["6"]}, {"input": "86\r\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\r\n", "output": ["7"]}, {"input": "96\r\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\r\n", "output": ["8"]}, {"input": "77\r\n11233392925013001334679215120076714945221576003953746107506364475115045309091\r\n", "output": ["0"]}, {"input": "87\r\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\r\n", "output": ["7"]}, {"input": "97\r\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\r\n", "output": ["8"]}, {"input": "100\r\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\r\n", "output": ["9"]}, {"input": "88\r\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\r\n", "output": ["0"]}, {"input": "98\r\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\r\n", "output": ["8"]}, {"input": "100\r\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\r\n", "output": ["9"]}, {"input": "11\r\n55814018693\r\n", "output": ["1"]}, {"input": "22\r\n6188156585823394680191\r\n", "output": ["2"]}, {"input": "33\r\n429980628264468835720540136177288\r\n", "output": ["3"]}, {"input": "44\r\n30153452341853403190257244993442815171970194\r\n", "output": ["2"]}, {"input": "55\r\n3982037603326093160114589190899881252765957832414122484\r\n", "output": ["5"]}, {"input": "66\r\n157941266854773786962397310504192100434183957442977444078457168272\r\n", "output": ["5"]}, {"input": "1\r\n0\r\n", "output": ["0"]}, {"input": "11\r\n80000000000\r\n", "output": ["1"]}, {"input": "27\r\n888000000000000000000000000\r\n", "output": ["2"]}, {"input": "10\r\n8000000000\r\n", "output": ["0"]}, {"input": "1\r\n8\r\n", "output": ["0"]}, {"input": "50\r\n88000000000000000000000000000000000000000000000000\r\n", "output": ["2"]}, {"input": "11\r\n81234567090\r\n", "output": ["1"]}, {"input": "32\r\n88000000000000000000000000000000\r\n", "output": ["2"]}, {"input": "57\r\n888888888888888888888888888888888888888888888888888888888\r\n", "output": ["5"]}, {"input": "22\r\n8899999999999999999999\r\n", "output": ["2"]}, {"input": "21\r\n881234567900123456790\r\n", "output": ["1"]}, {"input": "21\r\n888888555555555555555\r\n", "output": ["1"]}, {"input": "21\r\n888000000000000000000\r\n", "output": ["1"]}, {"input": "100\r\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r\n", "output": ["2"]}, {"input": "21\r\n888888888888000000000\r\n", "output": ["1"]}, {"input": "8\r\n12345678\r\n", "output": ["0"]}, {"input": "21\r\n880000000000000000000\r\n", "output": ["1"]}, {"input": "11\r\n81234567123\r\n", "output": ["1"]}, {"input": "11\r\n88888888888\r\n", "output": ["1"]}, {"input": "32\r\n88888888888888888888888888888888\r\n", "output": ["2"]}, {"input": "33\r\n888800000000000000000000000000000\r\n", "output": ["3"]}, {"input": "100\r\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\r\n", "output": ["1"]}, {"input": "21\r\n888111111111111111111\r\n", "output": ["1"]}, {"input": "77\r\n11111111111111111111111111111111111111111111111111111111111111111111111111111\r\n", "output": ["0"]}]
100
100
100
[{'input': '100\r\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\r\n', 'output': ['9']}, {'input': '51\r\n882889888888689888850888388887688788888888888858888\r\n', 'output': ['4']}, {'input': '74\r\n70988894874867688968816582886488688881063425288316858438189808828755218508\r\n', 'output': ['6']}, {'input': '11\r\n80000000000\r\n', 'output': ['1']}, {'input': '32\r\n88888888888888888888888888888888\r\n', 'output': ['2']}]
[{'input': '54\r\n438283821340622774637957966575424773837418828888614203\r\n', 'output': ['4']}, {'input': '20\r\n88888888888888888888\r\n', 'output': ['1']}, {'input': '44\r\n15920309219313427633220119270900111650391207\r\n', 'output': ['0']}, {'input': '84\r\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\r\n', 'output': ['7']}, {'input': '63\r\n728385948188688801288285888788852829888898565895847689806684688\r\n', 'output': ['5']}]
[{'input': '95\r\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\r\n', 'output': ['8']}, {'input': '11\r\n00000000008\r\n', 'output': ['1']}, {'input': '80\r\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\r\n', 'output': ['7']}, {'input': '65\r\n44542121362830719677175203560438858260878894083124543850593761845\r\n', 'output': ['5']}, {'input': '91\r\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\r\n', 'output': ['8']}]
[{'input': '100\r\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\r\n', 'output': ['9']}, {'input': '66\r\n157941266854773786962397310504192100434183957442977444078457168272\r\n', 'output': ['5']}, {'input': '100\r\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r\n', 'output': ['2']}, {'input': '60\r\n888888888888888888888888888888888888888888888888888888888888\r\n', 'output': ['5']}, {'input': '100\r\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\r\n', 'output': ['9']}]
[{'input': '99\r\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\r\n', 'output': ['9']}, {'input': '40\r\n8888888888888888888888888888888888888888\r\n', 'output': ['3']}, {'input': '81\r\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\r\n', 'output': ['7']}, {'input': '51\r\n882889888888689888850888388887688788888888888858888\r\n', 'output': ['4']}, {'input': '43\r\n7404899846883344886153727489084158470112581\r\n', 'output': ['3']}]
100
100
100
100
100
100
100
100
100
100
87.5
87.5
87.5
87.5
87.5
136
100
100
87.5
["1 993244853", "2 993244853", "3 993244853", "2019 993244853", "2020 437122297"]
The only line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 250\,000$$$, $$$10^8 \le m \le 10^9$$$, $$$m$$$ is prime).
020d5dae7157d937c3f58554c9b155f9
//#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //#include<bits/stdc++.h> #include <iostream> #include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <string> #include <cmath> #include <vector> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <stack> #include <queue> #include <deque> #include <iterator> #include <bitset> #include <assert.h> #include <new> #include <sstream> #include <time.h> //using namespace __gnu_pbds; using namespace std; /*** Optimization ***/ #pragma GCC optimize("Ofast,no-stack-protector") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("unroll-loops") /*** Typedef ***/ typedef long long ll; typedef unsigned long long ull; /*** Input ***/ #define sci1(a) scanf("%d",&a) #define sci2(a,b) scanf("%d %d",&a,&b) #define scln1(a) scanf("%lld",&a) #define scln2(a,b) scanf("%lld %lld",&a,&b) #define scln3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c) /*** Output ***/ #define pf1(a) printf("%d\n",a) #define pf2(a,b) printf("%d %d\n",a,b) #define pfln1(a) printf("%lld\n",a) #define pfln2(a,b) printf("%lld %lld\n",a,b) /*** Loops ***/ #define foR0(num) for(ll i = 0; i < num; i++) #define foR1(num) for(ll i = 1; i <= num; i++) #define foRev(num) for(ll i = num - 1; i >= 0; i--) #define forIn(arr, num) for(ll i = 0; i < num; i++) cin>>arr[i]; #define forIn1(arr, num) for(ll i = 1; i <= num; i++) cin>>arr[i]; #define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n'); #define apnt(arr, num) for(ll i = 0; i < num; i++) cout << arr[i] << (i + 1 < num ? ' ' : '\n'); /*** Define Values ***/ #define ff first #define ss second #define re return #define MP make_pair #define pb push_back #define SZ(x) ((int) (x).size()) #define EPS 10E-10 #define mxx 100005 #define MOD 1000000007 #define iseq(a,b) (fabs(a-b)<EPS) #define PI 3.141592653589793238462643 #define gcd(a, b) __gcd(a,b) #define min3(a,b,c) min(a,min(b,c)) #define max3(a,b,c) max(a,max(b,c)) #define lcm(a, b) ((a)*(b)/gcd(a,b)) #define min4(a,b,c,d) min(d,min(a,min(b,c))) #define max4(a,b,c,d) max(d,max(a,max(b,c))) #define input freopen("input.txt","rt", stdin) #define output freopen("output.txt","wt", stdout) #define all(v) v.begin(),v.end() #define mem(nam,val) memset(nam, val, sizeof(nam)) #define Unique(X) (X).resize(unique(all(X))-(X).begin()) #define get_pos(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin()) #define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); /*** STLs ***/ typedef vector <ll> vll; typedef set <ll> sll; typedef multiset <ll> msll; typedef queue <ll> qll; typedef stack <ll> stll; typedef map <ll, ll> mll; typedef pair <ll, ll> pll; typedef vector <pair <ll , ll> > vpll; /*** BitWise Operations ///int Set(int N,int pos){return N=N | (1<<pos);} ///int reset(int N,int pos){return N= N & ~(1<<pos);} ///bool check(int N,int pos){return (bool)(N & (1<<pos));} ***/ /*** Grids ///const int fx[] = {+1,-1,+0,+0}; ///const int fy[] = {+0,+0,+1,-1}; ///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move ///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move ///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move ///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move ***/ /*** Functions ///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; ///ll toint(string s){ll n=0,k=1;for(int i=s.size()-1; i>=0; i--){n += ((s[i]-'0')*k);k*=10;}return n;} ///string tostring(ll x){string s="";while(x){s += (x%10)+'0';x/=10;}reverse(s.begin(),s.end());return s;} ///bool sortinrev(const pair<ll,ll> &a,const pair<ll,ll> &b)return (a.first > b.first); ///priority_queue< pll ,vector<pll>,greater<pll> >p; ///cout<<*X.find_by_order(0)<<endl; ///cout<<X.order_of_key(-5)<<endl; ***/ /*** Some Prints ***/ #define en cout << '\n'; #define no cout << "NO" << '\n' #define yes cout << "YES" << '\n' ll A[1000005]; ll B[1000005]; ll fac[1000005]; void fact(ll m) { fac[0]=1; for(ll i=1;i<=250005;i++) { fac[i]=(i*fac[i-1])%m; } } int main() { IOS; ll tst=1; // cin>>tst; for(ll tt=1;tt<=tst;tt++) { //code ll n,m; cin>>n>>m; fact(m); ll res=(fac[n]*n)%m; for(ll i=1;i<n;i++) { ll dif=i+1; dif=fac[dif]; dif=(dif*(n-i))%m; ll val=(dif*fac[n-i])%m; // val=(val*fac[n-i]); res=(res+val)%m; } cout<<res<<endl; } return 0; }
["1", "6", "32", "923958830", "265955509"]
C++
NoteFor sample input $$$n=3$$$, let's consider all permutations of length $$$3$$$: $$$[1, 2, 3]$$$, all subsegments are framed segment. Happiness is $$$6$$$. $$$[1, 3, 2]$$$, all subsegments except $$$[1, 2]$$$ are framed segment. Happiness is $$$5$$$. $$$[2, 1, 3]$$$, all subsegments except $$$[2, 3]$$$ are framed segment. Happiness is $$$5$$$. $$$[2, 3, 1]$$$, all subsegments except $$$[2, 3]$$$ are framed segment. Happiness is $$$5$$$. $$$[3, 1, 2]$$$, all subsegments except $$$[1, 2]$$$ are framed segment. Happiness is $$$5$$$. $$$[3, 2, 1]$$$, all subsegments are framed segment. Happiness is $$$6$$$. Thus, the sum of happiness is $$$6+5+5+5+5+6 = 32$$$.
Print $$$r$$$ ($$$0 \le r &lt; m$$$), the sum of happiness for all permutations of length $$$n$$$, modulo a prime number $$$m$$$.
Recall that the permutation is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2,3,1,5,4]$$$ is a permutation, but $$$[1,2,2]$$$ is not a permutation ($$$2$$$ appears twice in the array) and $$$[1,3,4]$$$ is also not a permutation ($$$n=3$$$ but there is $$$4$$$ in the array).A sequence $$$a$$$ is a subsegment of a sequence $$$b$$$ if $$$a$$$ can be obtained from $$$b$$$ by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end. We will denote the subsegments as $$$[l, r]$$$, where $$$l, r$$$ are two integers with $$$1 \le l \le r \le n$$$. This indicates the subsegment where $$$l-1$$$ elements from the beginning and $$$n-r$$$ elements from the end are deleted from the sequence.For a permutation $$$p_1, p_2, \ldots, p_n$$$, we define a framed segment as a subsegment $$$[l,r]$$$ where $$$\max\{p_l, p_{l+1}, \dots, p_r\} - \min\{p_l, p_{l+1}, \dots, p_r\} = r - l$$$. For example, for the permutation $$$(6, 7, 1, 8, 5, 3, 2, 4)$$$ some of its framed segments are: $$$[1, 2], [5, 8], [6, 7], [3, 3], [8, 8]$$$. In particular, a subsegment $$$[i,i]$$$ is always a framed segments for any $$$i$$$ between $$$1$$$ and $$$n$$$, inclusive.We define the happiness of a permutation $$$p$$$ as the number of pairs $$$(l, r)$$$ such that $$$1 \le l \le r \le n$$$, and $$$[l, r]$$$ is a framed segment. For example, the permutation $$$[3, 1, 2]$$$ has happiness $$$5$$$: all segments except $$$[1, 2]$$$ are framed segments.Given integers $$$n$$$ and $$$m$$$, Jongwon wants to compute the sum of happiness for all permutations of length $$$n$$$, modulo the prime number $$$m$$$. Note that there exist $$$n!$$$ (factorial of $$$n$$$) different permutations of length $$$n$$$.
[{"input": "1 993244853\r\n", "output": ["1"]}, {"input": "2 993244853\r\n", "output": ["6"]}, {"input": "3 993244853\r\n", "output": ["32"]}, {"input": "2019 993244853\r\n", "output": ["923958830"]}, {"input": "2020 437122297\r\n", "output": ["265955509"]}, {"input": "250000 993244853\r\n", "output": ["872048421"]}, {"input": "244435 994838543\r\n", "output": ["634651929"]}, {"input": "234324 994631069\r\n", "output": ["720229385"]}, {"input": "249996 997202249\r\n", "output": ["633673455"]}, {"input": "32433 992864681\r\n", "output": ["302084847"]}, {"input": "4 389349601\r\n", "output": ["180"]}, {"input": "5 141602633\r\n", "output": ["1116"]}, {"input": "6 223676287\r\n", "output": ["7728"]}, {"input": "7 110998807\r\n", "output": ["59904"]}, {"input": "8 848339069\r\n", "output": ["518400"]}, {"input": "9 298827211\r\n", "output": ["4982400"]}, {"input": "10 876938317\r\n", "output": ["52842240"]}, {"input": "11 739198003\r\n", "output": ["614200320"]}, {"input": "12 273157301\r\n", "output": ["122791732"]}, {"input": "13 797912417\r\n", "output": ["234147739"]}, {"input": "14 353847517\r\n", "output": ["42904792"]}, {"input": "249997 996061721\r\n", "output": ["69046617"]}, {"input": "249998 990040613\r\n", "output": ["108188702"]}, {"input": "249999 992509109\r\n", "output": ["854585866"]}, {"input": "250000 996140731\r\n", "output": ["227969454"]}, {"input": "2341 994476991\r\n", "output": ["121932216"]}, {"input": "1000 100000651\r\n", "output": ["92079298"]}, {"input": "100000 100000921\r\n", "output": ["51605491"]}, {"input": "20422 956269049\r\n", "output": ["895579878"]}, {"input": "40424 285650803\r\n", "output": ["114646354"]}, {"input": "60426 547574749\r\n", "output": ["323978028"]}, {"input": "80428 410667659\r\n", "output": ["284512223"]}, {"input": "100432 858603079\r\n", "output": ["763015781"]}, {"input": "120424 735211237\r\n", "output": ["78258285"]}, {"input": "140426 454141843\r\n", "output": ["451934478"]}, {"input": "160428 434183023\r\n", "output": ["156691255"]}, {"input": "180420 266525887\r\n", "output": ["239713633"]}, {"input": "200422 984828937\r\n", "output": ["556345906"]}, {"input": "220424 428927617\r\n", "output": ["43877713"]}, {"input": "240422 623039447\r\n", "output": ["291729074"]}]
100
100
100
[{'input': '250000 993244853\r\n', 'output': ['872048421']}, {'input': '6 223676287\r\n', 'output': ['7728']}, {'input': '80428 410667659\r\n', 'output': ['284512223']}, {'input': '1000 100000651\r\n', 'output': ['92079298']}, {'input': '220424 428927617\r\n', 'output': ['43877713']}]
[{'input': '1 993244853\r\n', 'output': ['1']}, {'input': '200422 984828937\r\n', 'output': ['556345906']}, {'input': '100000 100000921\r\n', 'output': ['51605491']}, {'input': '160428 434183023\r\n', 'output': ['156691255']}, {'input': '6 223676287\r\n', 'output': ['7728']}]
[{'input': '249996 997202249\r\n', 'output': ['633673455']}, {'input': '249998 990040613\r\n', 'output': ['108188702']}, {'input': '32433 992864681\r\n', 'output': ['302084847']}, {'input': '20422 956269049\r\n', 'output': ['895579878']}, {'input': '9 298827211\r\n', 'output': ['4982400']}]
[{'input': '60426 547574749\r\n', 'output': ['323978028']}, {'input': '234324 994631069\r\n', 'output': ['720229385']}, {'input': '160428 434183023\r\n', 'output': ['156691255']}, {'input': '1 993244853\r\n', 'output': ['1']}, {'input': '80428 410667659\r\n', 'output': ['284512223']}]
[{'input': '180420 266525887\r\n', 'output': ['239713633']}, {'input': '32433 992864681\r\n', 'output': ['302084847']}, {'input': '250000 993244853\r\n', 'output': ['872048421']}, {'input': '220424 428927617\r\n', 'output': ['43877713']}, {'input': '1 993244853\r\n', 'output': ['1']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
137
100
100
100
["4 2 1 3", "7 2 2 4", "3 5 9 1"]
The first line of the input contains four space-separated positive integer numbers not exceeding 100 — lengthes of the sticks.
8f5df9a41e6e100aa65b9fc1d26e447a
#include<bits/stdc++.h> using namespace std; int a[5]; int u[4]; bool f[5],falg; void dfs(int dep) { if(dep==4) { if(u[1]+u[2]>u[3]&&u[1]+u[3]>u[2]&&u[2]+u[3]>u[1]) { printf("TRIANGLE"); exit(0); } if(u[1]+u[2]>=u[3]&&u[1]+u[3]>=u[2]&&u[2]+u[3]>=u[1])falg=true; return; } for(int i=1;i<=4;i++) if(f[i]==false) { f[i]=true; u[dep]=a[i]; dep++; dfs(dep); dep--; u[dep]=0; f[i]=false; } } int main() { scanf("%d%d%d%d",a+1,a+2,a+3,a+4); dfs(1); if(falg==true)printf("SEGMENT"); else printf("IMPOSSIBLE"); return 0; }
["TRIANGLE", "SEGMENT", "IMPOSSIBLE"]
C++
null
Output TRIANGLE if it is possible to construct a non-degenerate triangle. Output SEGMENT if the first case cannot take place and it is possible to construct a degenerate triangle. Output IMPOSSIBLE if it is impossible to construct any triangle. Remember that you are to use three sticks. It is not allowed to break the sticks or use their partial length.
Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out of four sticks of different colours. Naturally, one of the sticks is extra. It is not allowed to break the sticks or use their partial length. Anne has perfectly solved this task, now she is asking Johnny to do the same.The boy answered that he would cope with it without any difficulty. However, after a while he found out that different tricky things can occur. It can happen that it is impossible to construct a triangle of a positive area, but it is possible to construct a degenerate triangle. It can be so, that it is impossible to construct a degenerate triangle even. As Johnny is very lazy, he does not want to consider such a big amount of cases, he asks you to help him.
[{"input": "4 2 1 3\r\n", "output": ["TRIANGLE"]}, {"input": "7 2 2 4\r\n", "output": ["SEGMENT"]}, {"input": "3 5 9 1\r\n", "output": ["IMPOSSIBLE"]}, {"input": "3 1 5 1\r\n", "output": ["IMPOSSIBLE"]}, {"input": "10 10 10 10\r\n", "output": ["TRIANGLE"]}, {"input": "11 5 6 11\r\n", "output": ["TRIANGLE"]}, {"input": "1 1 1 1\r\n", "output": ["TRIANGLE"]}, {"input": "10 20 30 40\r\n", "output": ["TRIANGLE"]}, {"input": "45 25 5 15\r\n", "output": ["IMPOSSIBLE"]}, {"input": "20 5 8 13\r\n", "output": ["TRIANGLE"]}, {"input": "10 30 7 20\r\n", "output": ["SEGMENT"]}, {"input": "3 2 3 2\r\n", "output": ["TRIANGLE"]}, {"input": "70 10 100 30\r\n", "output": ["SEGMENT"]}, {"input": "4 8 16 2\r\n", "output": ["IMPOSSIBLE"]}, {"input": "3 3 3 10\r\n", "output": ["TRIANGLE"]}, {"input": "1 5 5 5\r\n", "output": ["TRIANGLE"]}, {"input": "13 25 12 1\r\n", "output": ["SEGMENT"]}, {"input": "10 100 7 3\r\n", "output": ["SEGMENT"]}, {"input": "50 1 50 100\r\n", "output": ["TRIANGLE"]}, {"input": "50 1 100 49\r\n", "output": ["SEGMENT"]}, {"input": "49 51 100 1\r\n", "output": ["SEGMENT"]}, {"input": "5 11 2 25\r\n", "output": ["IMPOSSIBLE"]}, {"input": "91 50 9 40\r\n", "output": ["IMPOSSIBLE"]}, {"input": "27 53 7 97\r\n", "output": ["IMPOSSIBLE"]}, {"input": "51 90 24 8\r\n", "output": ["IMPOSSIBLE"]}, {"input": "3 5 1 1\r\n", "output": ["IMPOSSIBLE"]}, {"input": "13 49 69 15\r\n", "output": ["IMPOSSIBLE"]}, {"input": "16 99 9 35\r\n", "output": ["IMPOSSIBLE"]}, {"input": "27 6 18 53\r\n", "output": ["IMPOSSIBLE"]}, {"input": "57 88 17 8\r\n", "output": ["IMPOSSIBLE"]}, {"input": "95 20 21 43\r\n", "output": ["IMPOSSIBLE"]}, {"input": "6 19 32 61\r\n", "output": ["IMPOSSIBLE"]}, {"input": "100 21 30 65\r\n", "output": ["IMPOSSIBLE"]}, {"input": "85 16 61 9\r\n", "output": ["IMPOSSIBLE"]}, {"input": "5 6 19 82\r\n", "output": ["IMPOSSIBLE"]}, {"input": "1 5 1 3\r\n", "output": ["IMPOSSIBLE"]}, {"input": "65 10 36 17\r\n", "output": ["IMPOSSIBLE"]}, {"input": "81 64 9 7\r\n", "output": ["IMPOSSIBLE"]}, {"input": "11 30 79 43\r\n", "output": ["IMPOSSIBLE"]}, {"input": "1 1 5 3\r\n", "output": ["IMPOSSIBLE"]}, {"input": "21 94 61 31\r\n", "output": ["IMPOSSIBLE"]}, {"input": "49 24 9 74\r\n", "output": ["IMPOSSIBLE"]}, {"input": "11 19 5 77\r\n", "output": ["IMPOSSIBLE"]}, {"input": "52 10 19 71\r\n", "output": ["SEGMENT"]}, {"input": "2 3 7 10\r\n", "output": ["SEGMENT"]}, {"input": "1 2 6 3\r\n", "output": ["SEGMENT"]}, {"input": "2 6 1 8\r\n", "output": ["SEGMENT"]}, {"input": "1 2 4 1\r\n", "output": ["SEGMENT"]}, {"input": "4 10 6 2\r\n", "output": ["SEGMENT"]}, {"input": "2 10 7 3\r\n", "output": ["SEGMENT"]}, {"input": "5 2 3 9\r\n", "output": ["SEGMENT"]}, {"input": "6 1 4 10\r\n", "output": ["SEGMENT"]}, {"input": "10 6 4 1\r\n", "output": ["SEGMENT"]}, {"input": "3 2 9 1\r\n", "output": ["SEGMENT"]}, {"input": "22 80 29 7\r\n", "output": ["SEGMENT"]}, {"input": "2 6 3 9\r\n", "output": ["SEGMENT"]}, {"input": "3 1 2 1\r\n", "output": ["SEGMENT"]}, {"input": "3 4 7 1\r\n", "output": ["SEGMENT"]}, {"input": "8 4 3 1\r\n", "output": ["SEGMENT"]}, {"input": "2 8 3 5\r\n", "output": ["SEGMENT"]}, {"input": "4 1 2 1\r\n", "output": ["SEGMENT"]}, {"input": "8 1 3 2\r\n", "output": ["SEGMENT"]}, {"input": "6 2 1 8\r\n", "output": ["SEGMENT"]}, {"input": "3 3 3 6\r\n", "output": ["TRIANGLE"]}, {"input": "3 6 3 3\r\n", "output": ["TRIANGLE"]}, {"input": "4 10 4 4\r\n", "output": ["TRIANGLE"]}, {"input": "1 1 2 1\r\n", "output": ["TRIANGLE"]}, {"input": "3 3 3 6\r\n", "output": ["TRIANGLE"]}, {"input": "5 4 5 5\r\n", "output": ["TRIANGLE"]}, {"input": "8 7 8 8\r\n", "output": ["TRIANGLE"]}, {"input": "3 3 3 1\r\n", "output": ["TRIANGLE"]}, {"input": "1 1 6 6\r\n", "output": ["TRIANGLE"]}, {"input": "1 9 1 9\r\n", "output": ["TRIANGLE"]}, {"input": "7 2 2 7\r\n", "output": ["TRIANGLE"]}, {"input": "7 2 3 2\r\n", "output": ["TRIANGLE"]}, {"input": "4 4 10 10\r\n", "output": ["TRIANGLE"]}, {"input": "7 7 10 7\r\n", "output": ["TRIANGLE"]}, {"input": "4 4 4 5\r\n", "output": ["TRIANGLE"]}, {"input": "1 10 9 2\r\n", "output": ["TRIANGLE"]}, {"input": "1 8 2 7\r\n", "output": ["TRIANGLE"]}, {"input": "4 3 2 8\r\n", "output": ["TRIANGLE"]}, {"input": "5 9 5 3\r\n", "output": ["TRIANGLE"]}, {"input": "4 10 3 5\r\n", "output": ["TRIANGLE"]}]
100
100
100
[{'input': '85 16 61 9\r\n', 'output': ['IMPOSSIBLE']}, {'input': '5 11 2 25\r\n', 'output': ['IMPOSSIBLE']}, {'input': '45 25 5 15\r\n', 'output': ['IMPOSSIBLE']}, {'input': '5 4 5 5\r\n', 'output': ['TRIANGLE']}, {'input': '1 8 2 7\r\n', 'output': ['TRIANGLE']}]
[{'input': '10 30 7 20\r\n', 'output': ['SEGMENT']}, {'input': '81 64 9 7\r\n', 'output': ['IMPOSSIBLE']}, {'input': '27 6 18 53\r\n', 'output': ['IMPOSSIBLE']}, {'input': '4 10 4 4\r\n', 'output': ['TRIANGLE']}, {'input': '51 90 24 8\r\n', 'output': ['IMPOSSIBLE']}]
[{'input': '6 19 32 61\r\n', 'output': ['IMPOSSIBLE']}, {'input': '65 10 36 17\r\n', 'output': ['IMPOSSIBLE']}, {'input': '22 80 29 7\r\n', 'output': ['SEGMENT']}, {'input': '2 3 7 10\r\n', 'output': ['SEGMENT']}, {'input': '11 30 79 43\r\n', 'output': ['IMPOSSIBLE']}]
[{'input': '45 25 5 15\r\n', 'output': ['IMPOSSIBLE']}, {'input': '7 7 10 7\r\n', 'output': ['TRIANGLE']}, {'input': '13 25 12 1\r\n', 'output': ['SEGMENT']}, {'input': '7 2 2 7\r\n', 'output': ['TRIANGLE']}, {'input': '100 21 30 65\r\n', 'output': ['IMPOSSIBLE']}]
[{'input': '50 1 50 100\r\n', 'output': ['TRIANGLE']}, {'input': '1 9 1 9\r\n', 'output': ['TRIANGLE']}, {'input': '3 3 3 1\r\n', 'output': ['TRIANGLE']}, {'input': '4 3 2 8\r\n', 'output': ['TRIANGLE']}, {'input': '81 64 9 7\r\n', 'output': ['IMPOSSIBLE']}]
100
100
100
100
100
100
100
90.91
100
100
95
100
95
100
90
138
100
98.182
96
["1 2", "8 16", "1 1"]
The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 1018). Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
d90e99d539b16590c17328d79a5921e0
#include <algorithm> #include <iostream> #include <cstring> #include <cstdlib> #include <cassert> #include <cstdio> #include <vector> #include <cmath> #include <ctime> #include <set> #include <map> #include <queue> #include <stack> #include <deque> #define F first #define S second #define eps 1e-8 #define pb push_back #define ppb pop_back #define mp make_pair #define lb lower_bound #define ub upper_bound #define INF 2000000000 typedef long long ll; using namespace std; ll l, r, ans; int q, Q, p; bool w[99], W[99]; int main() { ios::sync_with_stdio(0); cin >> l >> r; while(l){ w[q++] = l % 2; l >>= 1; } while(r){ W[Q++] = r % 2; r >>= 1; } for(int i = Q; i >= 0; i--) if(w[i] != W[i]){ p = i + 1; break; } ans = (1ll << p) - 1ll; cout << ans; return 0; }
["3", "31", "0"]
C++
null
In a single line print a single integer — the maximum value of for all pairs of integers a, b (l ≤ a ≤ b ≤ r).
A little girl loves problems on bitwise operations very much. Here's one of them.You are given two integers l and r. Let's consider the values of for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones.Expression means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as "xor".
[{"input": "1 2\r\n", "output": ["3"]}, {"input": "8 16\r\n", "output": ["31"]}, {"input": "1 1\r\n", "output": ["0"]}, {"input": "506 677\r\n", "output": ["1023"]}, {"input": "33 910\r\n", "output": ["1023"]}, {"input": "36 94\r\n", "output": ["127"]}, {"input": "10000000000 20000000000\r\n", "output": ["34359738367"]}, {"input": "79242383109441603 533369389165030783\r\n", "output": ["576460752303423487"]}, {"input": "797162752288318119 908416915938410706\r\n", "output": ["576460752303423487"]}, {"input": "230148668013473494 573330407369354716\r\n", "output": ["576460752303423487"]}, {"input": "668869743157683834 805679503731305624\r\n", "output": ["288230376151711743"]}, {"input": "32473107276976561 588384394540535099\r\n", "output": ["1152921504606846975"]}, {"input": "632668612680440378 864824360766754908\r\n", "output": ["576460752303423487"]}, {"input": "658472316271074503 728242833853270665\r\n", "output": ["288230376151711743"]}, {"input": "289218059048863941 314351197831808685\r\n", "output": ["36028797018963967"]}, {"input": "54248140375568203 718189790306910368\r\n", "output": ["1152921504606846975"]}, {"input": "330134158459714054 457118108955760856\r\n", "output": ["288230376151711743"]}, {"input": "190442232278841373 980738846929096255\r\n", "output": ["1152921504606846975"]}, {"input": "203359308073091683 455893840817516371\r\n", "output": ["576460752303423487"]}, {"input": "200851182089362664 449305852839820160\r\n", "output": ["576460752303423487"]}, {"input": "731792654005832175 789527173439457653\r\n", "output": ["72057594037927935"]}, {"input": "231465750142682282 276038074124518614\r\n", "output": ["72057594037927935"]}, {"input": "462451489958473150 957447393463701191\r\n", "output": ["1152921504606846975"]}, {"input": "68666076639301243 247574109010873331\r\n", "output": ["288230376151711743"]}, {"input": "491113582000560303 858928223424873439\r\n", "output": ["1152921504606846975"]}, {"input": "454452550141901489 843034681327343036\r\n", "output": ["1152921504606846975"]}, {"input": "43543567767276698 769776048133345296\r\n", "output": ["1152921504606846975"]}, {"input": "214985598536531449 956713939905291713\r\n", "output": ["1152921504606846975"]}, {"input": "56445001476501414 706930175458589379\r\n", "output": ["1152921504606846975"]}, {"input": "666033930784103123 883523065811761270\r\n", "output": ["576460752303423487"]}, {"input": "501827377176522663 590153819613032662\r\n", "output": ["1152921504606846975"]}, {"input": "140216419613864821 362678730465999561\r\n", "output": ["576460752303423487"]}, {"input": "23811264031960242 520940113721281721\r\n", "output": ["576460752303423487"]}, {"input": "43249439481689805 431488136320817289\r\n", "output": ["576460752303423487"]}, {"input": "198909890748296613 528950282310167050\r\n", "output": ["576460752303423487"]}, {"input": "190620774979376809 899159649449168622\r\n", "output": ["1152921504606846975"]}, {"input": "18565852953382418 697862904569985066\r\n", "output": ["1152921504606846975"]}, {"input": "277046860122752192 828379515775613732\r\n", "output": ["1152921504606846975"]}, {"input": "25785331761502790 119852560236585580\r\n", "output": ["144115188075855871"]}, {"input": "363313173638414449 500957528623228245\r\n", "output": ["288230376151711743"]}, {"input": "549330032897152846 715374717344043295\r\n", "output": ["1152921504606846975"]}, {"input": "47456305370335136 388462406071482688\r\n", "output": ["576460752303423487"]}, {"input": "125051194948742221 235911208585118006\r\n", "output": ["288230376151711743"]}, {"input": "780993382943360354 889872865454335075\r\n", "output": ["576460752303423487"]}, {"input": "815449097320007662 942453891178865528\r\n", "output": ["576460752303423487"]}, {"input": "765369978472937483 796958953973862258\r\n", "output": ["144115188075855871"]}, {"input": "259703440079833303 857510033561081530\r\n", "output": ["1152921504606846975"]}, {"input": "181513087965617551 301910258955864271\r\n", "output": ["576460752303423487"]}, {"input": "28591024119784617 732203343197854927\r\n", "output": ["1152921504606846975"]}, {"input": "215365547805299155 861595308221385098\r\n", "output": ["1152921504606846975"]}, {"input": "1 1000000000000000000\r\n", "output": ["1152921504606846975"]}, {"input": "1000000000000 999999999999999999\r\n", "output": ["1152921504606846975"]}, {"input": "1 1\r\n", "output": ["0"]}, {"input": "9999999999998 9999999999999\r\n", "output": ["1"]}, {"input": "9999999999900 9999999999901\r\n", "output": ["1"]}, {"input": "9999999999900 9999999999902\r\n", "output": ["3"]}, {"input": "9999999999900 9999999999903\r\n", "output": ["3"]}, {"input": "1 3\r\n", "output": ["3"]}, {"input": "5000000 5900000\r\n", "output": ["2097151"]}, {"input": "8589934592 8989934592\r\n", "output": ["536870911"]}]
100
100
100
[{'input': '215365547805299155 861595308221385098\r\n', 'output': ['1152921504606846975']}, {'input': '259703440079833303 857510033561081530\r\n', 'output': ['1152921504606846975']}, {'input': '203359308073091683 455893840817516371\r\n', 'output': ['576460752303423487']}, {'input': '1 1000000000000000000\r\n', 'output': ['1152921504606846975']}, {'input': '140216419613864821 362678730465999561\r\n', 'output': ['576460752303423487']}]
[{'input': '5000000 5900000\r\n', 'output': ['2097151']}, {'input': '10000000000 20000000000\r\n', 'output': ['34359738367']}, {'input': '203359308073091683 455893840817516371\r\n', 'output': ['576460752303423487']}, {'input': '47456305370335136 388462406071482688\r\n', 'output': ['576460752303423487']}, {'input': '8 16\r\n', 'output': ['31']}]
[{'input': '215365547805299155 861595308221385098\r\n', 'output': ['1152921504606846975']}, {'input': '797162752288318119 908416915938410706\r\n', 'output': ['576460752303423487']}, {'input': '23811264031960242 520940113721281721\r\n', 'output': ['576460752303423487']}, {'input': '501827377176522663 590153819613032662\r\n', 'output': ['1152921504606846975']}, {'input': '668869743157683834 805679503731305624\r\n', 'output': ['288230376151711743']}]
[{'input': '454452550141901489 843034681327343036\r\n', 'output': ['1152921504606846975']}, {'input': '200851182089362664 449305852839820160\r\n', 'output': ['576460752303423487']}, {'input': '203359308073091683 455893840817516371\r\n', 'output': ['576460752303423487']}, {'input': '765369978472937483 796958953973862258\r\n', 'output': ['144115188075855871']}, {'input': '56445001476501414 706930175458589379\r\n', 'output': ['1152921504606846975']}]
[{'input': '9999999999998 9999999999999\r\n', 'output': ['1']}, {'input': '501827377176522663 590153819613032662\r\n', 'output': ['1152921504606846975']}, {'input': '780993382943360354 889872865454335075\r\n', 'output': ['576460752303423487']}, {'input': '36 94\r\n', 'output': ['127']}, {'input': '363313173638414449 500957528623228245\r\n', 'output': ['288230376151711743']}]
100
100
100
100
100
100
100
100
100
100
87.5
87.5
87.5
87.5
87.5
139
100
100
87.5
["1 1 1", "5 2 4"]
The first and only line contains three integers: n, m and k (1 ≤ n, m, k ≤ 2000).
1f9107e8d1d8aebb1f4a1707a6cdeb6d
#include <iostream> #include <math.h> #include <vector> #include <algorithm> using namespace std; long long ans=1,n,m,k; int main() { cin >> n >> m >> k; if (k == 1 || k>n){ for (int i = 1; i <= n; i++){ ans = (ans*m) % 1000000007; } cout << ans; } else if (k == n){ for (int i = 1; i <= int((n + 1) / 2); i++){ ans = (ans*m) % 1000000007; } cout << ans; } else if (k % 2 == 1){ cout << m*m; } else{ cout << m; } return 0; }
["1", "2"]
C++
NoteIn the first sample only one string is valid: "a" (let's denote the only letter of our alphabet as "a").In the second sample (if we denote the alphabet letters as "a" and "b") the following strings are valid: "aaaaa" and "bbbbb".
Print a single integer — the number of strings of the described type modulo 1000000007 (109 + 7).
Just in case somebody missed it: this winter is totally cold in Nvodsk! It is so cold that one gets funny thoughts. For example, let's say there are strings with the length exactly n, based on the alphabet of size m. Any its substring with length equal to k is a palindrome. How many such strings exist? Your task is to find their quantity modulo 1000000007 (109 + 7). Be careful and don't miss a string or two!Let us remind you that a string is a palindrome if it can be read the same way in either direction, from the left to the right and from the right to the left.
[{"input": "1 1 1\r\n", "output": ["1"]}, {"input": "5 2 4\r\n", "output": ["2"]}, {"input": "7 4 20\r\n", "output": ["16384"]}, {"input": "8 13 9\r\n", "output": ["815730721"]}, {"input": "10 23 9\r\n", "output": ["529"]}, {"input": "10 25 8\r\n", "output": ["25"]}, {"input": "997 1752 1000\r\n", "output": ["184834849"]}, {"input": "784 1 1999\r\n", "output": ["1"]}, {"input": "341 9 342\r\n", "output": ["320920086"]}, {"input": "777 1 777\r\n", "output": ["1"]}, {"input": "542 13 542\r\n", "output": ["490685740"]}, {"input": "1501 893 1501\r\n", "output": ["889854713"]}, {"input": "1321 95 2\r\n", "output": ["95"]}, {"input": "2000 1000 3\r\n", "output": ["1000000"]}, {"input": "1769 849 1000\r\n", "output": ["849"]}, {"input": "1000 2 1\r\n", "output": ["688423210"]}, {"input": "345 1777 1\r\n", "output": ["756253754"]}, {"input": "1999 2000 2000\r\n", "output": ["675798323"]}, {"input": "1984 1847 1992\r\n", "output": ["345702953"]}, {"input": "2000 2000 2000\r\n", "output": ["321179016"]}, {"input": "1451 239 1451\r\n", "output": ["968856942"]}, {"input": "2000 2000 1\r\n", "output": ["596636543"]}, {"input": "1230 987 1\r\n", "output": ["890209975"]}, {"input": "1764 305 843\r\n", "output": ["93025"]}, {"input": "1999 98 132\r\n", "output": ["98"]}, {"input": "2000 2 10\r\n", "output": ["2"]}, {"input": "2000 1999 1999\r\n", "output": ["3996001"]}, {"input": "1678 1999 1234\r\n", "output": ["1999"]}, {"input": "7 10 7\r\n", "output": ["10000"]}, {"input": "15 1 15\r\n", "output": ["1"]}, {"input": "2000 2000 1000\r\n", "output": ["2000"]}, {"input": "1 2000 2000\r\n", "output": ["2000"]}, {"input": "10 10 90\r\n", "output": ["999999937"]}, {"input": "100 100 1\r\n", "output": ["424090053"]}, {"input": "6 6 6\r\n", "output": ["216"]}, {"input": "10 10 1\r\n", "output": ["999999937"]}, {"input": "100 10 100\r\n", "output": ["319300014"]}, {"input": "5 4 5\r\n", "output": ["64"]}, {"input": "5 2 5\r\n", "output": ["8"]}, {"input": "1000 1000 1000\r\n", "output": ["850431726"]}, {"input": "5 5 1\r\n", "output": ["3125"]}, {"input": "1000 1000 1\r\n", "output": ["524700271"]}, {"input": "4 256 1\r\n", "output": ["294967268"]}, {"input": "5 5 5\r\n", "output": ["125"]}, {"input": "10 10 10\r\n", "output": ["100000"]}, {"input": "100 100 100\r\n", "output": ["226732710"]}, {"input": "5 2 1\r\n", "output": ["32"]}, {"input": "4 4 4\r\n", "output": ["16"]}, {"input": "15 5 1\r\n", "output": ["517577915"]}, {"input": "1000 2 1001\r\n", "output": ["688423210"]}, {"input": "100 7 3\r\n", "output": ["49"]}, {"input": "8 2 8\r\n", "output": ["16"]}, {"input": "200 200 200\r\n", "output": ["104842676"]}, {"input": "4 4 1\r\n", "output": ["256"]}, {"input": "1999 1999 1999\r\n", "output": ["21610777"]}, {"input": "17 5 1\r\n", "output": ["939447791"]}, {"input": "100 5 1\r\n", "output": ["146981449"]}, {"input": "10 5 1\r\n", "output": ["9765625"]}, {"input": "11 2 11\r\n", "output": ["64"]}, {"input": "100 1000 1\r\n", "output": ["327648028"]}, {"input": "3 1000 3\r\n", "output": ["1000000"]}, {"input": "3 3 3\r\n", "output": ["9"]}, {"input": "3 5 3\r\n", "output": ["25"]}, {"input": "20 3 3\r\n", "output": ["9"]}, {"input": "10 2 1\r\n", "output": ["1024"]}, {"input": "7 2 7\r\n", "output": ["16"]}, {"input": "13 9 1\r\n", "output": ["865810542"]}, {"input": "11 2 5\r\n", "output": ["4"]}, {"input": "13 13 13\r\n", "output": ["62748517"]}, {"input": "239 123 239\r\n", "output": ["221051222"]}]
100
100
100
[{'input': '10 10 1\r\n', 'output': ['999999937']}, {'input': '10 25 8\r\n', 'output': ['25']}, {'input': '1501 893 1501\r\n', 'output': ['889854713']}, {'input': '3 3 3\r\n', 'output': ['9']}, {'input': '1769 849 1000\r\n', 'output': ['849']}]
[{'input': '1999 1999 1999\r\n', 'output': ['21610777']}, {'input': '777 1 777\r\n', 'output': ['1']}, {'input': '1451 239 1451\r\n', 'output': ['968856942']}, {'input': '100 10 100\r\n', 'output': ['319300014']}, {'input': '1230 987 1\r\n', 'output': ['890209975']}]
[{'input': '784 1 1999\r\n', 'output': ['1']}, {'input': '1999 1999 1999\r\n', 'output': ['21610777']}, {'input': '13 9 1\r\n', 'output': ['865810542']}, {'input': '4 4 1\r\n', 'output': ['256']}, {'input': '10 23 9\r\n', 'output': ['529']}]
[{'input': '11 2 11\r\n', 'output': ['64']}, {'input': '11 2 5\r\n', 'output': ['4']}, {'input': '10 10 10\r\n', 'output': ['100000']}, {'input': '1501 893 1501\r\n', 'output': ['889854713']}, {'input': '5 2 5\r\n', 'output': ['8']}]
[{'input': '10 2 1\r\n', 'output': ['1024']}, {'input': '5 2 1\r\n', 'output': ['32']}, {'input': '345 1777 1\r\n', 'output': ['756253754']}, {'input': '1 1 1\r\n', 'output': ['1']}, {'input': '13 9 1\r\n', 'output': ['865810542']}]
100
100
100
100
100
92.31
76.92
92.31
76.92
46.15
83.33
66.67
91.67
58.33
25
140
100
76.922
65
["2 3"]
The only line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100\,000$$$), the number of rows and the number of columns of the field.
0f1ab296cbe0952faa904f2bebe0567b
#include <iostream> #include <stdio.h> #include <string.h> using namespace std; typedef long long ll; const ll mod=1e9+7; ll n,m,f[100010][2][2],k,ans; //f[第i位][1黑0白][1/0前位与这位是否同色] int main() { scanf("%lld%lld",&n,&m); k=max(n,m); f[1][0][0]=1; f[1][1][0]=1; for(int i=2;i<=k;i++) { f[i][0][0]=(f[i-1][1][0]+f[i-1][1][1])%mod; f[i][1][0]=(f[i-1][0][0]+f[i-1][0][1])%mod; f[i][0][1]=f[i-1][0][0]; f[i][1][1]=f[i-1][1][0]; } ans=(ans+f[n][0][0])%mod; ans=(ans+f[n][1][0])%mod; ans=(ans+f[n][0][1])%mod; ans=(ans+f[n][1][1])%mod; ans=(ans+f[m][0][0])%mod; ans=(ans+f[m][1][0])%mod; ans=(ans+f[m][0][1])%mod; ans=(ans+f[m][1][1])%mod; printf("%lld\n",(ans-2+mod)%mod); }
["8"]
C++
NoteThe picture below shows all possible random pictures of size $$$2$$$ by $$$3$$$.
Print one integer, the number of random pictures modulo $$$10^9 + 7$$$.
Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in that area.To prove his skills, Ivan decided to demonstrate his friends a concept of random picture. A picture is a field of $$$n$$$ rows and $$$m$$$ columns, where each cell is either black or white. Ivan calls the picture random if for every cell it has at most one adjacent cell of the same color. Two cells are considered adjacent if they share a side.Ivan's brothers spent some time trying to explain that it's not how the randomness usually works. Trying to convince Ivan, they want to count the number of different random (according to Ivan) pictures. Two pictures are considered different if at least one cell on those two picture is colored differently. Since the number of such pictures may be quite large, print it modulo $$$10^9 + 7$$$.
[{"input": "2 3\r\n", "output": ["8"]}, {"input": "1 2\r\n", "output": ["4"]}, {"input": "1 1\r\n", "output": ["2"]}, {"input": "2 1\r\n", "output": ["4"]}, {"input": "1 3\r\n", "output": ["6"]}, {"input": "3 1\r\n", "output": ["6"]}, {"input": "2 5\r\n", "output": ["18"]}, {"input": "3 6\r\n", "output": ["30"]}, {"input": "2 2\r\n", "output": ["6"]}, {"input": "1 100000\r\n", "output": ["935236457"]}, {"input": "100000 1\r\n", "output": ["935236457"]}, {"input": "91697 91697\r\n", "output": ["999949469"]}, {"input": "86821 24538\r\n", "output": ["1000000005"]}, {"input": "100000 100000\r\n", "output": ["870472905"]}, {"input": "99999 1\r\n", "output": ["822870997"]}, {"input": "1 99999\r\n", "output": ["822870997"]}, {"input": "1 99998\r\n", "output": ["112365460"]}, {"input": "99998 1\r\n", "output": ["112365460"]}, {"input": "1 88588\r\n", "output": ["153641669"]}, {"input": "68869 1\r\n", "output": ["840775285"]}, {"input": "91248 82914\r\n", "output": ["542035391"]}, {"input": "99999 100000\r\n", "output": ["758107445"]}, {"input": "100000 99999\r\n", "output": ["758107445"]}, {"input": "99999 99999\r\n", "output": ["645741985"]}, {"input": "13771 94814\r\n", "output": ["581579207"]}, {"input": "99411 90913\r\n", "output": ["189215541"]}, {"input": "52702 64157\r\n", "output": ["1000000005"]}, {"input": "24538 86821\r\n", "output": ["1000000005"]}]
100
100
100
[{'input': '1 1\r\n', 'output': ['2']}, {'input': '2 5\r\n', 'output': ['18']}, {'input': '1 99999\r\n', 'output': ['822870997']}, {'input': '99999 1\r\n', 'output': ['822870997']}, {'input': '13771 94814\r\n', 'output': ['581579207']}]
[{'input': '2 3\r\n', 'output': ['8']}, {'input': '13771 94814\r\n', 'output': ['581579207']}, {'input': '52702 64157\r\n', 'output': ['1000000005']}, {'input': '2 1\r\n', 'output': ['4']}, {'input': '99999 100000\r\n', 'output': ['758107445']}]
[{'input': '1 3\r\n', 'output': ['6']}, {'input': '91697 91697\r\n', 'output': ['999949469']}, {'input': '2 3\r\n', 'output': ['8']}, {'input': '1 99998\r\n', 'output': ['112365460']}, {'input': '1 88588\r\n', 'output': ['153641669']}]
[{'input': '91248 82914\r\n', 'output': ['542035391']}, {'input': '1 88588\r\n', 'output': ['153641669']}, {'input': '99999 100000\r\n', 'output': ['758107445']}, {'input': '2 3\r\n', 'output': ['8']}, {'input': '1 2\r\n', 'output': ['4']}]
[{'input': '100000 100000\r\n', 'output': ['870472905']}, {'input': '1 99998\r\n', 'output': ['112365460']}, {'input': '2 2\r\n', 'output': ['6']}, {'input': '3 6\r\n', 'output': ['30']}, {'input': '99999 99999\r\n', 'output': ['645741985']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
141
100
100
100
["25\n2 3 4 5 6 7 8 9 10 11 12 14 15 16 17 18 19 20 21 22 23 24 25 26 28", "5\n16 23 8 15 4", "3\n14 15 92"]
The first line of input contains K (1 ≤ K ≤ 25), the number of onsite finalists you know. The second line of input contains r1, r2, ..., rK (1 ≤ ri ≤ 106), the qualifying ranks of the finalists you know. All these ranks are distinct.
ef657588b4f2fe8b2ff5f8edc0ab8afd
#include<iostream> #include<algorithm> using namespace std; int n; int ans; const int maxn=1e6+10; int sum[maxn]; int main() { cin>>n; for(int i=1;i<=n;i++) { cin>>sum[i]; } sort(sum+1,sum+1+n); if(sum[n]<=25) { cout<<"0"<<endl; return 0; } else { ans=sum[n]-25; } cout<<ans<<endl; return 0; }
["3", "0", "67"]
C++
NoteIn the first example, you know all 25 onsite finalists. The contestants who ranked 1-st, 13-th, and 27-th must have declined, so the answer is 3.
Print the minimum possible number of contestants that declined the invitation to compete onsite.
This year, as in previous years, MemSQL is inviting the top 25 competitors from the Start[c]up qualification round to compete onsite for the final round. Not everyone who is eligible to compete onsite can afford to travel to the office, though. Initially the top 25 contestants are invited to come onsite. Each eligible contestant must either accept or decline the invitation. Whenever a contestant declines, the highest ranked contestant not yet invited is invited to take the place of the one that declined. This continues until 25 contestants have accepted invitations.After the qualifying round completes, you know K of the onsite finalists, as well as their qualifying ranks (which start at 1, there are no ties). Determine the minimum possible number of contestants that declined the invitation to compete onsite in the final round.
[{"input": "25\r\n2 3 4 5 6 7 8 9 10 11 12 14 15 16 17 18 19 20 21 22 23 24 25 26 28\r\n", "output": ["3"]}, {"input": "5\r\n16 23 8 15 4\r\n", "output": ["0"]}, {"input": "3\r\n14 15 92\r\n", "output": ["67"]}, {"input": "1\r\n1000000\r\n", "output": ["999975"]}, {"input": "25\r\n1000000 999999 999998 999997 999996 999995 999994 999993 999992 999991 999990 999989 999988 999987 999986 999985 999984 999983 999982 999981 999980 999979 999978 999977 999976\r\n", "output": ["999975"]}, {"input": "25\r\n13 15 24 2 21 18 9 4 16 6 10 25 20 11 23 17 8 3 1 12 5 19 22 14 7\r\n", "output": ["0"]}, {"input": "10\r\n17 11 7 13 18 12 14 5 16 2\r\n", "output": ["0"]}, {"input": "22\r\n22 14 23 20 11 21 4 12 3 8 7 9 19 10 13 17 15 1 5 18 16 2\r\n", "output": ["0"]}, {"input": "21\r\n6 21 24 3 10 23 14 2 26 12 8 1 15 13 9 5 19 20 4 16 22\r\n", "output": ["1"]}, {"input": "1\r\n1\r\n", "output": ["0"]}, {"input": "2\r\n100 60\r\n", "output": ["75"]}, {"input": "4\r\n999 581 787 236\r\n", "output": ["974"]}, {"input": "6\r\n198 397 732 1234 309 827\r\n", "output": ["1209"]}, {"input": "11\r\n6494 3961 1858 4351 8056 780 7720 6211 1961 8192 3621\r\n", "output": ["8167"]}, {"input": "14\r\n18809 9534 11652 6493 8929 9370 4125 23888 16403 3559 23649 19243 14289 17852\r\n", "output": ["23863"]}, {"input": "18\r\n24939 35558 47058 70307 26221 12866 3453 40422 47557 36322 40698 64060 10825 77777 48645 26124 4859 64222\r\n", "output": ["77752"]}, {"input": "24\r\n633483 654321 122445 481150 347578 37803 525083 151084 211073 358699 339420 452023 219553 119727 74852 66750 371279 405099 618894 649977 235337 607819 81649 649804\r\n", "output": ["654296"]}, {"input": "25\r\n58115 794098 753382 484882 238434 674285 690118 858677 196185 173301 349729 918792 600745 636016 122678 366783 137179 377098 917081 369620 449039 379412 503678 1000000 292099\r\n", "output": ["999975"]}, {"input": "2\r\n26 27\r\n", "output": ["2"]}, {"input": "3\r\n40 30 35\r\n", "output": ["15"]}, {"input": "2\r\n46 45\r\n", "output": ["21"]}, {"input": "3\r\n1 25 90\r\n", "output": ["65"]}, {"input": "5\r\n14 15 16 30 92\r\n", "output": ["67"]}, {"input": "2\r\n1000 1001\r\n", "output": ["976"]}, {"input": "25\r\n3 4 5 6 7 8 9 10 11 12 14 15 16 17 18 19 20 21 22 23 24 25 26 28 2\r\n", "output": ["3"]}]
100
100
100
[{'input': '10\r\n17 11 7 13 18 12 14 5 16 2\r\n', 'output': ['0']}, {'input': '18\r\n24939 35558 47058 70307 26221 12866 3453 40422 47557 36322 40698 64060 10825 77777 48645 26124 4859 64222\r\n', 'output': ['77752']}, {'input': '25\r\n1000000 999999 999998 999997 999996 999995 999994 999993 999992 999991 999990 999989 999988 999987 999986 999985 999984 999983 999982 999981 999980 999979 999978 999977 999976\r\n', 'output': ['999975']}, {'input': '5\r\n16 23 8 15 4\r\n', 'output': ['0']}, {'input': '1\r\n1\r\n', 'output': ['0']}]
[{'input': '25\r\n2 3 4 5 6 7 8 9 10 11 12 14 15 16 17 18 19 20 21 22 23 24 25 26 28\r\n', 'output': ['3']}, {'input': '11\r\n6494 3961 1858 4351 8056 780 7720 6211 1961 8192 3621\r\n', 'output': ['8167']}, {'input': '2\r\n46 45\r\n', 'output': ['21']}, {'input': '18\r\n24939 35558 47058 70307 26221 12866 3453 40422 47557 36322 40698 64060 10825 77777 48645 26124 4859 64222\r\n', 'output': ['77752']}, {'input': '25\r\n3 4 5 6 7 8 9 10 11 12 14 15 16 17 18 19 20 21 22 23 24 25 26 28 2\r\n', 'output': ['3']}]
[{'input': '6\r\n198 397 732 1234 309 827\r\n', 'output': ['1209']}, {'input': '14\r\n18809 9534 11652 6493 8929 9370 4125 23888 16403 3559 23649 19243 14289 17852\r\n', 'output': ['23863']}, {'input': '25\r\n58115 794098 753382 484882 238434 674285 690118 858677 196185 173301 349729 918792 600745 636016 122678 366783 137179 377098 917081 369620 449039 379412 503678 1000000 292099\r\n', 'output': ['999975']}, {'input': '11\r\n6494 3961 1858 4351 8056 780 7720 6211 1961 8192 3621\r\n', 'output': ['8167']}, {'input': '25\r\n3 4 5 6 7 8 9 10 11 12 14 15 16 17 18 19 20 21 22 23 24 25 26 28 2\r\n', 'output': ['3']}]
[{'input': '2\r\n26 27\r\n', 'output': ['2']}, {'input': '25\r\n58115 794098 753382 484882 238434 674285 690118 858677 196185 173301 349729 918792 600745 636016 122678 366783 137179 377098 917081 369620 449039 379412 503678 1000000 292099\r\n', 'output': ['999975']}, {'input': '4\r\n999 581 787 236\r\n', 'output': ['974']}, {'input': '3\r\n14 15 92\r\n', 'output': ['67']}, {'input': '3\r\n40 30 35\r\n', 'output': ['15']}]
[{'input': '24\r\n633483 654321 122445 481150 347578 37803 525083 151084 211073 358699 339420 452023 219553 119727 74852 66750 371279 405099 618894 649977 235337 607819 81649 649804\r\n', 'output': ['654296']}, {'input': '1\r\n1000000\r\n', 'output': ['999975']}, {'input': '11\r\n6494 3961 1858 4351 8056 780 7720 6211 1961 8192 3621\r\n', 'output': ['8167']}, {'input': '1\r\n1\r\n', 'output': ['0']}, {'input': '5\r\n14 15 16 30 92\r\n', 'output': ['67']}]
100
100
100
100
100
100
81.82
81.82
81.82
100
100
75
75
75
100
142
100
89.092
85
["ya\n4\nah\noy\nto\nha", "hp\n2\nht\ntp", "ah\n1\nha"]
The first line contains two lowercase English letters — the password on the phone. The second line contains single integer n (1 ≤ n ≤ 100) — the number of words Kashtanka knows. The next n lines contain two lowercase English letters each, representing the words Kashtanka knows. The words are guaranteed to be distinct.
cad8283914da16bc41680857bd20fe9f
#include<stdio.h> char a1,b1,a[23333],b[23333]; int i,j,n; int main() { scanf(" %c%c",&a1,&b1); scanf("%d",&n); for(i=1;i<=n;i++) { scanf(" %c%c",&a[i],&b[i]); } for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { if((b[i]==a1&&a[j]==b1)||(a[i]==a1&&b[i]==b1)) { printf("YES\n"); return 0; } } } printf("NO\n"); }
["YES", "NO", "YES"]
C++
NoteIn the first example the password is "ya", and Kashtanka can bark "oy" and then "ah", and then "ha" to form the string "oyahha" which contains the password. So, the answer is "YES".In the second example Kashtanka can't produce a string containing password as a substring. Note that it can bark "ht" and then "tp" producing "http", but it doesn't contain the password "hp" as a substring.In the third example the string "hahahaha" contains "ah" as a substring.
Print "YES" if Kashtanka can bark several words in a line forming a string containing the password, and "NO" otherwise. You can print each letter in arbitrary case (upper or lower).
As technologies develop, manufacturers are making the process of unlocking a phone as user-friendly as possible. To unlock its new phone, Arkady's pet dog Mu-mu has to bark the password once. The phone represents a password as a string of two lowercase English letters.Mu-mu's enemy Kashtanka wants to unlock Mu-mu's phone to steal some sensible information, but it can only bark n distinct words, each of which can be represented as a string of two lowercase English letters. Kashtanka wants to bark several words (not necessarily distinct) one after another to pronounce a string containing the password as a substring. Tell if it's possible to unlock the phone in this way, or not.
[{"input": "ya\r\n4\r\nah\r\noy\r\nto\r\nha\r\n", "output": ["YES"]}, {"input": "hp\r\n2\r\nht\r\ntp\r\n", "output": ["NO"]}, {"input": "ah\r\n1\r\nha\r\n", "output": ["YES"]}, {"input": "bb\r\n4\r\nba\r\nab\r\naa\r\nbb\r\n", "output": ["YES"]}, {"input": "bc\r\n4\r\nca\r\nba\r\nbb\r\ncc\r\n", "output": ["YES"]}, {"input": "ba\r\n4\r\ncd\r\nad\r\ncc\r\ncb\r\n", "output": ["YES"]}, {"input": "pg\r\n4\r\nzl\r\nxs\r\ndi\r\nxn\r\n", "output": ["NO"]}, {"input": "bn\r\n100\r\ndf\r\nyb\r\nze\r\nml\r\nyr\r\nof\r\nnw\r\nfm\r\ndw\r\nlv\r\nzr\r\nhu\r\nzt\r\nlw\r\nld\r\nmo\r\nxz\r\ntp\r\nmr\r\nou\r\nme\r\npx\r\nvp\r\nes\r\nxi\r\nnr\r\nbx\r\nqc\r\ngm\r\njs\r\nkn\r\ntw\r\nrq\r\nkz\r\nuc\r\nvc\r\nqr\r\nab\r\nna\r\nro\r\nya\r\nqy\r\ngu\r\nvk\r\nqk\r\ngs\r\nyq\r\nop\r\nhw\r\nrj\r\neo\r\nlz\r\nbh\r\nkr\r\nkb\r\nma\r\nrd\r\nza\r\nuf\r\nhq\r\nmc\r\nmn\r\nti\r\nwn\r\nsh\r\nax\r\nsi\r\nnd\r\ntz\r\ndu\r\nfj\r\nkl\r\nws\r\now\r\nnf\r\nvr\r\nye\r\nzc\r\niw\r\nfv\r\nkv\r\noo\r\nsm\r\nbc\r\nrs\r\nau\r\nuz\r\nuv\r\ngh\r\nsu\r\njn\r\ndz\r\nrl\r\nwj\r\nbk\r\nzl\r\nas\r\nms\r\nit\r\nwu\r\n", "output": ["YES"]}, {"input": "bb\r\n1\r\naa\r\n", "output": ["NO"]}, {"input": "qm\r\n25\r\nqw\r\nwe\r\ner\r\nrt\r\nty\r\nyu\r\nui\r\nio\r\nop\r\npa\r\nas\r\nsd\r\ndf\r\nfg\r\ngh\r\nhj\r\njk\r\nkl\r\nlz\r\nzx\r\nxc\r\ncv\r\nvb\r\nbn\r\nnm\r\n", "output": ["NO"]}, {"input": "mq\r\n25\r\nqw\r\nwe\r\ner\r\nrt\r\nty\r\nyu\r\nui\r\nio\r\nop\r\npa\r\nas\r\nsd\r\ndf\r\nfg\r\ngh\r\nhj\r\njk\r\nkl\r\nlz\r\nzx\r\nxc\r\ncv\r\nvb\r\nbn\r\nnm\r\n", "output": ["YES"]}, {"input": "aa\r\n1\r\naa\r\n", "output": ["YES"]}, {"input": "bb\r\n1\r\nbb\r\n", "output": ["YES"]}, {"input": "ba\r\n1\r\ncc\r\n", "output": ["NO"]}, {"input": "ha\r\n1\r\nha\r\n", "output": ["YES"]}, {"input": "ez\r\n1\r\njl\r\n", "output": ["NO"]}, {"input": "aa\r\n2\r\nab\r\nba\r\n", "output": ["YES"]}, {"input": "aa\r\n2\r\nca\r\ncc\r\n", "output": ["NO"]}, {"input": "dd\r\n2\r\nac\r\ndc\r\n", "output": ["NO"]}, {"input": "qc\r\n2\r\nyc\r\nkr\r\n", "output": ["NO"]}, {"input": "aa\r\n3\r\nba\r\nbb\r\nab\r\n", "output": ["YES"]}, {"input": "ca\r\n3\r\naa\r\nbb\r\nab\r\n", "output": ["NO"]}, {"input": "ca\r\n3\r\nbc\r\nbd\r\nca\r\n", "output": ["YES"]}, {"input": "dd\r\n3\r\nmt\r\nrg\r\nxl\r\n", "output": ["NO"]}, {"input": "be\r\n20\r\nad\r\ncd\r\ncb\r\ndb\r\ndd\r\naa\r\nab\r\nca\r\nae\r\ned\r\ndc\r\nbb\r\nba\r\nda\r\nee\r\nea\r\ncc\r\nac\r\nec\r\neb\r\n", "output": ["YES"]}, {"input": "fc\r\n20\r\nca\r\nbb\r\nce\r\nfd\r\nde\r\nfa\r\ncc\r\nec\r\nfb\r\nfc\r\nff\r\nbe\r\ncf\r\nba\r\ndb\r\ned\r\naf\r\nae\r\nda\r\nef\r\n", "output": ["YES"]}, {"input": "ca\r\n20\r\ndc\r\naf\r\ndf\r\neg\r\naa\r\nbc\r\nea\r\nbd\r\nab\r\ndb\r\ngc\r\nfb\r\nba\r\nbe\r\nee\r\ngf\r\ncf\r\nag\r\nga\r\nca\r\n", "output": ["YES"]}, {"input": "ke\r\n20\r\nzk\r\nra\r\nbq\r\nqz\r\nwt\r\nzg\r\nmz\r\nuk\r\nge\r\nuv\r\nud\r\nfd\r\neh\r\ndm\r\nsk\r\nki\r\nfv\r\ntp\r\nat\r\nfb\r\n", "output": ["YES"]}, {"input": "hh\r\n50\r\nag\r\nhg\r\ndg\r\nfh\r\neg\r\ngh\r\ngd\r\nda\r\nbh\r\nab\r\nhf\r\ndc\r\nhb\r\nfe\r\nad\r\nec\r\nac\r\nfd\r\nca\r\naf\r\ncg\r\nhd\r\neb\r\nce\r\nhe\r\nha\r\ngb\r\nea\r\nae\r\nfb\r\nff\r\nbe\r\nch\r\nhh\r\nee\r\nde\r\nge\r\ngf\r\naa\r\ngg\r\neh\r\ned\r\nbf\r\nfc\r\nah\r\nga\r\nbd\r\ncb\r\nbg\r\nbc\r\n", "output": ["YES"]}, {"input": "id\r\n50\r\nhi\r\ndc\r\nfg\r\nee\r\ngi\r\nhc\r\nac\r\nih\r\ndg\r\nfc\r\nde\r\ned\r\nie\r\neb\r\nic\r\ncf\r\nib\r\nfa\r\ngc\r\nba\r\nbe\r\nga\r\nha\r\nhg\r\nia\r\ndf\r\nab\r\nei\r\neh\r\nad\r\nii\r\nci\r\ndh\r\nec\r\nif\r\ndi\r\nbg\r\nag\r\nhe\r\neg\r\nca\r\nae\r\ndb\r\naa\r\nid\r\nfh\r\nhh\r\ncc\r\nfb\r\ngb\r\n", "output": ["YES"]}, {"input": "fe\r\n50\r\nje\r\nbi\r\nbg\r\ngc\r\nfb\r\nig\r\ndf\r\nji\r\ndg\r\nfe\r\nfc\r\ncf\r\ngf\r\nai\r\nhe\r\nac\r\nch\r\nja\r\ngh\r\njf\r\nge\r\ncb\r\nij\r\ngb\r\ncg\r\naf\r\neh\r\nee\r\nhd\r\njd\r\njb\r\nii\r\nca\r\nci\r\nga\r\nab\r\nhi\r\nag\r\nfj\r\nej\r\nfi\r\nie\r\ndj\r\nfg\r\nef\r\njc\r\njg\r\njh\r\nhf\r\nha\r\n", "output": ["YES"]}, {"input": "rn\r\n50\r\nba\r\nec\r\nwg\r\nao\r\nlk\r\nmz\r\njj\r\ncf\r\nfa\r\njk\r\ndy\r\nsz\r\njs\r\nzr\r\nqv\r\ntx\r\nwv\r\nrd\r\nqw\r\nls\r\nrr\r\nvt\r\nrx\r\nkc\r\neh\r\nnj\r\niq\r\nyi\r\nkh\r\nue\r\nnv\r\nkz\r\nrn\r\nes\r\nua\r\nzf\r\nvu\r\nll\r\neg\r\nmj\r\ncz\r\nzj\r\nxz\r\net\r\neb\r\nci\r\nih\r\nig\r\nam\r\nvd\r\n", "output": ["YES"]}, {"input": "ee\r\n100\r\nah\r\nfb\r\ncd\r\nbi\r\nii\r\nai\r\nid\r\nag\r\nie\r\nha\r\ndi\r\nec\r\nae\r\nce\r\njb\r\ndg\r\njg\r\ngd\r\ngf\r\nda\r\nih\r\nbd\r\nhj\r\ngg\r\nhb\r\ndf\r\ned\r\nfh\r\naf\r\nja\r\nci\r\nfc\r\nic\r\nji\r\nac\r\nhi\r\nfj\r\nch\r\nbc\r\njd\r\naa\r\nff\r\nad\r\ngj\r\nej\r\nde\r\nee\r\nhe\r\ncf\r\nga\r\nia\r\ncg\r\nbb\r\nhc\r\nbe\r\ngi\r\njf\r\nbg\r\naj\r\njj\r\nbh\r\nfe\r\ndj\r\nef\r\ngb\r\nge\r\ndb\r\nig\r\ncj\r\ndc\r\nij\r\njh\r\nei\r\ndd\r\nib\r\nhf\r\neg\r\nbf\r\nfg\r\nab\r\ngc\r\nfd\r\nhd\r\ngh\r\neh\r\njc\r\neb\r\nhh\r\nca\r\nje\r\nbj\r\nif\r\nea\r\nhg\r\nfa\r\ncc\r\nba\r\ndh\r\ncb\r\nfi\r\n", "output": ["YES"]}, {"input": "if\r\n100\r\njd\r\nbc\r\nje\r\nhi\r\nga\r\nde\r\nkb\r\nfc\r\ncd\r\ngd\r\naj\r\ncb\r\nei\r\nbf\r\ncf\r\ndk\r\ndb\r\ncg\r\nki\r\ngg\r\nkg\r\nfa\r\nkj\r\nii\r\njf\r\njg\r\ngb\r\nbh\r\nbg\r\neh\r\nhj\r\nhb\r\ndg\r\ndj\r\njc\r\njb\r\nce\r\ndi\r\nig\r\nci\r\ndf\r\nji\r\nhc\r\nfk\r\naf\r\nac\r\ngk\r\nhd\r\nae\r\nkd\r\nec\r\nkc\r\neb\r\nfh\r\nij\r\nie\r\nca\r\nhh\r\nkf\r\nha\r\ndd\r\nif\r\nef\r\nih\r\nhg\r\nej\r\nfe\r\njk\r\nea\r\nib\r\nck\r\nhf\r\nak\r\ngi\r\nch\r\ndc\r\nba\r\nke\r\nad\r\nka\r\neg\r\njh\r\nja\r\ngc\r\nfd\r\ncc\r\nab\r\ngj\r\nik\r\nfg\r\nbj\r\nhe\r\nfj\r\nge\r\ngh\r\nhk\r\nbk\r\ned\r\nid\r\nfi\r\n", "output": ["YES"]}, {"input": "kd\r\n100\r\nek\r\nea\r\nha\r\nkf\r\nkj\r\ngh\r\ndl\r\nfj\r\nal\r\nga\r\nlj\r\nik\r\ngd\r\nid\r\ncb\r\nfh\r\ndk\r\nif\r\nbh\r\nkb\r\nhc\r\nej\r\nhk\r\ngc\r\ngb\r\nef\r\nkk\r\nll\r\nlf\r\nkh\r\ncl\r\nlh\r\njj\r\nil\r\nhh\r\nci\r\ndb\r\ndf\r\ngk\r\njg\r\nch\r\nbd\r\ncg\r\nfg\r\nda\r\neb\r\nlg\r\ndg\r\nbk\r\nje\r\nbg\r\nbl\r\njl\r\ncj\r\nhb\r\nei\r\naa\r\ngl\r\nka\r\nfa\r\nfi\r\naf\r\nkc\r\nla\r\ngi\r\nij\r\nib\r\nle\r\ndi\r\nck\r\nag\r\nlc\r\nca\r\nge\r\nie\r\nlb\r\nke\r\nii\r\nae\r\nig\r\nic\r\nhe\r\ncf\r\nhd\r\nak\r\nfb\r\nhi\r\ngf\r\nad\r\nba\r\nhg\r\nbi\r\nkl\r\nac\r\ngg\r\ngj\r\nbe\r\nlk\r\nld\r\naj\r\n", "output": ["YES"]}, {"input": "ab\r\n1\r\nab\r\n", "output": ["YES"]}, {"input": "ya\r\n1\r\nya\r\n", "output": ["YES"]}, {"input": "ay\r\n1\r\nyb\r\n", "output": ["NO"]}, {"input": "ax\r\n2\r\nii\r\nxa\r\n", "output": ["YES"]}, {"input": "hi\r\n1\r\nhi\r\n", "output": ["YES"]}, {"input": "ag\r\n1\r\nag\r\n", "output": ["YES"]}, {"input": "th\r\n1\r\nth\r\n", "output": ["YES"]}, {"input": "sb\r\n1\r\nsb\r\n", "output": ["YES"]}, {"input": "hp\r\n1\r\nhp\r\n", "output": ["YES"]}, {"input": "ah\r\n1\r\nah\r\n", "output": ["YES"]}, {"input": "ta\r\n1\r\nta\r\n", "output": ["YES"]}, {"input": "tb\r\n1\r\ntb\r\n", "output": ["YES"]}, {"input": "ab\r\n5\r\nca\r\nda\r\nea\r\nfa\r\nka\r\n", "output": ["NO"]}, {"input": "ac\r\n1\r\nac\r\n", "output": ["YES"]}, {"input": "ha\r\n2\r\nha\r\nzz\r\n", "output": ["YES"]}, {"input": "ok\r\n1\r\nok\r\n", "output": ["YES"]}, {"input": "bc\r\n1\r\nbc\r\n", "output": ["YES"]}, {"input": "az\r\n1\r\nzz\r\n", "output": ["NO"]}, {"input": "ab\r\n2\r\nba\r\ntt\r\n", "output": ["YES"]}, {"input": "ah\r\n2\r\nap\r\nhp\r\n", "output": ["NO"]}, {"input": "sh\r\n1\r\nsh\r\n", "output": ["YES"]}, {"input": "az\r\n1\r\nby\r\n", "output": ["NO"]}, {"input": "as\r\n1\r\nas\r\n", "output": ["YES"]}, {"input": "ab\r\n2\r\nab\r\ncd\r\n", "output": ["YES"]}, {"input": "ab\r\n2\r\nxa\r\nza\r\n", "output": ["NO"]}, {"input": "ab\r\n2\r\net\r\nab\r\n", "output": ["YES"]}, {"input": "ab\r\n1\r\naa\r\n", "output": ["NO"]}, {"input": "ab\r\n2\r\nab\r\nde\r\n", "output": ["YES"]}, {"input": "ah\r\n2\r\nba\r\nha\r\n", "output": ["YES"]}, {"input": "ha\r\n3\r\ndd\r\ncc\r\nha\r\n", "output": ["YES"]}, {"input": "oo\r\n1\r\nox\r\n", "output": ["NO"]}, {"input": "ab\r\n2\r\nax\r\nbx\r\n", "output": ["NO"]}, {"input": "ww\r\n4\r\nuw\r\now\r\npo\r\nko\r\n", "output": ["NO"]}, {"input": "ay\r\n1\r\nay\r\n", "output": ["YES"]}, {"input": "yo\r\n1\r\nyo\r\n", "output": ["YES"]}, {"input": "ba\r\n1\r\nba\r\n", "output": ["YES"]}, {"input": "qw\r\n1\r\nqw\r\n", "output": ["YES"]}, {"input": "la\r\n1\r\nla\r\n", "output": ["YES"]}, {"input": "ab\r\n2\r\nbb\r\nbc\r\n", "output": ["NO"]}, {"input": "aa\r\n2\r\nab\r\nac\r\n", "output": ["NO"]}, {"input": "ah\r\n2\r\nbb\r\nha\r\n", "output": ["YES"]}, {"input": "ya\r\n42\r\nab\r\nac\r\nad\r\nae\r\naf\r\nag\r\nah\r\nai\r\nak\r\naj\r\nba\r\nbc\r\nbd\r\nbe\r\nbf\r\nbg\r\nbh\r\nbi\r\nbk\r\nbj\r\ncb\r\nca\r\ncd\r\nce\r\ncf\r\ncg\r\nch\r\nci\r\nck\r\ncj\r\ndb\r\ndc\r\nda\r\nde\r\ndf\r\ndg\r\ndh\r\ndi\r\ndk\r\ndj\r\nef\r\nek\r\n", "output": ["NO"]}, {"input": "ab\r\n3\r\nab\r\nxx\r\nyy\r\n", "output": ["YES"]}, {"input": "ab\r\n2\r\nab\r\ncc\r\n", "output": ["YES"]}, {"input": "sa\r\n2\r\nxx\r\nas\r\n", "output": ["YES"]}, {"input": "ma\r\n1\r\nma\r\n", "output": ["YES"]}, {"input": "ba\r\n1\r\nbb\r\n", "output": ["NO"]}, {"input": "bc\r\n1\r\nab\r\n", "output": ["NO"]}, {"input": "fa\r\n1\r\nfa\r\n", "output": ["YES"]}, {"input": "ap\r\n1\r\nap\r\n", "output": ["YES"]}, {"input": "ab\r\n1\r\nbb\r\n", "output": ["NO"]}, {"input": "bk\r\n1\r\nbk\r\n", "output": ["YES"]}, {"input": "xy\r\n2\r\nxy\r\naa\r\n", "output": ["YES"]}, {"input": "ab\r\n2\r\nza\r\nbz\r\n", "output": ["YES"]}]
100
100
100
[{'input': 'ay\r\n1\r\nay\r\n', 'output': ['YES']}, {'input': 'if\r\n100\r\njd\r\nbc\r\nje\r\nhi\r\nga\r\nde\r\nkb\r\nfc\r\ncd\r\ngd\r\naj\r\ncb\r\nei\r\nbf\r\ncf\r\ndk\r\ndb\r\ncg\r\nki\r\ngg\r\nkg\r\nfa\r\nkj\r\nii\r\njf\r\njg\r\ngb\r\nbh\r\nbg\r\neh\r\nhj\r\nhb\r\ndg\r\ndj\r\njc\r\njb\r\nce\r\ndi\r\nig\r\nci\r\ndf\r\nji\r\nhc\r\nfk\r\naf\r\nac\r\ngk\r\nhd\r\nae\r\nkd\r\nec\r\nkc\r\neb\r\nfh\r\nij\r\nie\r\nca\r\nhh\r\nkf\r\nha\r\ndd\r\nif\r\nef\r\nih\r\nhg\r\nej\r\nfe\r\njk\r\nea\r\nib\r\nck\r\nhf\r\nak\r\ngi\r\nch\r\ndc\r\nba\r\nke\r\nad\r\nka\r\neg\r\njh\r\nja\r\ngc\r\nfd\r\ncc\r\nab\r\ngj\r\nik\r\nfg\r\nbj\r\nhe\r\nfj\r\nge\r\ngh\r\nhk\r\nbk\r\ned\r\nid\r\nfi\r\n', 'output': ['YES']}, {'input': 'ah\r\n1\r\nah\r\n', 'output': ['YES']}, {'input': 'bb\r\n1\r\naa\r\n', 'output': ['NO']}, {'input': 'fa\r\n1\r\nfa\r\n', 'output': ['YES']}]
[{'input': 'ok\r\n1\r\nok\r\n', 'output': ['YES']}, {'input': 'az\r\n1\r\nby\r\n', 'output': ['NO']}, {'input': 'aa\r\n2\r\nca\r\ncc\r\n', 'output': ['NO']}, {'input': 'aa\r\n1\r\naa\r\n', 'output': ['YES']}, {'input': 'hp\r\n1\r\nhp\r\n', 'output': ['YES']}]
[{'input': 'aa\r\n1\r\naa\r\n', 'output': ['YES']}, {'input': 'hh\r\n50\r\nag\r\nhg\r\ndg\r\nfh\r\neg\r\ngh\r\ngd\r\nda\r\nbh\r\nab\r\nhf\r\ndc\r\nhb\r\nfe\r\nad\r\nec\r\nac\r\nfd\r\nca\r\naf\r\ncg\r\nhd\r\neb\r\nce\r\nhe\r\nha\r\ngb\r\nea\r\nae\r\nfb\r\nff\r\nbe\r\nch\r\nhh\r\nee\r\nde\r\nge\r\ngf\r\naa\r\ngg\r\neh\r\ned\r\nbf\r\nfc\r\nah\r\nga\r\nbd\r\ncb\r\nbg\r\nbc\r\n', 'output': ['YES']}, {'input': 'ah\r\n1\r\nah\r\n', 'output': ['YES']}, {'input': 'az\r\n1\r\nzz\r\n', 'output': ['NO']}, {'input': 'aa\r\n2\r\nab\r\nac\r\n', 'output': ['NO']}]
[{'input': 'ah\r\n1\r\nah\r\n', 'output': ['YES']}, {'input': 'fe\r\n50\r\nje\r\nbi\r\nbg\r\ngc\r\nfb\r\nig\r\ndf\r\nji\r\ndg\r\nfe\r\nfc\r\ncf\r\ngf\r\nai\r\nhe\r\nac\r\nch\r\nja\r\ngh\r\njf\r\nge\r\ncb\r\nij\r\ngb\r\ncg\r\naf\r\neh\r\nee\r\nhd\r\njd\r\njb\r\nii\r\nca\r\nci\r\nga\r\nab\r\nhi\r\nag\r\nfj\r\nej\r\nfi\r\nie\r\ndj\r\nfg\r\nef\r\njc\r\njg\r\njh\r\nhf\r\nha\r\n', 'output': ['YES']}, {'input': 'ab\r\n5\r\nca\r\nda\r\nea\r\nfa\r\nka\r\n', 'output': ['NO']}, {'input': 'aa\r\n3\r\nba\r\nbb\r\nab\r\n', 'output': ['YES']}, {'input': 'be\r\n20\r\nad\r\ncd\r\ncb\r\ndb\r\ndd\r\naa\r\nab\r\nca\r\nae\r\ned\r\ndc\r\nbb\r\nba\r\nda\r\nee\r\nea\r\ncc\r\nac\r\nec\r\neb\r\n', 'output': ['YES']}]
[{'input': 'qc\r\n2\r\nyc\r\nkr\r\n', 'output': ['NO']}, {'input': 'sb\r\n1\r\nsb\r\n', 'output': ['YES']}, {'input': 'dd\r\n2\r\nac\r\ndc\r\n', 'output': ['NO']}, {'input': 'bb\r\n4\r\nba\r\nab\r\naa\r\nbb\r\n', 'output': ['YES']}, {'input': 'sh\r\n1\r\nsh\r\n', 'output': ['YES']}]
100
100
100
100
100
100
100
100
100
100
92.86
92.86
100
100
92.86
143
100
100
95.716
["XX.\n...\n.XX", "X.X\nX..\n..."]
Input contains the matrix of three rows of three symbols each. Symbol «X» means that the corresponding button was pressed, and «.» means that is was not pressed. The matrix may contain no «X», also it may contain no «.».
6a5fe5fac8a4e3993dc3423180cdd6a9
#include<bits/stdc++.h> using namespace std; string s1,s2,s3; int main(){ cin>>s1>>s2>>s3; s1=s1+s2; s1=s1+s3; for(int i=0;i<=3;i++){ if(s1[i]!=s1[8-i]){ printf("NO"); return 0; } } printf("YES"); return 0; }
["YES", "NO"]
C++
NoteIf you are not familiar with the term «central symmetry», you may look into http://en.wikipedia.org/wiki/Central_symmetry
Print YES if the password is symmetric with respect to the central button of the terminal and NO otherwise.
There is a very secret base in Potatoland where potato mash is made according to a special recipe. The neighbours from Porridgia decided to seize this recipe and to sell it to Pilauland. For this mission they have been preparing special agent Pearlo for many years. When, finally, Pearlo learned all secrets of espionage, he penetrated into the Potatoland territory and reached the secret base.Now he is standing at the entrance, but to get inside he need to pass combination lock. Minute ago one of the workers entered the password on the terminal and opened the door. The terminal is a square digital keyboard 3 × 3 with digits from 1 to 9.Pearlo knows that the password consists from distinct digits and is probably symmetric with respect to the central button of the terminal. He has heat sensor which allowed him to detect the digits which the worker pressed. Now he wants to check whether the password entered by the worker is symmetric with respect to the central button of the terminal. This fact can Help Pearlo to reduce the number of different possible password combinations.
[{"input": "XX.\r\n...\r\n.XX\r\n", "output": ["YES"]}, {"input": "X.X\r\nX..\r\n...\r\n", "output": ["NO"]}, {"input": "...\r\n...\r\n...\r\n", "output": ["YES"]}, {"input": ".X.\r\n.X.\r\n.X.\r\n", "output": ["YES"]}, {"input": "XXX\r\nXXX\r\nXXX\r\n", "output": ["YES"]}, {"input": "XXX\r\nX.X\r\nXXX\r\n", "output": ["YES"]}, {"input": "X..\r\n.X.\r\n..X\r\n", "output": ["YES"]}, {"input": "...\r\nX.X\r\nX..\r\n", "output": ["NO"]}, {"input": ".X.\r\nX.X\r\n.X.\r\n", "output": ["YES"]}, {"input": "X.X\r\n.X.\r\nX.X\r\n", "output": ["YES"]}, {"input": "...\r\n...\r\n..X\r\n", "output": ["NO"]}, {"input": "...\r\n.X.\r\n...\r\n", "output": ["YES"]}, {"input": "XXX\r\n...\r\nXXX\r\n", "output": ["YES"]}, {"input": "...\r\nXXX\r\n...\r\n", "output": ["YES"]}, {"input": "..X\r\nX..\r\n..X\r\n", "output": ["NO"]}, {"input": ".X.\r\n...\r\nX.X\r\n", "output": ["NO"]}, {"input": "X.X\r\nX.X\r\nX.X\r\n", "output": ["YES"]}, {"input": ".X.\r\nX.X\r\nXX.\r\n", "output": ["NO"]}, {"input": "...\r\nXXX\r\nXXX\r\n", "output": ["NO"]}, {"input": "...\r\nX.X\r\n...\r\n", "output": ["YES"]}, {"input": "XXX\r\n..X\r\nXXX\r\n", "output": ["NO"]}, {"input": "X..\r\nX.X\r\n.X.\r\n", "output": ["NO"]}, {"input": "...\r\n..X\r\nXXX\r\n", "output": ["NO"]}, {"input": "..X\r\nX.X\r\nX..\r\n", "output": ["YES"]}, {"input": "..X\r\n..X\r\nXXX\r\n", "output": ["NO"]}, {"input": "X..\r\nX..\r\nX..\r\n", "output": ["NO"]}, {"input": "XXX\r\n.X.\r\n...\r\n", "output": ["NO"]}, {"input": "XXX\r\n.X.\r\nXXX\r\n", "output": ["YES"]}, {"input": "X..\r\n...\r\n...\r\n", "output": ["NO"]}, {"input": "..X\r\n...\r\nX..\r\n", "output": ["YES"]}, {"input": ".X.\r\n...\r\n...\r\n", "output": ["NO"]}, {"input": "..X\r\n...\r\n...\r\n", "output": ["NO"]}, {"input": "...\r\nX..\r\n...\r\n", "output": ["NO"]}, {"input": "...\r\n..X\r\n...\r\n", "output": ["NO"]}, {"input": "...\r\n...\r\nX..\r\n", "output": ["NO"]}, {"input": "...\r\n...\r\n.X.\r\n", "output": ["NO"]}, {"input": "...\r\n.X.\r\nX..\r\n", "output": ["NO"]}]
100
100
100
[{'input': '.X.\r\n...\r\n...\r\n', 'output': ['NO']}, {'input': 'XXX\r\n...\r\nXXX\r\n', 'output': ['YES']}, {'input': '...\r\nX.X\r\n...\r\n', 'output': ['YES']}, {'input': '..X\r\nX.X\r\nX..\r\n', 'output': ['YES']}, {'input': '.X.\r\n...\r\nX.X\r\n', 'output': ['NO']}]
[{'input': 'X..\r\n.X.\r\n..X\r\n', 'output': ['YES']}, {'input': 'XXX\r\n.X.\r\nXXX\r\n', 'output': ['YES']}, {'input': 'X.X\r\nX.X\r\nX.X\r\n', 'output': ['YES']}, {'input': '...\r\nX.X\r\nX..\r\n', 'output': ['NO']}, {'input': 'XXX\r\nXXX\r\nXXX\r\n', 'output': ['YES']}]
[{'input': 'X.X\r\nX..\r\n...\r\n', 'output': ['NO']}, {'input': '..X\r\n...\r\nX..\r\n', 'output': ['YES']}, {'input': '...\r\n...\r\n..X\r\n', 'output': ['NO']}, {'input': 'XXX\r\n.X.\r\nXXX\r\n', 'output': ['YES']}, {'input': '..X\r\n...\r\n...\r\n', 'output': ['NO']}]
[{'input': 'XXX\r\nX.X\r\nXXX\r\n', 'output': ['YES']}, {'input': 'XXX\r\n...\r\nXXX\r\n', 'output': ['YES']}, {'input': '...\r\n..X\r\nXXX\r\n', 'output': ['NO']}, {'input': 'X.X\r\nX..\r\n...\r\n', 'output': ['NO']}, {'input': '.X.\r\n.X.\r\n.X.\r\n', 'output': ['YES']}]
[{'input': '...\r\n...\r\n.X.\r\n', 'output': ['NO']}, {'input': 'XXX\r\n.X.\r\n...\r\n', 'output': ['NO']}, {'input': '...\r\n...\r\n...\r\n', 'output': ['YES']}, {'input': 'XXX\r\n.X.\r\nXXX\r\n', 'output': ['YES']}, {'input': 'XXX\r\nXXX\r\nXXX\r\n', 'output': ['YES']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
144
100
100
100
["1 5", "2 3"]
The first line of input contains two space-separated integers m and b (1 ≤ m ≤ 1000, 1 ≤ b ≤ 10000).
9300f1c07dd36e0cf7e6cb7911df4cf2
#include <bits/stdc++.h> #include <stdio.h> #define PB push_back #define f(i,a,b) for(int i=a;i<b;i++) #define MAX 4002 using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vll; ll m,b; ll f; int main() { cin>>m>>b; for(ll x=0;x<=m*b;x++) { ll y= -(x+m-1)/m+b; f=max(f,(x*(x+1)*(y+1)+y*(y+1)*(x+1))/2); } cout<<f; }
["30", "25"]
C++
Note The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas.
Print the maximum number of bananas Okabe can get from the trees he cuts.
Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees.Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≤ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation . Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point.Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely.Okabe is sure that the answer does not exceed 1018. You can trust him.
[{"input": "1 5\r\n", "output": ["30"]}, {"input": "2 3\r\n", "output": ["25"]}, {"input": "4 6\r\n", "output": ["459"]}, {"input": "6 3\r\n", "output": ["171"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "10 1\r\n", "output": ["55"]}, {"input": "20 10\r\n", "output": ["40326"]}, {"input": "1000 10000\r\n", "output": ["74133360011484445"]}, {"input": "139 9252\r\n", "output": ["1137907933561080"]}, {"input": "859 8096\r\n", "output": ["29032056230649780"]}, {"input": "987 4237\r\n", "output": ["5495451829240878"]}, {"input": "411 3081\r\n", "output": ["366755153481948"]}, {"input": "539 9221\r\n", "output": ["16893595018603386"]}, {"input": "259 770\r\n", "output": ["2281741798549"]}, {"input": "387 5422\r\n", "output": ["1771610559998400"]}, {"input": "515 1563\r\n", "output": ["75233740231341"]}, {"input": "939 407\r\n", "output": ["4438222781916"]}, {"input": "518 6518\r\n", "output": ["5511730799718825"]}, {"input": "646 1171\r\n", "output": ["49802404050106"]}, {"input": "70 7311\r\n", "output": ["142915220249910"]}, {"input": "494 6155\r\n", "output": ["4221391613846823"]}, {"input": "918 7704\r\n", "output": ["28569727339126165"]}, {"input": "46 3844\r\n", "output": ["9007500020760"]}, {"input": "174 2688\r\n", "output": ["43730657099581"]}, {"input": "894 4637\r\n", "output": ["5909849585253250"]}, {"input": "22 3481\r\n", "output": ["1548544125646"]}, {"input": "446 5030\r\n", "output": ["1878390629993745"]}, {"input": "440 8704\r\n", "output": ["9470470760118060"]}, {"input": "569 7548\r\n", "output": ["10326205017481606"]}, {"input": "289 6393\r\n", "output": ["1620061541812350"]}, {"input": "417 1045\r\n", "output": ["14758909519725"]}, {"input": "841 7185\r\n", "output": ["19452619774222875"]}, {"input": "969 6030\r\n", "output": ["15265318959845745"]}, {"input": "393 4874\r\n", "output": ["1327174123029975"]}, {"input": "817 3719\r\n", "output": ["2546859449982016"]}, {"input": "945 2563\r\n", "output": ["1115613396515835"]}, {"input": "369 4511\r\n", "output": ["927715710215505"]}, {"input": "555 3594\r\n", "output": ["1061060598862891"]}]
100
100
100
[{'input': '646 1171\r\n', 'output': ['49802404050106']}, {'input': '259 770\r\n', 'output': ['2281741798549']}, {'input': '139 9252\r\n', 'output': ['1137907933561080']}, {'input': '945 2563\r\n', 'output': ['1115613396515835']}, {'input': '6 3\r\n', 'output': ['171']}]
[{'input': '446 5030\r\n', 'output': ['1878390629993745']}, {'input': '440 8704\r\n', 'output': ['9470470760118060']}, {'input': '539 9221\r\n', 'output': ['16893595018603386']}, {'input': '10 1\r\n', 'output': ['55']}, {'input': '46 3844\r\n', 'output': ['9007500020760']}]
[{'input': '393 4874\r\n', 'output': ['1327174123029975']}, {'input': '440 8704\r\n', 'output': ['9470470760118060']}, {'input': '10 1\r\n', 'output': ['55']}, {'input': '369 4511\r\n', 'output': ['927715710215505']}, {'input': '646 1171\r\n', 'output': ['49802404050106']}]
[{'input': '1000 10000\r\n', 'output': ['74133360011484445']}, {'input': '446 5030\r\n', 'output': ['1878390629993745']}, {'input': '440 8704\r\n', 'output': ['9470470760118060']}, {'input': '393 4874\r\n', 'output': ['1327174123029975']}, {'input': '10 1\r\n', 'output': ['55']}]
[{'input': '289 6393\r\n', 'output': ['1620061541812350']}, {'input': '2 3\r\n', 'output': ['25']}, {'input': '259 770\r\n', 'output': ['2281741798549']}, {'input': '515 1563\r\n', 'output': ['75233740231341']}, {'input': '1 5\r\n', 'output': ['30']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
145
100
100
100
["1", "2", "10"]
The only line of the input file contains a single integer $$$n$$$ ($$$1 \le n \le 10^9$$$) — the number of roman digits to use.
75ec99318736a8a1b62a8d51efd95355
#include <bits/stdc++.h> using namespace std; #define fst first #define snd second #define mp make_pair #define rep(i,a,n) for(int i=(a);i<(n);++i) #define per(i,a,n) for(int i=(n)-1;i>=(a);--i) #define all(x) (x).begin(),(x).end() template <typename T1, typename T2> inline bool umin(T1& x, const T2& y){return x>y ? x=y,true : false;} template <typename T1, typename T2> inline bool umax(T1& x, const T2& y){return x<y ? x=y,true : false;} typedef long long ll; typedef long double ld; typedef pair<int,int> pii; const int N = (int)1e5+5; const int mod = (int)1e9+7; const int INF = (int)1e9+17; const ll LLINF = (ll)1e18+17; int n; int ans[N]; bool dp[53][5001]; void prepare() { dp[0][0] = true; rep(i, 0, 5001) { rep(j, 0, 51) { for(int x:{1, 5, 10, 50}) { if (i + x <= 5000) dp[j+1][i+x] |= dp[j][i]; } ans[j] += dp[j][i]; } } } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr); #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else // freopen("river.in", "r", stdin); // freopen("river.out", "w", stdout); #endif prepare(); cin >> n; if (n <= 50) { cout << ans[n] << endl; } else { cout << ans[50] + 49ll * (n-50) << endl; } return 0; }
["4", "10", "244"]
C++
NoteIn the first sample there are exactly $$$4$$$ integers which can be represented — I, V, X and L.In the second sample it is possible to represent integers $$$2$$$ (II), $$$6$$$ (VI), $$$10$$$ (VV), $$$11$$$ (XI), $$$15$$$ (XV), $$$20$$$ (XX), $$$51$$$ (IL), $$$55$$$ (VL), $$$60$$$ (XL) and $$$100$$$ (LL).
Output a single integer — the number of distinct integers which can be represented using $$$n$$$ roman digits exactly.
Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $$$1$$$, $$$5$$$, $$$10$$$ and $$$50$$$ respectively. The use of other roman digits is not allowed.Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence simply as the sum of digits in it.For example, the number XXXV evaluates to $$$35$$$ and the number IXI — to $$$12$$$.Pay attention to the difference to the traditional roman system — in our system any sequence of digits is valid, moreover the order of digits doesn't matter, for example IX means $$$11$$$, not $$$9$$$.One can notice that this system is ambiguous, and some numbers can be written in many different ways. Your goal is to determine how many distinct integers can be represented by exactly $$$n$$$ roman digits I, V, X, L.
[{"input": "1\r\n", "output": ["4"]}, {"input": "2\r\n", "output": ["10"]}, {"input": "10\r\n", "output": ["244"]}, {"input": "1000\r\n", "output": ["48753"]}, {"input": "2000\r\n", "output": ["97753"]}, {"input": "5000\r\n", "output": ["244753"]}, {"input": "10000\r\n", "output": ["489753"]}, {"input": "111199\r\n", "output": ["5448504"]}, {"input": "101232812\r\n", "output": ["4960407541"]}, {"input": "1000000000\r\n", "output": ["48999999753"]}, {"input": "3\r\n", "output": ["20"]}, {"input": "4\r\n", "output": ["35"]}, {"input": "5\r\n", "output": ["56"]}, {"input": "6\r\n", "output": ["83"]}, {"input": "7\r\n", "output": ["116"]}, {"input": "8\r\n", "output": ["155"]}, {"input": "9\r\n", "output": ["198"]}, {"input": "11\r\n", "output": ["292"]}, {"input": "12\r\n", "output": ["341"]}, {"input": "13\r\n", "output": ["390"]}, {"input": "55\r\n", "output": ["2448"]}, {"input": "100\r\n", "output": ["4653"]}, {"input": "150\r\n", "output": ["7103"]}, {"input": "1200\r\n", "output": ["58553"]}, {"input": "9999999\r\n", "output": ["489999704"]}, {"input": "100000000\r\n", "output": ["4899999753"]}, {"input": "500000000\r\n", "output": ["24499999753"]}, {"input": "600000000\r\n", "output": ["29399999753"]}, {"input": "709000900\r\n", "output": ["34741043853"]}, {"input": "999999999\r\n", "output": ["48999999704"]}, {"input": "20\r\n", "output": ["733"]}, {"input": "35\r\n", "output": ["1468"]}, {"input": "56\r\n", "output": ["2497"]}, {"input": "83\r\n", "output": ["3820"]}, {"input": "116\r\n", "output": ["5437"]}, {"input": "155\r\n", "output": ["7348"]}, {"input": "198\r\n", "output": ["9455"]}, {"input": "244\r\n", "output": ["11709"]}, {"input": "292\r\n", "output": ["14061"]}, {"input": "14\r\n", "output": ["439"]}]
100
100
100
[{'input': '2\r\n', 'output': ['10']}, {'input': '1200\r\n', 'output': ['58553']}, {'input': '14\r\n', 'output': ['439']}, {'input': '5\r\n', 'output': ['56']}, {'input': '600000000\r\n', 'output': ['29399999753']}]
[{'input': '20\r\n', 'output': ['733']}, {'input': '1\r\n', 'output': ['4']}, {'input': '55\r\n', 'output': ['2448']}, {'input': '5\r\n', 'output': ['56']}, {'input': '101232812\r\n', 'output': ['4960407541']}]
[{'input': '9\r\n', 'output': ['198']}, {'input': '1200\r\n', 'output': ['58553']}, {'input': '6\r\n', 'output': ['83']}, {'input': '116\r\n', 'output': ['5437']}, {'input': '2\r\n', 'output': ['10']}]
[{'input': '5\r\n', 'output': ['56']}, {'input': '10\r\n', 'output': ['244']}, {'input': '10000\r\n', 'output': ['489753']}, {'input': '155\r\n', 'output': ['7348']}, {'input': '1000\r\n', 'output': ['48753']}]
[{'input': '111199\r\n', 'output': ['5448504']}, {'input': '10\r\n', 'output': ['244']}, {'input': '12\r\n', 'output': ['341']}, {'input': '7\r\n', 'output': ['116']}, {'input': '2000\r\n', 'output': ['97753']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
146
100
100
100
["4\n1001", "1\n1"]
The first line contains integer number n (1 ≤ n ≤ 100) — the length of string s. The second line contains the string s consisting of characters "0" and "1". It is guaranteed that the string s is correct.
ac244791f8b648d672ed3de32ce0074d
#include <iostream> using namespace std; string s; int k,i; main(){ cin>>i>>s; for (i=0; i<s.size();i++) if (s[i]=='0') k++; if(k!=s.size()) cout<<1; for (i=0; i<k; i++) cout<<0; }
["100", "1"]
C++
NoteIn the first example you can obtain the answer by the following sequence of operations: "1001" "1010" "1100" "100".In the second example you can't obtain smaller answer no matter what operations you use.
Print one string — the minimum correct string that you can obtain from the given one.
String can be called correct if it consists of characters "0" and "1" and there are no redundant leading zeroes. Here are some examples: "0", "10", "1001".You are given a correct string s.You can perform two different operations on this string: swap any pair of adjacent characters (for example, "101" "110"); replace "11" with "1" (for example, "110" "10"). Let val(s) be such a number that s is its binary representation.Correct string a is less than some other correct string b iff val(a) &lt; val(b).Your task is to find the minimum correct string that you can obtain from the given one using the operations described above. You can use these operations any number of times in any order (or even use no operations at all).
[{"input": "4\r\n1001\r\n", "output": ["100"]}, {"input": "1\r\n1\r\n", "output": ["1"]}, {"input": "100\r\n1110111100001111011111111010110011111111011110000111101101011100110110001011000000101010110101011100\r\n", "output": ["1000000000000000000000000000000000000000"]}, {"input": "100\r\n1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r\n", "output": ["1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"]}, {"input": "100\r\n1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\r\n", "output": ["1"]}, {"input": "100\r\n1111111111111111111111111111111111111111111111111111111110111111111111111111111111111111111111111111\r\n", "output": ["10"]}, {"input": "1\r\n0\r\n", "output": ["0"]}, {"input": "8\r\n10101010\r\n", "output": ["10000"]}, {"input": "2\r\n10\r\n", "output": ["10"]}, {"input": "3\r\n111\r\n", "output": ["1"]}, {"input": "5\r\n11100\r\n", "output": ["100"]}, {"input": "2\r\n11\r\n", "output": ["1"]}, {"input": "3\r\n110\r\n", "output": ["10"]}, {"input": "50\r\n10010010000000000000000000000000000000001000000000\r\n", "output": ["10000000000000000000000000000000000000000000000"]}]
100
100
100
[{'input': '100\r\n1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\r\n', 'output': ['1']}, {'input': '50\r\n10010010000000000000000000000000000000001000000000\r\n', 'output': ['10000000000000000000000000000000000000000000000']}, {'input': '100\r\n1111111111111111111111111111111111111111111111111111111110111111111111111111111111111111111111111111\r\n', 'output': ['10']}, {'input': '2\r\n10\r\n', 'output': ['10']}, {'input': '2\r\n11\r\n', 'output': ['1']}]
[{'input': '1\r\n0\r\n', 'output': ['0']}, {'input': '1\r\n1\r\n', 'output': ['1']}, {'input': '3\r\n110\r\n', 'output': ['10']}, {'input': '50\r\n10010010000000000000000000000000000000001000000000\r\n', 'output': ['10000000000000000000000000000000000000000000000']}, {'input': '100\r\n1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r\n', 'output': ['1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000']}]
[{'input': '100\r\n1111111111111111111111111111111111111111111111111111111110111111111111111111111111111111111111111111\r\n', 'output': ['10']}, {'input': '100\r\n1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\r\n', 'output': ['1']}, {'input': '100\r\n1110111100001111011111111010110011111111011110000111101101011100110110001011000000101010110101011100\r\n', 'output': ['1000000000000000000000000000000000000000']}, {'input': '2\r\n10\r\n', 'output': ['10']}, {'input': '50\r\n10010010000000000000000000000000000000001000000000\r\n', 'output': ['10000000000000000000000000000000000000000000000']}]
[{'input': '100\r\n1110111100001111011111111010110011111111011110000111101101011100110110001011000000101010110101011100\r\n', 'output': ['1000000000000000000000000000000000000000']}, {'input': '100\r\n1111111111111111111111111111111111111111111111111111111110111111111111111111111111111111111111111111\r\n', 'output': ['10']}, {'input': '4\r\n1001\r\n', 'output': ['100']}, {'input': '2\r\n11\r\n', 'output': ['1']}, {'input': '100\r\n1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r\n', 'output': ['1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000']}]
[{'input': '8\r\n10101010\r\n', 'output': ['10000']}, {'input': '4\r\n1001\r\n', 'output': ['100']}, {'input': '100\r\n1110111100001111011111111010110011111111011110000111101101011100110110001011000000101010110101011100\r\n', 'output': ['1000000000000000000000000000000000000000']}, {'input': '1\r\n1\r\n', 'output': ['1']}, {'input': '50\r\n10010010000000000000000000000000000000001000000000\r\n', 'output': ['10000000000000000000000000000000000000000000000']}]
100
100
100
100
100
100
100
100
100
100
87.5
100
87.5
87.5
87.5
147
100
100
90
["4 1 2"]
The first line of input contains three integers n (2 ≤ n ≤ 108), c0 and c1 (0 ≤ c0, c1 ≤ 108) — the number of letters in the alphabet, and costs of '0' and '1', respectively.
39b824b740a40f68bae39b8d9f0adcbe
#include<bits/stdc++.h> #define ll long long using namespace std; ll ans; int n,a,b,s; int c[20005]; bool check(ll m){ int sum=m/a; for (int i=0;i<=s;i++) c[i]=i+1; for (int i=1;1ll*i*b<=m&&sum<n;i++) for (int j=0;1ll*i*b+1ll*j*a<=m&&sum<n;j++) sum+=c[j],c[j]+=(j?c[j-1]:0); return sum>=n; } void calc(ll m){ int sum=m/a; ans+=1ll*sum*(sum+1)/2*a; for (int i=0;i<=s;i++) c[i]=i+1; for (int i=1;1ll*i*b<=m;i++) for (int j=0;1ll*i*b+1ll*j*a<=m;j++){ ans+=1ll*c[j]*(1ll*i*b+1ll*j*a); sum+=c[j],c[j]+=(j?c[j-1]:0); } ans-=m*(sum-n); } int main(){ scanf("%d%d%d",&n,&a,&b); if (a>b) swap(a,b); n--; ans=1ll*n*(a+b); n--; s=sqrt(n*2)+1; if (!a){ printf("%lld\n",ans); return 0; } ll l=0,r=1ll*n*a; while (l<r){ ll mid=(l+r)/2; if (check(mid)) r=mid; else l=mid+1; } calc(l); printf("%lld\n",ans); }
["12"]
C++
NoteThere are 4 letters in the alphabet. The optimal encoding is "00", "01", "10", "11". There are 4 zeroes and 4 ones used, so the total cost is 4·1 + 4·2 = 12.
Output a single integer — minimum possible total a cost of the whole alphabet.
R3D3 spent some time on an internship in MDCS. After earning enough money, he decided to go on a holiday somewhere far, far away. He enjoyed suntanning, drinking alcohol-free cocktails and going to concerts of popular local bands. While listening to "The White Buttons" and their hit song "Dacan the Baker", he met another robot for whom he was sure is the love of his life. Well, his summer, at least. Anyway, R3D3 was too shy to approach his potential soulmate, so he decided to write her a love letter. However, he stumbled upon a problem. Due to a terrorist threat, the Intergalactic Space Police was monitoring all letters sent in the area. Thus, R3D3 decided to invent his own alphabet, for which he was sure his love would be able to decipher.There are n letters in R3D3’s alphabet, and he wants to represent each letter as a sequence of '0' and '1', so that no letter’s sequence is a prefix of another letter's sequence. Since the Intergalactic Space Communications Service has lately introduced a tax for invented alphabets, R3D3 must pay a certain amount of money for each bit in his alphabet’s code (check the sample test for clarifications). He is too lovestruck to think clearly, so he asked you for help.Given the costs c0 and c1 for each '0' and '1' in R3D3’s alphabet, respectively, you should come up with a coding for the alphabet (with properties as above) with minimum total cost.
[{"input": "4 1 2\r\n", "output": ["12"]}, {"input": "2 1 5\r\n", "output": ["6"]}, {"input": "3 1 1\r\n", "output": ["5"]}, {"input": "5 5 5\r\n", "output": ["60"]}, {"input": "4 0 0\r\n", "output": ["0"]}, {"input": "6 0 6\r\n", "output": ["30"]}, {"input": "6 6 0\r\n", "output": ["30"]}, {"input": "2 1 2\r\n", "output": ["3"]}, {"input": "100000000 1 0\r\n", "output": ["99999999"]}, {"input": "2 0 0\r\n", "output": ["0"]}, {"input": "2 100000000 100000000\r\n", "output": ["200000000"]}, {"input": "2 100000000 0\r\n", "output": ["100000000"]}, {"input": "2 0 100000000\r\n", "output": ["100000000"]}, {"input": "100000000 0 0\r\n", "output": ["0"]}, {"input": "100000000 100000000 100000000\r\n", "output": ["266578227200000000"]}, {"input": "100000000 100000000 0\r\n", "output": ["9999999900000000"]}, {"input": "100000000 0 100000000\r\n", "output": ["9999999900000000"]}, {"input": "2 50000000 0\r\n", "output": ["50000000"]}, {"input": "2 50000000 100000000\r\n", "output": ["150000000"]}, {"input": "2 50000000 0\r\n", "output": ["50000000"]}, {"input": "2 50000000 100000000\r\n", "output": ["150000000"]}, {"input": "100000000 50000000 0\r\n", "output": ["4999999950000000"]}, {"input": "100000000 50000000 100000000\r\n", "output": ["191720992950000000"]}, {"input": "100000000 50000000 0\r\n", "output": ["4999999950000000"]}, {"input": "100000000 50000000 100000000\r\n", "output": ["191720992950000000"]}, {"input": "96212915 66569231 66289469\r\n", "output": ["170023209909758400"]}, {"input": "39969092 91869601 91924349\r\n", "output": ["93003696194821620"]}, {"input": "26854436 29462638 67336233\r\n", "output": ["30373819153055635"]}, {"input": "39201451 80233602 30662934\r\n", "output": ["50953283386656312"]}, {"input": "92820995 96034432 40568102\r\n", "output": ["158135215198065044"]}, {"input": "81913246 61174868 31286889\r\n", "output": ["96084588586645841"]}, {"input": "74790405 66932852 48171076\r\n", "output": ["111690840882243696"]}, {"input": "88265295 26984472 18821097\r\n", "output": ["52835608063500861"]}, {"input": "39858798 77741429 44017779\r\n", "output": ["59709461677488470"]}, {"input": "70931513 41663344 29095671\r\n", "output": ["64816798089350400"]}, {"input": "68251617 52232534 34187120\r\n", "output": ["75694251898945158"]}, {"input": "44440915 82093126 57268128\r\n", "output": ["77907273273831800"]}, {"input": "61988457 90532323 72913492\r\n", "output": ["130757350538583270"]}, {"input": "13756397 41019327 86510346\r\n", "output": ["19895886795999000"]}, {"input": "84963589 37799442 20818727\r\n", "output": ["63754887412974663"]}, {"input": "99338896 62289589 49020203\r\n", "output": ["146320678028775569"]}, {"input": "1505663 3257962 1039115\r\n", "output": ["60023256524142"]}, {"input": "80587587 25402325 8120971\r\n", "output": ["32044560697691212"]}, {"input": "64302230 83635846 22670768\r\n", "output": ["77790985833197594"]}, {"input": "6508457 32226669 8706339\r\n", "output": ["2645634460061466"]}, {"input": "1389928 84918086 54850899\r\n", "output": ["1953921305304795"]}, {"input": "37142108 10188690 35774598\r\n", "output": ["19009588918065432"]}, {"input": "86813943 11824369 38451380\r\n", "output": ["51645349299460766"]}, {"input": "14913475 61391038 9257618\r\n", "output": ["9761450207212562"]}, {"input": "25721978 63666459 14214946\r\n", "output": ["20847031763747988"]}, {"input": "73363656 63565575 76409698\r\n", "output": ["133919836504944416"]}, {"input": "34291060 92893503 64680754\r\n", "output": ["66960630525688676"]}, {"input": "85779772 26434899 86820336\r\n", "output": ["114681463889615136"]}, {"input": "7347370 2098650 66077918\r\n", "output": ["3070602135161752"]}, {"input": "28258585 6194848 49146833\r\n", "output": ["14441957862691571"]}, {"input": "9678 133 5955\r\n", "output": ["196970292"]}, {"input": "9251 4756 2763\r\n", "output": ["448302621"]}, {"input": "1736 5628 2595\r\n", "output": ["73441521"]}, {"input": "5195 1354 2885\r\n", "output": ["130236572"]}, {"input": "1312 5090 9909\r\n", "output": ["98808420"]}, {"input": "8619 6736 9365\r\n", "output": ["900966230"]}, {"input": "151 7023 3093\r\n", "output": ["5267919"]}, {"input": "5992 2773 6869\r\n", "output": ["340564941"]}, {"input": "3894 9921 3871\r\n", "output": ["299508763"]}, {"input": "1006 9237 1123\r\n", "output": ["38974261"]}, {"input": "9708 3254 2830\r\n", "output": ["391502526"]}, {"input": "1504 1123 626\r\n", "output": ["13538132"]}, {"input": "8642 5709 51\r\n", "output": ["135655830"]}, {"input": "8954 4025 7157\r\n", "output": ["641304164"]}, {"input": "4730 8020 8722\r\n", "output": ["484587068"]}, {"input": "2500 5736 4002\r\n", "output": ["136264140"]}, {"input": "6699 4249 1068\r\n", "output": ["196812772"]}, {"input": "4755 6759 4899\r\n", "output": ["336456318"]}, {"input": "8447 1494 4432\r\n", "output": ["298387478"]}, {"input": "6995 4636 8251\r\n", "output": ["561476311"]}, {"input": "4295 9730 4322\r\n", "output": ["346320888"]}, {"input": "8584 4286 9528\r\n", "output": ["738058224"]}, {"input": "174 6826 355\r\n", "output": ["2889605"]}, {"input": "5656 7968 3400\r\n", "output": ["379249528"]}, {"input": "2793 175 3594\r\n", "output": ["36405762"]}, {"input": "2888 9056 3931\r\n", "output": ["204521173"]}, {"input": "6222 7124 6784\r\n", "output": ["547839384"]}, {"input": "8415 8714 2475\r\n", "output": ["545452719"]}, {"input": "2179 7307 8608\r\n", "output": ["192281235"]}, {"input": "1189 1829 6875\r\n", "output": ["46521099"]}]
100
100
100
[{'input': '2 50000000 0\r\n', 'output': ['50000000']}, {'input': '2 1 5\r\n', 'output': ['6']}, {'input': '1389928 84918086 54850899\r\n', 'output': ['1953921305304795']}, {'input': '28258585 6194848 49146833\r\n', 'output': ['14441957862691571']}, {'input': '9678 133 5955\r\n', 'output': ['196970292']}]
[{'input': '70931513 41663344 29095671\r\n', 'output': ['64816798089350400']}, {'input': '100000000 50000000 0\r\n', 'output': ['4999999950000000']}, {'input': '100000000 0 100000000\r\n', 'output': ['9999999900000000']}, {'input': '9678 133 5955\r\n', 'output': ['196970292']}, {'input': '6 0 6\r\n', 'output': ['30']}]
[{'input': '8619 6736 9365\r\n', 'output': ['900966230']}, {'input': '100000000 1 0\r\n', 'output': ['99999999']}, {'input': '4 1 2\r\n', 'output': ['12']}, {'input': '100000000 50000000 100000000\r\n', 'output': ['191720992950000000']}, {'input': '4755 6759 4899\r\n', 'output': ['336456318']}]
[{'input': '25721978 63666459 14214946\r\n', 'output': ['20847031763747988']}, {'input': '64302230 83635846 22670768\r\n', 'output': ['77790985833197594']}, {'input': '34291060 92893503 64680754\r\n', 'output': ['66960630525688676']}, {'input': '92820995 96034432 40568102\r\n', 'output': ['158135215198065044']}, {'input': '1389928 84918086 54850899\r\n', 'output': ['1953921305304795']}]
[{'input': '8642 5709 51\r\n', 'output': ['135655830']}, {'input': '64302230 83635846 22670768\r\n', 'output': ['77790985833197594']}, {'input': '2793 175 3594\r\n', 'output': ['36405762']}, {'input': '4730 8020 8722\r\n', 'output': ['484587068']}, {'input': '61988457 90532323 72913492\r\n', 'output': ['130757350538583270']}]
100
100
100
100
100
100
100
100
93.94
93.94
100
100
100
92.86
96.43
148
100
97.576
97.858
["2", "4", "8", "20"]
The input contains one integer $$$n$$$ ($$$2 \le n \le 20$$$), $$$n$$$ is an even number.
ad0985c56a207f76afa2ecd642f56728
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> using namespace std; typedef long long ll; const ll Maxn=20+5; ll n,mul[Maxn]; int main() { scanf("%lld",&n); mul[0]=1; for(ll i=1;i<=n;i++)mul[i]=1ll*mul[i-1]*i; printf("%lld\n",mul[n]/mul[n/2]/mul[n/2]/2*mul[n/2-1]*mul[n/2-1]); return 0; }
["1", "3", "1260", "12164510040883200"]
C++
null
Print one integer — the number of ways to make two round dances. It is guaranteed that the answer fits in the $$$64$$$-bit integer data type.
One day, $$$n$$$ people ($$$n$$$ is an even number) met on a plaza and made two round dances, each round dance consists of exactly $$$\frac{n}{2}$$$ people. Your task is to find the number of ways $$$n$$$ people can make two round dances if each round dance consists of exactly $$$\frac{n}{2}$$$ people. Each person should belong to exactly one of these two round dances.Round dance is a dance circle consisting of $$$1$$$ or more people. Two round dances are indistinguishable (equal) if one can be transformed to another by choosing the first participant. For example, round dances $$$[1, 3, 4, 2]$$$, $$$[4, 2, 1, 3]$$$ and $$$[2, 1, 3, 4]$$$ are indistinguishable.For example, if $$$n=2$$$ then the number of ways is $$$1$$$: one round dance consists of the first person and the second one of the second person.For example, if $$$n=4$$$ then the number of ways is $$$3$$$. Possible options: one round dance — $$$[1,2]$$$, another — $$$[3,4]$$$; one round dance — $$$[2,4]$$$, another — $$$[3,1]$$$; one round dance — $$$[4,1]$$$, another — $$$[3,2]$$$. Your task is to find the number of ways $$$n$$$ people can make two round dances if each round dance consists of exactly $$$\frac{n}{2}$$$ people.
[{"input": "2\r\n", "output": ["1"]}, {"input": "4\r\n", "output": ["3"]}, {"input": "8\r\n", "output": ["1260"]}, {"input": "20\r\n", "output": ["12164510040883200"]}, {"input": "6\r\n", "output": ["40"]}, {"input": "10\r\n", "output": ["72576"]}, {"input": "12\r\n", "output": ["6652800"]}, {"input": "14\r\n", "output": ["889574400"]}, {"input": "18\r\n", "output": ["39520825344000"]}, {"input": "16\r\n", "output": ["163459296000"]}]
100
100
100
[{'input': '6\r\n', 'output': ['40']}, {'input': '18\r\n', 'output': ['39520825344000']}, {'input': '16\r\n', 'output': ['163459296000']}, {'input': '10\r\n', 'output': ['72576']}, {'input': '12\r\n', 'output': ['6652800']}]
[{'input': '10\r\n', 'output': ['72576']}, {'input': '2\r\n', 'output': ['1']}, {'input': '16\r\n', 'output': ['163459296000']}, {'input': '6\r\n', 'output': ['40']}, {'input': '20\r\n', 'output': ['12164510040883200']}]
[{'input': '12\r\n', 'output': ['6652800']}, {'input': '6\r\n', 'output': ['40']}, {'input': '10\r\n', 'output': ['72576']}, {'input': '8\r\n', 'output': ['1260']}, {'input': '14\r\n', 'output': ['889574400']}]
[{'input': '20\r\n', 'output': ['12164510040883200']}, {'input': '10\r\n', 'output': ['72576']}, {'input': '2\r\n', 'output': ['1']}, {'input': '18\r\n', 'output': ['39520825344000']}, {'input': '8\r\n', 'output': ['1260']}]
[{'input': '20\r\n', 'output': ['12164510040883200']}, {'input': '4\r\n', 'output': ['3']}, {'input': '2\r\n', 'output': ['1']}, {'input': '14\r\n', 'output': ['889574400']}, {'input': '6\r\n', 'output': ['40']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
149
100
100
100
["4\n1 3 3 2", "3\n1 1 1", "4\n42 0 0 42"]
The first line contains a single integer n (1 ≤ n ≤ 100) — the number of participants. The next line contains a sequence of n integers a1, a2, ..., an (0 ≤ ai ≤ 600) — participants' scores. It's guaranteed that at least one participant has non-zero score.
3b520c15ea9a11b16129da30dcfb5161
#include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cstring> /* A. Olympiad */ using namespace std; typedef long long ll; int n, a[105], res, vis[605]; int main(int argc, char * argv[]) { scanf("%d", &n); for (int i = 0; i < n; i ++) scanf("%d", &a[i]); sort(a, a + n); res = 0; memset(vis, 0, sizeof(vis)); for (int i = 0; i < n; i ++) { if (a[i] != 0 && !vis[a[i]]) { res ++; vis[a[i]] = 1; } } cout << res << endl; return 0; }
["3", "1", "1"]
C++
NoteThere are three ways to choose a subset in sample case one. Only participants with 3 points will get diplomas. Participants with 2 or 3 points will get diplomas. Everyone will get a diploma! The only option in sample case two is to award everyone.Note that in sample case three participants with zero scores cannot get anything.
Print a single integer — the desired number of ways.
The recent All-Berland Olympiad in Informatics featured n participants with each scoring a certain amount of points.As the head of the programming committee, you are to determine the set of participants to be awarded with diplomas with respect to the following criteria: At least one participant should get a diploma. None of those with score equal to zero should get awarded. When someone is awarded, all participants with score not less than his score should also be awarded. Determine the number of ways to choose a subset of participants that will receive the diplomas.
[{"input": "4\r\n1 3 3 2\r\n", "output": ["3"]}, {"input": "3\r\n1 1 1\r\n", "output": ["1"]}, {"input": "4\r\n42 0 0 42\r\n", "output": ["1"]}, {"input": "10\r\n1 0 1 0 1 0 0 0 0 1\r\n", "output": ["1"]}, {"input": "10\r\n572 471 540 163 50 30 561 510 43 200\r\n", "output": ["10"]}, {"input": "100\r\n122 575 426 445 172 81 247 429 97 202 175 325 382 384 417 356 132 502 328 537 57 339 518 211 479 306 140 168 268 16 140 263 593 249 391 310 555 468 231 180 157 18 334 328 276 155 21 280 322 545 111 267 467 274 291 304 235 34 365 180 21 95 501 552 325 331 302 353 296 22 289 399 7 466 32 302 568 333 75 192 284 10 94 128 154 512 9 480 243 521 551 492 420 197 207 125 367 117 438 600\r\n", "output": ["94"]}, {"input": "100\r\n600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600\r\n", "output": ["1"]}, {"input": "78\r\n5 4 13 2 5 6 2 10 10 1 2 6 7 9 6 3 5 7 1 10 2 2 7 0 2 11 11 3 1 13 3 10 6 2 0 3 0 5 0 1 4 11 1 1 7 0 12 7 5 12 0 2 12 9 8 3 4 3 4 11 4 10 2 3 10 12 5 6 1 11 2 0 8 7 9 1 3 12\r\n", "output": ["13"]}, {"input": "34\r\n220 387 408 343 184 447 197 307 337 414 251 319 426 322 347 242 208 412 188 185 241 235 216 259 331 372 322 284 444 384 214 297 389 391\r\n", "output": ["33"]}, {"input": "100\r\n1 2 1 0 3 0 2 0 0 1 2 0 1 3 0 3 3 1 3 0 0 2 1 2 2 1 3 3 3 3 3 2 0 0 2 1 2 3 2 3 0 1 1 3 3 2 0 3 1 0 2 2 2 1 2 3 2 1 0 3 0 2 0 3 0 2 1 0 3 1 0 2 2 1 3 1 3 0 2 3 3 1 1 3 1 3 0 3 2 0 2 3 3 0 2 0 2 0 1 3\r\n", "output": ["3"]}, {"input": "100\r\n572 471 540 163 50 30 561 510 43 200 213 387 500 424 113 487 357 333 294 337 435 202 447 494 485 465 161 344 470 559 104 356 393 207 224 213 511 514 60 386 149 216 392 229 429 173 165 401 395 150 127 579 344 390 529 296 225 425 318 79 465 447 177 110 367 212 459 270 41 500 277 567 125 436 178 9 214 342 203 112 144 24 79 155 495 556 40 549 463 281 241 316 2 246 1 396 510 293 332 55\r\n", "output": ["93"]}, {"input": "99\r\n5 4 13 2 5 6 2 10 10 1 2 6 7 9 6 3 5 7 1 10 2 2 7 0 2 11 11 3 1 13 3 10 6 2 0 3 0 5 0 1 4 11 1 1 7 0 12 7 5 12 0 2 12 9 8 3 4 3 4 11 4 10 2 3 10 12 5 6 1 11 2 0 8 7 9 1 3 12 2 3 9 3 7 13 7 13 0 11 8 12 2 5 9 4 0 6 6 2 13\r\n", "output": ["13"]}, {"input": "99\r\n1 0 1 0 1 0 0 0 0 1 0 0 1 1 0 1 1 1 1 0 0 0 1 0 0 1 1 1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 0 0 0 1 0 1 0 1 0 1 0 0 0 1 0 0 1 0 1 1 0 0 0 1 1 1 1 0 0 1 1 1 1 1 1 1 0 1 0 0 0 1 1 0 0 0 0 0 1\r\n", "output": ["1"]}, {"input": "99\r\n21 74 25 44 71 80 46 28 96 1 74 24 81 83 16 55 31 1 27 36 56 38 17 10 78 5 39 67 67 15 39 62 92 48 90 9 54 67 30 79 56 17 33 27 75 54 20 79 21 44 10 66 66 73 90 3 34 33 64 79 20 94 0 51 24 30 1 52 95 21 88 98 6 65 31 1 67 32 74 91 83 9 93 27 53 11 8 79 42 20 50 91 19 96 6 24 66 16 37\r\n", "output": ["61"]}, {"input": "2\r\n0 1\r\n", "output": ["1"]}, {"input": "2\r\n0 600\r\n", "output": ["1"]}, {"input": "4\r\n1 1 1 2\r\n", "output": ["2"]}, {"input": "4\r\n0 0 1 2\r\n", "output": ["2"]}, {"input": "1\r\n5\r\n", "output": ["1"]}, {"input": "2\r\n0 5\r\n", "output": ["1"]}, {"input": "5\r\n1 0 0 1 2\r\n", "output": ["2"]}]
100
100
100
[{'input': '2\r\n0 5\r\n', 'output': ['1']}, {'input': '100\r\n1 2 1 0 3 0 2 0 0 1 2 0 1 3 0 3 3 1 3 0 0 2 1 2 2 1 3 3 3 3 3 2 0 0 2 1 2 3 2 3 0 1 1 3 3 2 0 3 1 0 2 2 2 1 2 3 2 1 0 3 0 2 0 3 0 2 1 0 3 1 0 2 2 1 3 1 3 0 2 3 3 1 1 3 1 3 0 3 2 0 2 3 3 0 2 0 2 0 1 3\r\n', 'output': ['3']}, {'input': '99\r\n1 0 1 0 1 0 0 0 0 1 0 0 1 1 0 1 1 1 1 0 0 0 1 0 0 1 1 1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 0 0 0 1 0 1 0 1 0 1 0 0 0 1 0 0 1 0 1 1 0 0 0 1 1 1 1 0 0 1 1 1 1 1 1 1 0 1 0 0 0 1 1 0 0 0 0 0 1\r\n', 'output': ['1']}, {'input': '100\r\n600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600\r\n', 'output': ['1']}, {'input': '78\r\n5 4 13 2 5 6 2 10 10 1 2 6 7 9 6 3 5 7 1 10 2 2 7 0 2 11 11 3 1 13 3 10 6 2 0 3 0 5 0 1 4 11 1 1 7 0 12 7 5 12 0 2 12 9 8 3 4 3 4 11 4 10 2 3 10 12 5 6 1 11 2 0 8 7 9 1 3 12\r\n', 'output': ['13']}]
[{'input': '100\r\n122 575 426 445 172 81 247 429 97 202 175 325 382 384 417 356 132 502 328 537 57 339 518 211 479 306 140 168 268 16 140 263 593 249 391 310 555 468 231 180 157 18 334 328 276 155 21 280 322 545 111 267 467 274 291 304 235 34 365 180 21 95 501 552 325 331 302 353 296 22 289 399 7 466 32 302 568 333 75 192 284 10 94 128 154 512 9 480 243 521 551 492 420 197 207 125 367 117 438 600\r\n', 'output': ['94']}, {'input': '2\r\n0 5\r\n', 'output': ['1']}, {'input': '10\r\n1 0 1 0 1 0 0 0 0 1\r\n', 'output': ['1']}, {'input': '100\r\n600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600\r\n', 'output': ['1']}, {'input': '4\r\n0 0 1 2\r\n', 'output': ['2']}]
[{'input': '99\r\n21 74 25 44 71 80 46 28 96 1 74 24 81 83 16 55 31 1 27 36 56 38 17 10 78 5 39 67 67 15 39 62 92 48 90 9 54 67 30 79 56 17 33 27 75 54 20 79 21 44 10 66 66 73 90 3 34 33 64 79 20 94 0 51 24 30 1 52 95 21 88 98 6 65 31 1 67 32 74 91 83 9 93 27 53 11 8 79 42 20 50 91 19 96 6 24 66 16 37\r\n', 'output': ['61']}, {'input': '5\r\n1 0 0 1 2\r\n', 'output': ['2']}, {'input': '1\r\n5\r\n', 'output': ['1']}, {'input': '2\r\n0 5\r\n', 'output': ['1']}, {'input': '78\r\n5 4 13 2 5 6 2 10 10 1 2 6 7 9 6 3 5 7 1 10 2 2 7 0 2 11 11 3 1 13 3 10 6 2 0 3 0 5 0 1 4 11 1 1 7 0 12 7 5 12 0 2 12 9 8 3 4 3 4 11 4 10 2 3 10 12 5 6 1 11 2 0 8 7 9 1 3 12\r\n', 'output': ['13']}]
[{'input': '10\r\n1 0 1 0 1 0 0 0 0 1\r\n', 'output': ['1']}, {'input': '2\r\n0 5\r\n', 'output': ['1']}, {'input': '2\r\n0 1\r\n', 'output': ['1']}, {'input': '5\r\n1 0 0 1 2\r\n', 'output': ['2']}, {'input': '100\r\n572 471 540 163 50 30 561 510 43 200 213 387 500 424 113 487 357 333 294 337 435 202 447 494 485 465 161 344 470 559 104 356 393 207 224 213 511 514 60 386 149 216 392 229 429 173 165 401 395 150 127 579 344 390 529 296 225 425 318 79 465 447 177 110 367 212 459 270 41 500 277 567 125 436 178 9 214 342 203 112 144 24 79 155 495 556 40 549 463 281 241 316 2 246 1 396 510 293 332 55\r\n', 'output': ['93']}]
[{'input': '78\r\n5 4 13 2 5 6 2 10 10 1 2 6 7 9 6 3 5 7 1 10 2 2 7 0 2 11 11 3 1 13 3 10 6 2 0 3 0 5 0 1 4 11 1 1 7 0 12 7 5 12 0 2 12 9 8 3 4 3 4 11 4 10 2 3 10 12 5 6 1 11 2 0 8 7 9 1 3 12\r\n', 'output': ['13']}, {'input': '2\r\n0 600\r\n', 'output': ['1']}, {'input': '100\r\n572 471 540 163 50 30 561 510 43 200 213 387 500 424 113 487 357 333 294 337 435 202 447 494 485 465 161 344 470 559 104 356 393 207 224 213 511 514 60 386 149 216 392 229 429 173 165 401 395 150 127 579 344 390 529 296 225 425 318 79 465 447 177 110 367 212 459 270 41 500 277 567 125 436 178 9 214 342 203 112 144 24 79 155 495 556 40 549 463 281 241 316 2 246 1 396 510 293 332 55\r\n', 'output': ['93']}, {'input': '100\r\n600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600\r\n', 'output': ['1']}, {'input': '34\r\n220 387 408 343 184 447 197 307 337 414 251 319 426 322 347 242 208 412 188 185 241 235 216 259 331 372 322 284 444 384 214 297 389 391\r\n', 'output': ['33']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
150
100
100
100
["4", "7", "12"]
The only line contains integer n from the problem's statement (1 ≤ n ≤ 109).
2468eead8acc5b8f5ddc51bfa2bd4fb7
#include<stdio.h> #include<vector> #include<algorithm> #include<queue> #include <string> #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll>pii; //typedef bitset<8> mask; //int x4[4]={1,0,0,-1}; //int y4[4]={0,1,-1,0}; ll n,x,y,z,ans1=1e18+20,ans2=-100000000; int main() { //cout<<Pow((ll)1000000,(ll)110); //freopen("hotel.in","r",stdin); //freopen("math.in","w",stdout); //printf("%s %.4f\n",k.c_str(),g); cin>>n; for(int i=1;i<=1000;i++) { for(int j=i;j*i<=1000000;j++) { if(n%(i*j)==0&&n/(i*j)>=j) { x=i;y=j;z=n/(x*y); ans1=min(ans1,(z+2)*(y+2)*(x+1)-n); ans2=max(ans2,(z+1)*(y+2)*(x+2)-n); } } } //cout<<x<<" "<<y<<" "<<z<<endl; cout<<ans1<<" "<<ans2; return 0; }
["28 41", "47 65", "48 105"]
C++
NoteLet's consider the first sample test. If initially Sam has a parallelepiped consisting of 32 = 2 × 4 × 4 hay blocks in his barn, then after the theft the barn has 4 = (2 - 1) × (4 - 2) × (4 - 2) hay blocks left. Thus, the thieves could have stolen 32 - 4 = 28 hay blocks. If Sam initially had a parallelepiped consisting of 45 = 5 × 3 × 3 hay blocks in his barn, then after the theft the barn has 4 = (5 - 1) × (3 - 2) × (3 - 2) hay blocks left. Thus, the thieves could have stolen 45 - 4 = 41 hay blocks. No other variants of the blocks' initial arrangement (that leave Sam with exactly 4 blocks after the theft) can permit the thieves to steal less than 28 or more than 41 blocks.
Print space-separated minimum and maximum number of hay blocks that could have been stolen by the thieves. Note that the answer to the problem can be large enough, so you must use the 64-bit integer type for calculations. Please, do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specificator.
Once upon a time in the Kingdom of Far Far Away lived Sam the Farmer. Sam had a cow named Dawn and he was deeply attached to her. Sam would spend the whole summer stocking hay to feed Dawn in winter. Sam scythed hay and put it into haystack. As Sam was a bright farmer, he tried to make the process of storing hay simpler and more convenient to use. He collected the hay into cubical hay blocks of the same size. Then he stored the blocks in his barn. After a summer spent in hard toil Sam stored A·B·C hay blocks and stored them in a barn as a rectangular parallelepiped A layers high. Each layer had B rows and each row had C blocks.At the end of the autumn Sam came into the barn to admire one more time the hay he'd been stacking during this hard summer. Unfortunately, Sam was horrified to see that the hay blocks had been carelessly scattered around the barn. The place was a complete mess. As it turned out, thieves had sneaked into the barn. They completely dissembled and took away a layer of blocks from the parallelepiped's front, back, top and sides. As a result, the barn only had a parallelepiped containing (A - 1) × (B - 2) × (C - 2) hay blocks. To hide the evidence of the crime, the thieves had dissembled the parallelepiped into single 1 × 1 × 1 blocks and scattered them around the barn. After the theft Sam counted n hay blocks in the barn but he forgot numbers A, B и C.Given number n, find the minimally possible and maximally possible number of stolen hay blocks.
[{"input": "4\r\n", "output": ["28 41"]}, {"input": "7\r\n", "output": ["47 65"]}, {"input": "12\r\n", "output": ["48 105"]}, {"input": "1\r\n", "output": ["17 17"]}, {"input": "6\r\n", "output": ["34 57"]}, {"input": "8\r\n", "output": ["40 73"]}, {"input": "9\r\n", "output": ["41 81"]}, {"input": "14\r\n", "output": ["58 121"]}, {"input": "15\r\n", "output": ["55 129"]}, {"input": "16\r\n", "output": ["56 137"]}, {"input": "18\r\n", "output": ["57 153"]}, {"input": "20\r\n", "output": ["64 169"]}, {"input": "299999771\r\n", "output": ["1499998867 2399998177"]}, {"input": "54\r\n", "output": ["106 441"]}, {"input": "96\r\n", "output": ["144 777"]}, {"input": "348\r\n", "output": ["396 2793"]}, {"input": "748\r\n", "output": ["487 5993"]}, {"input": "908\r\n", "output": ["1840 7273"]}, {"input": "1026\r\n", "output": ["591 8217"]}, {"input": "1985\r\n", "output": ["3601 15889"]}, {"input": "4472\r\n", "output": ["1603 35785"]}, {"input": "20845\r\n", "output": ["8873 166769"]}, {"input": "50480\r\n", "output": ["17884 403849"]}, {"input": "62497\r\n", "output": ["312497 499985"]}, {"input": "646055\r\n", "output": ["140995 5168449"]}, {"input": "790620\r\n", "output": ["316416 6324969"]}, {"input": "989903\r\n", "output": ["1082167 7919233"]}, {"input": "7033800\r\n", "output": ["210976 56270409"]}, {"input": "7661860\r\n", "output": ["546725 61294889"]}, {"input": "7834243\r\n", "output": ["8302235 62673953"]}, {"input": "45134118\r\n", "output": ["19223945 361072953"]}, {"input": "89054701\r\n", "output": ["445273517 712437617"]}, {"input": "99264891\r\n", "output": ["15587889 794119137"]}, {"input": "127039320\r\n", "output": ["1209066 1016314569"]}, {"input": "206898748\r\n", "output": ["1683461 1655189993"]}, {"input": "231136953\r\n", "output": ["539319577 1849095633"]}, {"input": "257259713\r\n", "output": ["2122207 2058077713"]}, {"input": "286736327\r\n", "output": ["290355727 2293890625"]}, {"input": "311933803\r\n", "output": ["1559669027 2495470433"]}, {"input": "332393619\r\n", "output": ["10714371 2659148961"]}, {"input": "422114561\r\n", "output": ["78417139 3376916497"]}, {"input": "453012754\r\n", "output": ["2844347 3624102041"]}, {"input": "470860680\r\n", "output": ["129486993 3766885449"]}, {"input": "509607936\r\n", "output": ["3045276 4076863497"]}, {"input": "534879507\r\n", "output": ["253364145 4279036065"]}, {"input": "535074941\r\n", "output": ["647722381 4280599537"]}, {"input": "536870912\r\n", "output": ["3151876 4294967305"]}, {"input": "573308928\r\n", "output": ["3301020 4586471433"]}, {"input": "603979776\r\n", "output": ["3414276 4831838217"]}, {"input": "605404800\r\n", "output": ["3414952 4843238409"]}, {"input": "615716902\r\n", "output": ["10508698 4925735225"]}, {"input": "628464178\r\n", "output": ["3574502 5027713433"]}, {"input": "631243141\r\n", "output": ["634644469 5049945137"]}, {"input": "644972544\r\n", "output": ["3573148 5159780361"]}, {"input": "659274082\r\n", "output": ["1977822262 5274192665"]}, {"input": "679477248\r\n", "output": ["3693060 5435817993"]}, {"input": "735134400\r\n", "output": ["3886608 5881075209"]}, {"input": "764411904\r\n", "output": ["3988228 6115295241"]}, {"input": "778377600\r\n", "output": ["4036708 6227020809"]}, {"input": "791683200\r\n", "output": ["4082888 6333465609"]}, {"input": "805306368\r\n", "output": ["4201476 6442450953"]}, {"input": "821620800\r\n", "output": ["4185636 6572966409"]}, {"input": "856079286\r\n", "output": ["196667409 6848634297"]}, {"input": "857656800\r\n", "output": ["4307008 6861254409"]}, {"input": "859963392\r\n", "output": ["4320292 6879707145"]}, {"input": "864864000\r\n", "output": ["4331048 6918912009"]}, {"input": "882161280\r\n", "output": ["4388720 7057290249"]}, {"input": "884822400\r\n", "output": ["4396766 7078579209"]}, {"input": "905969664\r\n", "output": ["4529412 7247757321"]}, {"input": "908107200\r\n", "output": ["4474050 7264857609"]}, {"input": "918918000\r\n", "output": ["4511288 7351344009"]}, {"input": "931170240\r\n", "output": ["4548514 7449361929"]}, {"input": "935625600\r\n", "output": ["4563150 7485004809"]}, {"input": "936354996\r\n", "output": ["40069269 7490839977"]}, {"input": "951350400\r\n", "output": ["4614600 7610803209"]}, {"input": "958557600\r\n", "output": ["4637398 7668460809"]}, {"input": "972972000\r\n", "output": ["4685478 7783776009"]}, {"input": "980179200\r\n", "output": ["4707050 7841433609"]}, {"input": "985944960\r\n", "output": ["4725040 7887559689"]}, {"input": "994593600\r\n", "output": ["4752650 7956748809"]}, {"input": "999893227\r\n", "output": ["1000183267 7999145825"]}, {"input": "999893387\r\n", "output": ["1000724227 7999147105"]}, {"input": "999905161\r\n", "output": ["1000161721 7999241297"]}, {"input": "999942949\r\n", "output": ["1000368197 7999543601"]}, {"input": "999996583\r\n", "output": ["1022096687 7999972673"]}, {"input": "999999797\r\n", "output": ["4999998997 7999998385"]}, {"input": "999999883\r\n", "output": ["4999999427 7999999073"]}, {"input": "999999893\r\n", "output": ["4999999477 7999999153"]}, {"input": "999999929\r\n", "output": ["4999999657 7999999441"]}, {"input": "999999937\r\n", "output": ["4999999697 7999999505"]}, {"input": "999999991\r\n", "output": ["1059701759 7999999937"]}, {"input": "999999992\r\n", "output": ["129518035 7999999945"]}, {"input": "999999993\r\n", "output": ["490196227 7999999953"]}, {"input": "999999994\r\n", "output": ["928571477 7999999961"]}, {"input": "999999995\r\n", "output": ["4924975 7999999969"]}, {"input": "999999996\r\n", "output": ["1000000044 7999999977"]}, {"input": "999999997\r\n", "output": ["15309947 7999999985"]}, {"input": "999999998\r\n", "output": ["504345691 7999999993"]}, {"input": "999999999\r\n", "output": ["52392027 8000000001"]}, {"input": "1000000000\r\n", "output": ["4770064 8000000009"]}]
100
100
100
[{'input': '615716902\r\n', 'output': ['10508698 4925735225']}, {'input': '958557600\r\n', 'output': ['4637398 7668460809']}, {'input': '7033800\r\n', 'output': ['210976 56270409']}, {'input': '905969664\r\n', 'output': ['4529412 7247757321']}, {'input': '999893387\r\n', 'output': ['1000724227 7999147105']}]
[{'input': '935625600\r\n', 'output': ['4563150 7485004809']}, {'input': '20\r\n', 'output': ['64 169']}, {'input': '299999771\r\n', 'output': ['1499998867 2399998177']}, {'input': '573308928\r\n', 'output': ['3301020 4586471433']}, {'input': '332393619\r\n', 'output': ['10714371 2659148961']}]
[{'input': '7661860\r\n', 'output': ['546725 61294889']}, {'input': '422114561\r\n', 'output': ['78417139 3376916497']}, {'input': '12\r\n', 'output': ['48 105']}, {'input': '821620800\r\n', 'output': ['4185636 6572966409']}, {'input': '348\r\n', 'output': ['396 2793']}]
[{'input': '15\r\n', 'output': ['55 129']}, {'input': '534879507\r\n', 'output': ['253364145 4279036065']}, {'input': '6\r\n', 'output': ['34 57']}, {'input': '821620800\r\n', 'output': ['4185636 6572966409']}, {'input': '628464178\r\n', 'output': ['3574502 5027713433']}]
[{'input': '1\r\n', 'output': ['17 17']}, {'input': '14\r\n', 'output': ['58 121']}, {'input': '535074941\r\n', 'output': ['647722381 4280599537']}, {'input': '615716902\r\n', 'output': ['10508698 4925735225']}, {'input': '18\r\n', 'output': ['57 153']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
151
100
100
100
["WBWBWBWB\nBWBWBWBW\nBWBWBWBW\nBWBWBWBW\nWBWBWBWB\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB", "WBWBWBWB\nWBWBWBWB\nBBWBWWWB\nBWBWBWBW\nBWBWBWBW\nBWBWBWWW\nBWBWBWBW\nBWBWBWBW"]
The input consists of exactly eight lines. Each line contains exactly eight characters "W" or "B" without any spaces: the j-th character in the i-th line stands for the color of the j-th cell of the i-th row of the elephants' board. Character "W" stands for the white color, character "B" stands for the black color. Consider the rows of the board numbered from 1 to 8 from top to bottom, and the columns — from 1 to 8 from left to right. The given board can initially be a proper chessboard.
ca65e023be092b2ce25599f52acc1a67
/* ************************************************************* * "The world is nothing but a good program, * * and we are all some instances of the program!!" * * PROBLEM: * * SOLVED DATE: 2012/12/20 * * RT: 0.00 sec; RANK: * * ALGO: * * ==>> TheCoderJU (BISHAL) * ************************************************************* */ #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cstdlib> #include <cctype> #include <cmath> using namespace std; int i,j,k,m,n,tc,sm,cnt=0,tmp,w,b,cs=1,p,q,f=1,g=1; string s,s1,sw[10000]; int main() { f=1; for(i=1;i<=8;i++) { cin>>sw[i]; cnt=0; for(j=0;i<sw[i][j];j+=2) { if(sw[i][0]=='W' && (sw[i][j]=='W' && sw[i][j+1]=='B'))cnt++; else if(sw[i][0]=='B' && (sw[i][j]=='B' && sw[i][j+1]=='W'))cnt++; } if(cnt!=4){f=0;} } if(f)cout<<"YES\n"; else cout<<"NO\n"; return 0; }
["YES", "NO"]
C++
NoteIn the first sample you should shift the following lines one position to the right: the 3-rd, the 6-th, the 7-th and the 8-th.In the second sample there is no way you can achieve the goal.
In a single line print "YES" (without the quotes), if we can make the board a proper chessboard and "NO" (without the quotes) otherwise.
The Little Elephant loves chess very much. One day the Little Elephant and his friend decided to play chess. They've got the chess pieces but the board is a problem. They've got an 8 × 8 checkered board, each square is painted either black or white. The Little Elephant and his friend know that a proper chessboard doesn't have any side-adjacent cells with the same color and the upper left cell is white. To play chess, they want to make the board they have a proper chessboard. For that the friends can choose any row of the board and cyclically shift the cells of the chosen row, that is, put the last (rightmost) square on the first place in the row and shift the others one position to the right. You can run the described operation multiple times (or not run it at all).For example, if the first line of the board looks like that "BBBBBBWW" (the white cells of the line are marked with character "W", the black cells are marked with character "B"), then after one cyclic shift it will look like that "WBBBBBBW".Help the Little Elephant and his friend to find out whether they can use any number of the described operations to turn the board they have into a proper chessboard.
[{"input": "WBWBWBWB\r\nBWBWBWBW\r\nBWBWBWBW\r\nBWBWBWBW\r\nWBWBWBWB\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\n", "output": ["YES"]}, {"input": "WBWBWBWB\r\nWBWBWBWB\r\nBBWBWWWB\r\nBWBWBWBW\r\nBWBWBWBW\r\nBWBWBWWW\r\nBWBWBWBW\r\nBWBWBWBW\r\n", "output": ["NO"]}, {"input": "BWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nBWBWBWBW\r\nWBWBWBWB\r\nWBWBWBWB\r\nWBWBWBWB\r\nWBWBWBWB\r\n", "output": ["YES"]}, {"input": "BWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nWBWBWBWB\r\nWBWBWBWB\r\n", "output": ["YES"]}, {"input": "WBWBWBWB\r\nBWBWBWBW\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nBWBWBWBW\r\nBWBWBWBW\r\nBWBWBWBW\r\n", "output": ["YES"]}, {"input": "WBWBWBWB\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nWBWBWBWB\r\nWBWBWBWB\r\nWBWBWBWB\r\nBWWWBWBW\r\n", "output": ["NO"]}, {"input": "BBBBBWWW\r\nWBBWBWWB\r\nWWWWWBWW\r\nBWBWWBWW\r\nBBBWWBWW\r\nBBBBBWBW\r\nWBBBWBWB\r\nWBWBWWWB\r\n", "output": ["NO"]}, {"input": "BWBWBWBW\r\nBWBWBWBW\r\nBWWWWWBB\r\nBBWBWBWB\r\nWBWBWBWB\r\nWWBWWBWW\r\nBWBWBWBW\r\nWBWWBBBB\r\n", "output": ["NO"]}, {"input": "WBWBWBWB\r\nWBWBWBWB\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nWBWWBWBB\r\n", "output": ["NO"]}, {"input": "WBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nWBWBWBWB\r\nBWBWBWBW\r\nBWBWBWBW\r\n", "output": ["YES"]}, {"input": "WBWBWBWB\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nBWBWBWBW\r\n", "output": ["YES"]}, {"input": "WWWWBWWB\r\nBWBWBWBW\r\nBWBWBWBW\r\nWWBWBBBB\r\nBBWWBBBB\r\nBBBWWBBW\r\nBWWWWWWB\r\nBWWBBBWW\r\n", "output": ["NO"]}, {"input": "WBBWWBWB\r\nBBWBWBWB\r\nBWBWBWBW\r\nBWBWBWBW\r\nWBWBWBBW\r\nWBWBBBBW\r\nBWWWWBWB\r\nBBBBBBBW\r\n", "output": ["NO"]}, {"input": "BWBWBWBW\r\nBWBWBWBW\r\nBBWWWBBB\r\nWBBBBBWW\r\nWBBBBWBB\r\nWBWBWBWB\r\nWBWWBWWB\r\nWBBWBBWW\r\n", "output": ["NO"]}, {"input": "WBBBBBWB\r\nBWBWBWBW\r\nBWBWBWBW\r\nWBWBWBWB\r\nWBWBWBWB\r\nBBBBBWBB\r\nWBBWWBWB\r\nBWBWBWBW\r\n", "output": ["NO"]}, {"input": "BWBWBWBW\r\nBWBWBWBW\r\nBWBWBWBW\r\nWBWBWBWB\r\nWBWBWBWB\r\nBWBWBWBW\r\nBWBWBWBW\r\nWBBWWBWB\r\n", "output": ["NO"]}, {"input": "BWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nBWWWBWBW\r\nWBWBWBWB\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBBW\r\n", "output": ["NO"]}, {"input": "WBWBWBWB\r\nWBWBWBWB\r\nBWBWBWBW\r\nBWBWBWBW\r\nBWBWBWBW\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\n", "output": ["YES"]}, {"input": "BWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nBWBWBWBW\r\nBWBWBWBW\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\n", "output": ["YES"]}, {"input": "BWBWBWBW\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\n", "output": ["YES"]}, {"input": "WWBBWWBB\r\nBWWBBWWB\r\nBWBWBWBW\r\nWWBBWWWB\r\nWBWWWWBB\r\nWBWWBBWB\r\nBWBBWBWW\r\nBWBWWWWW\r\n", "output": ["NO"]}, {"input": "WBWBWBWB\r\nWBWBWBWB\r\nWWBBWBBB\r\nWBWBWBWB\r\nWWWWBWWB\r\nWBBBBWWW\r\nBWBWWWBW\r\nWWWBWBBB\r\n", "output": ["NO"]}, {"input": "WBWBWBWB\r\nBWWBWWWW\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nWWBBBBBW\r\nWWWBWWBW\r\nWWBBBBWW\r\n", "output": ["NO"]}, {"input": "BWBWBWBW\r\nBWBBBWWB\r\nWBWBWBWB\r\nBWBWBWBW\r\nBWBWBWBW\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\n", "output": ["NO"]}, {"input": "BWBWBWBW\r\nBWBWBWBW\r\nWBWBWBWB\r\nWBWBWBWB\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\n", "output": ["YES"]}, {"input": "BBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nWWWWWWWW\r\nWWWWWWWW\r\nWWWWWWWW\r\nWWWWWWWW\r\n", "output": ["NO"]}, {"input": "BBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\n", "output": ["NO"]}, {"input": "BWBWBWBB\r\nBWBWBWBB\r\nBWBWBWBB\r\nBWBWBWBB\r\nBWBWBWBB\r\nBWBWBWBB\r\nBWBWBWBB\r\nBWBWBWBB\r\n", "output": ["NO"]}, {"input": "WWBWWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\n", "output": ["NO"]}, {"input": "WWWWWWWW\r\nBBBBBBBB\r\nWWWWWWWW\r\nBBBBBBBB\r\nWWWWWWWW\r\nBBBBBBBB\r\nWWWWWWWW\r\nBBBBBBBB\r\n", "output": ["NO"]}, {"input": "BBBBBBBB\r\nBWBWBWBW\r\nBWBWBWBW\r\nBWBWBWBW\r\nWBWBWBWB\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\n", "output": ["NO"]}, {"input": "BBBBBBBW\r\nBBBBBBBW\r\nBBBBBBBW\r\nBBBBBBBW\r\nBBBBBBBW\r\nBBBBBBBW\r\nBBBBBBBW\r\nBBBBBBBW\r\n", "output": ["NO"]}, {"input": "BBBWWWWW\r\nWWWBBBBB\r\nBBBWWWWW\r\nWWWBBBBB\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\n", "output": ["NO"]}]
100
100
100
[{'input': 'BWBWBWBW\r\nBWBWBWBW\r\nWBWBWBWB\r\nWBWBWBWB\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\n', 'output': ['YES']}, {'input': 'BBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\n', 'output': ['NO']}, {'input': 'WBWBWBWB\r\nWBWBWBWB\r\nBWBWBWBW\r\nBWBWBWBW\r\nBWBWBWBW\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\n', 'output': ['YES']}, {'input': 'BWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nBWBWBWBW\r\nBWBWBWBW\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\n', 'output': ['YES']}, {'input': 'BBBBBBBW\r\nBBBBBBBW\r\nBBBBBBBW\r\nBBBBBBBW\r\nBBBBBBBW\r\nBBBBBBBW\r\nBBBBBBBW\r\nBBBBBBBW\r\n', 'output': ['NO']}]
[{'input': 'BBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nWWWWWWWW\r\nWWWWWWWW\r\nWWWWWWWW\r\nWWWWWWWW\r\n', 'output': ['NO']}, {'input': 'BBBBBBBB\r\nBWBWBWBW\r\nBWBWBWBW\r\nBWBWBWBW\r\nWBWBWBWB\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\n', 'output': ['NO']}, {'input': 'BWBWBWBW\r\nBWBWBWBW\r\nBBWWWBBB\r\nWBBBBBWW\r\nWBBBBWBB\r\nWBWBWBWB\r\nWBWWBWWB\r\nWBBWBBWW\r\n', 'output': ['NO']}, {'input': 'WBWBWBWB\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nBWBWBWBW\r\n', 'output': ['YES']}, {'input': 'BBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\n', 'output': ['NO']}]
[{'input': 'BWBWBWBW\r\nBWBBBWWB\r\nWBWBWBWB\r\nBWBWBWBW\r\nBWBWBWBW\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\n', 'output': ['NO']}, {'input': 'BWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nBWBWBWBW\r\nWBWBWBWB\r\nWBWBWBWB\r\nWBWBWBWB\r\nWBWBWBWB\r\n', 'output': ['YES']}, {'input': 'BBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nWWWWWWWW\r\nWWWWWWWW\r\nWWWWWWWW\r\nWWWWWWWW\r\n', 'output': ['NO']}, {'input': 'WWWWBWWB\r\nBWBWBWBW\r\nBWBWBWBW\r\nWWBWBBBB\r\nBBWWBBBB\r\nBBBWWBBW\r\nBWWWWWWB\r\nBWWBBBWW\r\n', 'output': ['NO']}, {'input': 'WBBBBBWB\r\nBWBWBWBW\r\nBWBWBWBW\r\nWBWBWBWB\r\nWBWBWBWB\r\nBBBBBWBB\r\nWBBWWBWB\r\nBWBWBWBW\r\n', 'output': ['NO']}]
[{'input': 'BWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nWBWBWBWB\r\nWBWBWBWB\r\n', 'output': ['YES']}, {'input': 'WWBWWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\n', 'output': ['NO']}, {'input': 'WWBBWWBB\r\nBWWBBWWB\r\nBWBWBWBW\r\nWWBBWWWB\r\nWBWWWWBB\r\nWBWWBBWB\r\nBWBBWBWW\r\nBWBWWWWW\r\n', 'output': ['NO']}, {'input': 'BWBWBWBW\r\nBWBWBWBW\r\nBBWWWBBB\r\nWBBBBBWW\r\nWBBBBWBB\r\nWBWBWBWB\r\nWBWWBWWB\r\nWBBWBBWW\r\n', 'output': ['NO']}, {'input': 'BWBWBWBW\r\nBWBWBWBW\r\nBWWWWWBB\r\nBBWBWBWB\r\nWBWBWBWB\r\nWWBWWBWW\r\nBWBWBWBW\r\nWBWWBBBB\r\n', 'output': ['NO']}]
[{'input': 'WBWBWBWB\r\nWBWBWBWB\r\nBWBWBWBW\r\nBWBWBWBW\r\nBWBWBWBW\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\n', 'output': ['YES']}, {'input': 'WBWBWBWB\r\nWBWBWBWB\r\nWWBBWBBB\r\nWBWBWBWB\r\nWWWWBWWB\r\nWBBBBWWW\r\nBWBWWWBW\r\nWWWBWBBB\r\n', 'output': ['NO']}, {'input': 'BBBBBBBW\r\nBBBBBBBW\r\nBBBBBBBW\r\nBBBBBBBW\r\nBBBBBBBW\r\nBBBBBBBW\r\nBBBBBBBW\r\nBBBBBBBW\r\n', 'output': ['NO']}, {'input': 'BBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\n', 'output': ['NO']}, {'input': 'BWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nBWBWBWBW\r\nWBWBWBWB\r\nWBWBWBWB\r\nWBWBWBWB\r\n', 'output': ['YES']}]
100
100
100
100
100
100
100
100
100
100
83.33
100
100
100
100
152
100
100
96.666
["5 1", "3 2", "6 3"]
The only line of input contains two integers n and m, separated by a single space (1 ≤ m ≤ n ≤ 109) — the number of participants and the number of teams respectively.
a081d400a5ce22899b91df38ba98eecc
#include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; const ll inf = LLONG_MAX; #define rel( i, a, b) for( ll i = a ; i <= b ; i++ ) #define rep( k, a, b) for( ll k = a ; k <= b ; k+=2*k ) #define rev( i, a, b) for( ll i = b ; i >= a ; i-- ) #define M 1000000007 #define pll pair<ll,ll> #define vll vector<ll> #define vpll vector<pll> #define mll map<ll,ll> #define mpll map<ll,pll> #define sll set<ll> #define spll set<pll> #define msll multiset<ll> #define F first #define S second #define pb push_back #define mp make_pair #define FIO ios::sync_with_stdio(false);cin.tie(0);cerr.tie(0) #define lb lower_bound #define ub upper_bound #define fprint(x) cout << fixed << setprecision(10) << (ld)x; ll n, m; ll mini, maxi; int main() { cin >> n >> m; ll t1, t2; t1 = n/m; mini = m*((t1*(t1-1))/2); if( n % m != 0 ){ ll t = n%m; mini += t1*t; } maxi = ((n-m+1)*(n-m))/2; cout << mini << " " << maxi; return 0; }
["10 10", "1 1", "3 6"]
C++
NoteIn the first sample all the participants get into one team, so there will be exactly ten pairs of friends.In the second sample at any possible arrangement one team will always have two participants and the other team will always have one participant. Thus, the number of pairs of friends will always be equal to one.In the third sample minimum number of newly formed friendships can be achieved if participants were split on teams consisting of 2 people, maximum number can be achieved if participants were split on teams of 1, 1 and 4 people.
The only line of the output should contain two integers kmin and kmax — the minimum possible number of pairs of friends and the maximum possible number of pairs of friends respectively.
n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends.Your task is to write a program that will find the minimum and the maximum number of pairs of friends that could have formed by the end of the competition.
[{"input": "5 1\r\n", "output": ["10 10"]}, {"input": "3 2\r\n", "output": ["1 1"]}, {"input": "6 3\r\n", "output": ["3 6"]}, {"input": "5 3\r\n", "output": ["2 3"]}, {"input": "10 2\r\n", "output": ["20 36"]}, {"input": "10 6\r\n", "output": ["4 10"]}, {"input": "1000000000 1\r\n", "output": ["499999999500000000 499999999500000000"]}, {"input": "5000000 12\r\n", "output": ["1041664166668 12499942500066"]}, {"input": "1833 195\r\n", "output": ["7722 1342341"]}, {"input": "1000000000 1000000000\r\n", "output": ["0 0"]}, {"input": "1000000000 1000000\r\n", "output": ["499500000000 499000500499500000"]}, {"input": "1000000000 32170\r\n", "output": ["15541930838100 499967831017438365"]}, {"input": "1000000 1000\r\n", "output": ["499500000 499000999500"]}, {"input": "1234 1123\r\n", "output": ["111 6216"]}, {"input": "599222887 298488\r\n", "output": ["601178656545 179355218158217800"]}, {"input": "999999999 500000000\r\n", "output": ["499999999 124999999750000000"]}, {"input": "1000000000 384842119\r\n", "output": ["845473643 189209609585784021"]}, {"input": "1000000000 2\r\n", "output": ["249999999500000000 499999998500000001"]}, {"input": "1000000000 999999999\r\n", "output": ["1 1"]}, {"input": "38447 383\r\n", "output": ["1910550 724453080"]}, {"input": "100000000 99999799\r\n", "output": ["201 20301"]}, {"input": "1 1\r\n", "output": ["0 0"]}, {"input": "2 1\r\n", "output": ["1 1"]}, {"input": "2 2\r\n", "output": ["0 0"]}, {"input": "10 10\r\n", "output": ["0 0"]}]
100
100
100
[{'input': '1000000000 1000000\r\n', 'output': ['499500000000 499000500499500000']}, {'input': '5 1\r\n', 'output': ['10 10']}, {'input': '5000000 12\r\n', 'output': ['1041664166668 12499942500066']}, {'input': '1000000000 1\r\n', 'output': ['499999999500000000 499999999500000000']}, {'input': '6 3\r\n', 'output': ['3 6']}]
[{'input': '599222887 298488\r\n', 'output': ['601178656545 179355218158217800']}, {'input': '5000000 12\r\n', 'output': ['1041664166668 12499942500066']}, {'input': '1000000 1000\r\n', 'output': ['499500000 499000999500']}, {'input': '999999999 500000000\r\n', 'output': ['499999999 124999999750000000']}, {'input': '5 1\r\n', 'output': ['10 10']}]
[{'input': '3 2\r\n', 'output': ['1 1']}, {'input': '599222887 298488\r\n', 'output': ['601178656545 179355218158217800']}, {'input': '1 1\r\n', 'output': ['0 0']}, {'input': '1000000000 2\r\n', 'output': ['249999999500000000 499999998500000001']}, {'input': '38447 383\r\n', 'output': ['1910550 724453080']}]
[{'input': '1000000 1000\r\n', 'output': ['499500000 499000999500']}, {'input': '1000000000 384842119\r\n', 'output': ['845473643 189209609585784021']}, {'input': '1000000000 1\r\n', 'output': ['499999999500000000 499999999500000000']}, {'input': '1000000000 1000000000\r\n', 'output': ['0 0']}, {'input': '1000000000 999999999\r\n', 'output': ['1 1']}]
[{'input': '1234 1123\r\n', 'output': ['111 6216']}, {'input': '38447 383\r\n', 'output': ['1910550 724453080']}, {'input': '5000000 12\r\n', 'output': ['1041664166668 12499942500066']}, {'input': '1000000000 1000000000\r\n', 'output': ['0 0']}, {'input': '1000000 1000\r\n', 'output': ['499500000 499000999500']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
153
100
100
100
["2\n8 8", "4\n3 1 4 1"]
The first line contains one integer $$$n$$$ ($$$2 \leq n \leq 50$$$) — the number of piles. It is guaranteed that $$$n$$$ is an even number. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 50$$$) — the number of stones in the piles.
4b9cf82967aa8441e9af3db3101161e9
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, a[N], cnt; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; sort(a + 1, a + n + 1); for (int i = 1; i <= n; ++i) if (a[i] == a[1]) ++cnt; if (cnt <= n >> 1) return cout << "Alice", 0; cout << "Bob"; }
["Bob", "Alice"]
C++
NoteIn the first example, each player can only remove stones from one pile ($$$\frac{2}{2}=1$$$). Alice loses, since Bob can copy whatever Alice does on the other pile, so Alice will run out of moves first.In the second example, Alice can remove $$$2$$$ stones from the first pile and $$$3$$$ stones from the third pile on her first move to guarantee a win.
Print a single string "Alice" if Alice wins; otherwise, print "Bob" (without double quotes).
Alice and Bob are playing a game with $$$n$$$ piles of stones. It is guaranteed that $$$n$$$ is an even number. The $$$i$$$-th pile has $$$a_i$$$ stones.Alice and Bob will play a game alternating turns with Alice going first.On a player's turn, they must choose exactly $$$\frac{n}{2}$$$ nonempty piles and independently remove a positive number of stones from each of the chosen piles. They can remove a different number of stones from the piles in a single turn. The first player unable to make a move loses (when there are less than $$$\frac{n}{2}$$$ nonempty piles).Given the starting configuration, determine who will win the game.
[{"input": "2\r\n8 8\r\n", "output": ["Bob"]}, {"input": "4\r\n3 1 4 1\r\n", "output": ["Alice"]}, {"input": "4\r\n42 49 42 42\r\n", "output": ["Bob"]}, {"input": "8\r\n11 21 31 41 41 31 21 11\r\n", "output": ["Alice"]}, {"input": "10\r\n21 4 7 21 18 38 12 17 21 13\r\n", "output": ["Alice"]}, {"input": "12\r\n33 26 11 11 32 25 18 24 27 47 28 7\r\n", "output": ["Alice"]}, {"input": "14\r\n4 10 7 13 27 28 13 34 16 18 39 26 29 22\r\n", "output": ["Alice"]}, {"input": "16\r\n47 27 33 49 2 47 48 9 37 39 5 24 38 38 4 32\r\n", "output": ["Alice"]}, {"input": "18\r\n38 48 13 15 18 16 44 46 17 30 16 33 43 12 9 48 31 37\r\n", "output": ["Alice"]}, {"input": "20\r\n28 10 4 31 4 49 50 1 40 43 31 49 34 16 34 38 50 40 10 10\r\n", "output": ["Alice"]}, {"input": "22\r\n37 35 37 35 39 42 35 35 49 50 42 35 40 36 35 35 35 43 35 35 35 35\r\n", "output": ["Bob"]}, {"input": "24\r\n31 6 41 46 36 37 6 50 50 6 6 6 6 6 6 6 39 45 40 6 35 6 6 6\r\n", "output": ["Bob"]}, {"input": "26\r\n8 47 49 44 33 43 33 8 29 41 8 8 8 8 8 8 41 47 8 8 8 8 43 8 32 8\r\n", "output": ["Bob"]}, {"input": "28\r\n48 14 22 14 14 14 14 14 47 39 14 36 14 14 49 41 36 45 14 34 14 14 14 14 14 45 25 41\r\n", "output": ["Bob"]}, {"input": "30\r\n7 47 7 40 35 37 7 42 40 7 7 7 7 7 35 7 47 7 34 7 7 33 7 7 41 7 46 33 44 7\r\n", "output": ["Bob"]}, {"input": "50\r\n44 25 36 44 25 7 28 33 35 16 31 17 50 48 6 42 47 36 9 11 31 27 28 20 34 47 24 44 38 50 46 9 38 28 9 10 28 42 37 43 29 42 38 43 41 25 12 29 26 36\r\n", "output": ["Alice"]}, {"input": "50\r\n42 4 18 29 37 36 41 41 34 32 1 50 15 25 46 22 9 38 48 49 5 50 2 14 15 10 27 34 46 50 30 6 19 39 45 36 39 50 8 13 13 24 27 5 25 19 42 46 11 30\r\n", "output": ["Alice"]}, {"input": "50\r\n40 9 43 18 39 35 35 46 48 49 26 34 28 50 14 34 17 3 13 8 8 48 17 43 42 21 43 30 45 12 43 13 25 30 39 5 19 3 19 6 12 30 19 46 48 24 14 33 6 19\r\n", "output": ["Alice"]}, {"input": "50\r\n11 6 26 45 49 26 50 31 21 21 10 19 39 50 16 8 39 35 29 14 17 9 34 13 44 28 20 23 32 37 16 4 21 40 10 42 2 2 38 30 9 24 42 30 30 15 18 38 47 12\r\n", "output": ["Alice"]}, {"input": "50\r\n20 12 45 12 15 49 45 7 27 20 32 47 50 16 37 4 9 33 5 27 6 18 42 35 21 9 27 14 50 24 23 5 46 12 29 45 17 38 20 12 32 27 43 49 17 4 45 2 50 4\r\n", "output": ["Alice"]}, {"input": "40\r\n48 29 48 31 39 16 17 11 20 11 33 29 18 42 39 26 43 43 22 28 1 5 33 49 7 18 6 3 33 41 41 40 25 25 37 47 12 42 23 27\r\n", "output": ["Alice"]}, {"input": "40\r\n32 32 34 38 1 50 18 26 16 14 13 26 10 15 20 28 19 49 17 14 8 6 45 32 15 37 14 15 21 21 42 33 12 14 34 44 38 25 24 15\r\n", "output": ["Alice"]}, {"input": "40\r\n36 34 16 47 49 45 46 16 46 2 30 23 2 20 4 8 28 38 20 3 50 40 21 48 45 25 41 14 37 17 5 3 33 33 49 47 48 32 47 2\r\n", "output": ["Alice"]}, {"input": "40\r\n46 2 26 49 34 10 12 47 36 44 15 36 48 23 30 4 36 26 23 32 31 13 34 15 10 41 17 32 33 25 12 36 9 31 25 9 46 28 6 30\r\n", "output": ["Alice"]}, {"input": "40\r\n17 8 23 16 25 37 11 16 16 29 25 38 31 45 14 46 40 24 49 44 21 12 29 18 33 35 7 47 41 48 24 39 8 37 29 13 12 21 44 19\r\n", "output": ["Alice"]}, {"input": "42\r\n13 33 2 18 5 25 29 15 38 11 49 14 38 16 34 3 5 35 1 39 45 4 32 15 30 23 48 22 9 34 42 34 8 36 39 5 27 22 8 38 26 31\r\n", "output": ["Alice"]}, {"input": "42\r\n7 6 9 5 18 8 16 46 10 48 43 20 14 20 16 24 2 12 26 5 9 48 4 47 39 31 2 30 36 47 10 43 16 19 50 48 18 43 35 38 9 45\r\n", "output": ["Alice"]}, {"input": "42\r\n49 46 12 3 38 7 32 7 25 40 20 25 2 43 17 28 28 50 35 35 22 42 15 13 44 14 27 30 26 7 29 31 40 39 18 42 11 3 32 48 34 11\r\n", "output": ["Alice"]}, {"input": "42\r\n3 50 33 31 8 19 3 36 41 50 2 22 9 40 39 22 30 34 43 25 42 39 40 8 18 1 25 13 50 11 48 10 11 4 3 47 2 35 25 39 31 36\r\n", "output": ["Alice"]}, {"input": "42\r\n20 38 27 15 6 17 21 42 31 38 43 20 31 12 29 3 11 45 44 22 10 2 14 20 39 33 47 6 11 43 41 1 14 27 24 41 9 4 7 26 8 21\r\n", "output": ["Alice"]}, {"input": "44\r\n50 32 33 26 39 26 26 46 26 28 26 38 26 26 26 32 26 46 26 35 28 26 41 37 26 41 26 26 45 26 44 50 42 26 39 26 46 26 26 28 26 26 26 26\r\n", "output": ["Bob"]}, {"input": "44\r\n45 18 18 39 35 30 34 18 28 18 47 18 18 18 18 18 40 18 18 49 31 35 18 18 35 36 18 18 28 18 18 42 32 18 18 31 37 27 18 18 18 37 18 37\r\n", "output": ["Bob"]}, {"input": "44\r\n28 28 36 40 28 28 35 28 28 33 33 28 28 28 28 47 28 43 28 28 35 38 49 40 28 28 34 39 45 32 28 28 28 50 39 28 32 28 50 32 28 33 28 28\r\n", "output": ["Bob"]}, {"input": "44\r\n27 40 39 38 27 49 27 33 45 34 27 39 49 27 27 27 27 27 27 39 49 27 27 27 27 27 38 39 43 44 45 44 33 27 27 27 27 27 42 27 47 27 42 27\r\n", "output": ["Bob"]}, {"input": "44\r\n37 43 3 3 36 45 3 3 30 3 30 29 3 3 3 3 36 34 31 38 3 38 3 48 3 3 3 3 46 49 30 50 3 42 3 3 3 37 3 3 41 3 49 3\r\n", "output": ["Bob"]}, {"input": "46\r\n35 37 27 27 27 33 27 34 32 34 32 38 27 50 27 27 29 27 35 45 27 27 27 32 30 27 27 27 47 27 27 27 27 38 33 27 43 49 29 27 31 27 27 27 38 27\r\n", "output": ["Bob"]}, {"input": "46\r\n15 15 36 15 30 15 15 45 20 29 41 37 15 15 15 15 22 22 38 15 15 15 15 47 15 39 15 15 15 15 42 15 15 34 24 30 21 39 15 22 15 24 15 35 15 21\r\n", "output": ["Bob"]}, {"input": "46\r\n39 18 30 18 43 18 18 18 18 18 18 36 18 39 32 46 32 18 18 18 18 18 18 38 43 44 48 18 34 35 18 46 30 18 18 45 43 18 18 18 44 30 18 18 44 33\r\n", "output": ["Bob"]}, {"input": "46\r\n14 14 14 14 14 14 30 45 42 30 42 14 14 34 14 14 42 28 14 14 37 14 25 49 34 14 46 14 14 40 49 44 40 47 14 14 14 26 14 14 14 46 14 31 30 14\r\n", "output": ["Bob"]}, {"input": "46\r\n14 14 48 14 14 22 14 14 14 14 40 14 14 33 14 32 49 40 14 34 14 14 14 14 46 42 14 43 14 41 22 50 14 32 14 49 14 31 47 50 47 14 14 14 44 22\r\n", "output": ["Bob"]}, {"input": "48\r\n9 36 47 31 48 33 39 9 23 3 18 44 33 49 26 10 45 12 28 30 5 22 41 27 19 44 44 27 9 46 24 22 11 28 41 48 45 1 10 42 19 34 40 8 36 48 43 50\r\n", "output": ["Alice"]}, {"input": "48\r\n12 19 22 48 21 19 18 49 10 50 31 40 19 19 44 33 6 12 31 11 5 47 26 48 2 17 6 37 17 25 20 42 30 35 37 41 32 45 47 38 44 41 20 31 47 39 3 45\r\n", "output": ["Alice"]}, {"input": "48\r\n33 47 6 10 28 22 41 45 27 19 45 18 29 10 35 18 39 29 8 10 9 1 9 23 10 11 3 14 12 15 35 29 29 18 12 49 27 18 18 45 29 32 15 21 34 1 43 9\r\n", "output": ["Alice"]}, {"input": "48\r\n13 25 45 45 23 29 11 30 40 10 49 32 44 50 35 7 48 37 17 43 45 50 48 31 41 6 3 32 33 22 41 4 1 30 16 9 48 46 17 29 45 12 49 42 21 1 13 10\r\n", "output": ["Alice"]}, {"input": "48\r\n47 3 12 9 37 19 8 9 10 11 48 28 6 8 12 48 44 1 15 8 48 10 33 11 42 24 45 27 8 30 48 40 3 15 34 17 2 32 30 50 9 11 7 33 41 33 27 17\r\n", "output": ["Alice"]}, {"input": "50\r\n44 4 19 9 41 48 31 39 30 16 27 38 37 45 12 36 37 25 35 19 43 22 36 26 26 49 23 4 33 2 31 26 36 38 41 30 42 18 45 24 23 14 32 37 44 13 4 39 46 7\r\n", "output": ["Alice"]}, {"input": "50\r\n4 36 10 48 17 28 14 7 47 38 13 3 1 48 28 21 12 49 1 35 16 9 15 42 36 34 10 28 27 23 47 36 33 44 44 26 3 43 31 32 26 36 41 44 10 8 29 1 36 9\r\n", "output": ["Alice"]}, {"input": "50\r\n13 10 50 35 23 34 47 25 39 11 50 41 20 48 10 10 1 2 41 16 14 50 49 42 48 39 16 9 31 30 22 2 25 40 6 8 34 4 2 46 14 6 6 38 45 30 27 36 49 18\r\n", "output": ["Alice"]}, {"input": "50\r\n42 31 49 11 28 38 49 32 15 22 10 18 43 39 46 32 10 19 13 32 19 40 34 28 28 39 19 3 1 47 10 18 19 31 21 7 39 37 34 45 19 21 35 46 10 24 45 33 20 40\r\n", "output": ["Alice"]}, {"input": "50\r\n28 30 40 25 47 47 3 22 28 10 37 15 11 18 31 36 35 18 34 3 21 16 24 29 12 29 42 23 25 8 7 10 43 24 40 29 3 6 14 28 2 32 29 18 47 4 6 45 42 40\r\n", "output": ["Alice"]}, {"input": "4\r\n1 4 4 4\r\n", "output": ["Alice"]}, {"input": "4\r\n1 2 2 2\r\n", "output": ["Alice"]}, {"input": "2\r\n1 1\r\n", "output": ["Bob"]}, {"input": "4\r\n3 4 4 4\r\n", "output": ["Alice"]}, {"input": "4\r\n2 2 2 1\r\n", "output": ["Alice"]}, {"input": "4\r\n1 3 3 3\r\n", "output": ["Alice"]}, {"input": "6\r\n4 4 4 4 4 1\r\n", "output": ["Alice"]}, {"input": "4\r\n1 50 50 50\r\n", "output": ["Alice"]}, {"input": "6\r\n1 2 2 2 2 3\r\n", "output": ["Alice"]}, {"input": "4\r\n1 2 2 3\r\n", "output": ["Alice"]}, {"input": "4\r\n2 1 1 1\r\n", "output": ["Bob"]}, {"input": "6\r\n1 1 2 2 3 3\r\n", "output": ["Alice"]}, {"input": "4\r\n1 1 1 4\r\n", "output": ["Bob"]}, {"input": "6\r\n1 2 2 2 2 2\r\n", "output": ["Alice"]}, {"input": "6\r\n1 2 2 2 2 4\r\n", "output": ["Alice"]}, {"input": "4\r\n2 3 3 3\r\n", "output": ["Alice"]}, {"input": "6\r\n1 1 2 2 2 2\r\n", "output": ["Alice"]}, {"input": "8\r\n1 1 1 1 1 1 6 6\r\n", "output": ["Bob"]}, {"input": "8\r\n1 1 2 2 2 2 2 2\r\n", "output": ["Alice"]}, {"input": "8\r\n1 1 1 1 1 2 2 2\r\n", "output": ["Bob"]}]
100
100
100
[{'input': '10\r\n21 4 7 21 18 38 12 17 21 13\r\n', 'output': ['Alice']}, {'input': '46\r\n35 37 27 27 27 33 27 34 32 34 32 38 27 50 27 27 29 27 35 45 27 27 27 32 30 27 27 27 47 27 27 27 27 38 33 27 43 49 29 27 31 27 27 27 38 27\r\n', 'output': ['Bob']}, {'input': '6\r\n1 2 2 2 2 2\r\n', 'output': ['Alice']}, {'input': '50\r\n20 12 45 12 15 49 45 7 27 20 32 47 50 16 37 4 9 33 5 27 6 18 42 35 21 9 27 14 50 24 23 5 46 12 29 45 17 38 20 12 32 27 43 49 17 4 45 2 50 4\r\n', 'output': ['Alice']}, {'input': '50\r\n11 6 26 45 49 26 50 31 21 21 10 19 39 50 16 8 39 35 29 14 17 9 34 13 44 28 20 23 32 37 16 4 21 40 10 42 2 2 38 30 9 24 42 30 30 15 18 38 47 12\r\n', 'output': ['Alice']}]
[{'input': '6\r\n1 1 2 2 3 3\r\n', 'output': ['Alice']}, {'input': '22\r\n37 35 37 35 39 42 35 35 49 50 42 35 40 36 35 35 35 43 35 35 35 35\r\n', 'output': ['Bob']}, {'input': '14\r\n4 10 7 13 27 28 13 34 16 18 39 26 29 22\r\n', 'output': ['Alice']}, {'input': '8\r\n1 1 1 1 1 2 2 2\r\n', 'output': ['Bob']}, {'input': '50\r\n28 30 40 25 47 47 3 22 28 10 37 15 11 18 31 36 35 18 34 3 21 16 24 29 12 29 42 23 25 8 7 10 43 24 40 29 3 6 14 28 2 32 29 18 47 4 6 45 42 40\r\n', 'output': ['Alice']}]
[{'input': '6\r\n4 4 4 4 4 1\r\n', 'output': ['Alice']}, {'input': '6\r\n1 2 2 2 2 4\r\n', 'output': ['Alice']}, {'input': '40\r\n17 8 23 16 25 37 11 16 16 29 25 38 31 45 14 46 40 24 49 44 21 12 29 18 33 35 7 47 41 48 24 39 8 37 29 13 12 21 44 19\r\n', 'output': ['Alice']}, {'input': '48\r\n13 25 45 45 23 29 11 30 40 10 49 32 44 50 35 7 48 37 17 43 45 50 48 31 41 6 3 32 33 22 41 4 1 30 16 9 48 46 17 29 45 12 49 42 21 1 13 10\r\n', 'output': ['Alice']}, {'input': '46\r\n35 37 27 27 27 33 27 34 32 34 32 38 27 50 27 27 29 27 35 45 27 27 27 32 30 27 27 27 47 27 27 27 27 38 33 27 43 49 29 27 31 27 27 27 38 27\r\n', 'output': ['Bob']}]
[{'input': '44\r\n37 43 3 3 36 45 3 3 30 3 30 29 3 3 3 3 36 34 31 38 3 38 3 48 3 3 3 3 46 49 30 50 3 42 3 3 3 37 3 3 41 3 49 3\r\n', 'output': ['Bob']}, {'input': '18\r\n38 48 13 15 18 16 44 46 17 30 16 33 43 12 9 48 31 37\r\n', 'output': ['Alice']}, {'input': '44\r\n27 40 39 38 27 49 27 33 45 34 27 39 49 27 27 27 27 27 27 39 49 27 27 27 27 27 38 39 43 44 45 44 33 27 27 27 27 27 42 27 47 27 42 27\r\n', 'output': ['Bob']}, {'input': '50\r\n28 30 40 25 47 47 3 22 28 10 37 15 11 18 31 36 35 18 34 3 21 16 24 29 12 29 42 23 25 8 7 10 43 24 40 29 3 6 14 28 2 32 29 18 47 4 6 45 42 40\r\n', 'output': ['Alice']}, {'input': '24\r\n31 6 41 46 36 37 6 50 50 6 6 6 6 6 6 6 39 45 40 6 35 6 6 6\r\n', 'output': ['Bob']}]
[{'input': '6\r\n4 4 4 4 4 1\r\n', 'output': ['Alice']}, {'input': '6\r\n1 2 2 2 2 2\r\n', 'output': ['Alice']}, {'input': '4\r\n42 49 42 42\r\n', 'output': ['Bob']}, {'input': '48\r\n33 47 6 10 28 22 41 45 27 19 45 18 29 10 35 18 39 29 8 10 9 1 9 23 10 11 3 14 12 15 35 29 29 18 12 49 27 18 18 45 29 32 15 21 34 1 43 9\r\n', 'output': ['Alice']}, {'input': '8\r\n1 1 1 1 1 1 6 6\r\n', 'output': ['Bob']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
154
100
100
100
["4\n2 3 1 4", "4\n4 4 4 4", "4\n2 1 4 3"]
The first line of input contains integer n (1 ≤ n ≤ 100) — the number of people in Arpa's land. The second line contains n integers, i-th of them is crushi (1 ≤ crushi ≤ n) — the number of i-th person's crush.
149221131a978298ac56b58438df46c9
#include <stdio.h> int n,par[105]; bool vis[105]; int gcd(int a,int b){ if(b==0)return a; return gcd(b,a%b); } int main(){ int ans=1; scanf("%i",&n); for(int i=1;i<=n;i++)scanf("%i",&par[i]); for(int j=1;j<=n;j++){ if(vis[j])continue; bool valid=0; int pos=par[j]; for(int k=1;k<=n+2;k++){ vis[pos]=1; if(pos==j){ valid=1; int fpb=gcd(ans,(k&1)?k:k/2); ans=(ans*((k&1)?k:k/2))/fpb; break; } pos=par[pos]; } if(!valid){ printf("-1\n"); return 0; } } printf("%i\n",ans); }
["3", "-1", "1"]
C++
NoteIn the first sample suppose t = 3. If the first person starts some round:The first person calls the second person and says "Owwwf", then the second person calls the third person and says "Owwf", then the third person calls the first person and says "Owf", so the first person becomes Joon-Joon of the round. So the condition is satisfied if x is 1.The process is similar for the second and the third person.If the fourth person starts some round:The fourth person calls himself and says "Owwwf", then he calls himself again and says "Owwf", then he calls himself for another time and says "Owf", so the fourth person becomes Joon-Joon of the round. So the condition is satisfied when x is 4.In the last example if the first person starts a round, then the second person becomes the Joon-Joon, and vice versa.
If there is no t satisfying the condition, print -1. Otherwise print such smallest t.
As you have noticed, there are lovely girls in Arpa’s land.People in Arpa's land are numbered from 1 to n. Everyone has exactly one crush, i-th person's crush is person with the number crushi. Someday Arpa shouted Owf loudly from the top of the palace and a funny game started in Arpa's land. The rules are as follows.The game consists of rounds. Assume person x wants to start a round, he calls crushx and says: "Oww...wwf" (the letter w is repeated t times) and cuts off the phone immediately. If t &gt; 1 then crushx calls crushcrushx and says: "Oww...wwf" (the letter w is repeated t - 1 times) and cuts off the phone immediately. The round continues until some person receives an "Owf" (t = 1). This person is called the Joon-Joon of the round. There can't be two rounds at the same time.Mehrdad has an evil plan to make the game more funny, he wants to find smallest t (t ≥ 1) such that for each person x, if x starts some round and y becomes the Joon-Joon of the round, then by starting from y, x would become the Joon-Joon of the round. Find such t for Mehrdad if it's possible.Some strange fact in Arpa's land is that someone can be himself's crush (i.e. crushi = i).
[{"input": "4\r\n2 3 1 4\r\n", "output": ["3"]}, {"input": "4\r\n4 4 4 4\r\n", "output": ["-1"]}, {"input": "4\r\n2 1 4 3\r\n", "output": ["1"]}, {"input": "5\r\n2 4 3 1 2\r\n", "output": ["-1"]}, {"input": "5\r\n2 2 4 4 5\r\n", "output": ["-1"]}, {"input": "5\r\n2 4 5 4 2\r\n", "output": ["-1"]}, {"input": "10\r\n8 10 4 3 2 1 9 6 5 7\r\n", "output": ["15"]}, {"input": "10\r\n10 1 4 8 5 2 3 7 9 6\r\n", "output": ["2"]}, {"input": "10\r\n6 4 3 9 5 2 1 10 8 7\r\n", "output": ["4"]}, {"input": "100\r\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100\r\n", "output": ["1"]}, {"input": "100\r\n95 27 13 62 100 21 48 84 27 41 34 89 21 96 56 10 6 27 9 85 7 85 16 12 80 78 20 79 63 1 74 46 56 59 62 88 59 5 42 13 81 58 49 1 62 51 2 75 92 94 14 32 31 39 34 93 72 18 59 44 11 75 27 36 44 72 63 55 41 63 87 59 54 81 68 39 95 96 99 50 94 5 3 84 59 95 71 44 35 51 73 54 49 98 44 11 52 74 95 48\r\n", "output": ["-1"]}, {"input": "100\r\n70 49 88 43 66 72 6 6 48 46 59 22 56 86 14 53 50 84 79 76 89 65 10 14 27 43 92 95 98 6 86 6 95 65 91 8 58 33 31 67 75 65 94 75 12 25 37 56 17 79 74 5 94 65 99 75 16 52 19 17 41 39 44 46 51 50 82 90 25 32 83 36 74 49 61 37 8 52 35 28 58 82 76 12 7 66 23 85 53 19 45 8 46 21 62 38 42 48 100 61\r\n", "output": ["-1"]}, {"input": "100\r\n27 55 94 11 56 59 83 81 79 89 48 89 7 75 70 20 70 76 14 81 61 55 98 76 35 20 79 100 77 12 97 57 16 80 45 75 2 21 44 81 93 75 69 3 87 25 27 25 85 91 96 86 35 85 99 61 70 37 11 27 63 89 62 47 61 10 91 13 90 18 72 47 47 98 93 27 71 37 51 31 80 63 42 88 6 76 11 12 13 7 90 99 100 27 22 66 41 49 12 11\r\n", "output": ["-1"]}, {"input": "100\r\n98 39 44 79 31 99 96 72 97 54 83 15 81 65 59 75 3 51 83 40 28 54 41 93 56 94 93 58 20 53 21 7 81 17 71 31 31 88 34 22 55 67 57 92 34 88 87 23 36 33 41 33 17 10 71 28 79 6 3 60 67 99 68 8 39 29 49 17 82 43 100 86 64 47 55 66 58 57 50 49 8 11 15 91 42 44 72 28 18 32 81 22 20 78 55 51 37 94 34 4\r\n", "output": ["-1"]}, {"input": "100\r\n53 12 13 98 57 83 52 61 69 54 13 92 91 27 16 91 86 75 93 29 16 59 14 2 37 74 34 30 98 17 3 72 83 93 21 72 52 89 57 58 60 29 94 16 45 20 76 64 78 67 76 68 41 47 50 36 9 75 79 11 10 88 71 22 36 60 44 19 79 43 49 24 6 57 8 42 51 58 60 2 84 48 79 55 74 41 89 10 45 70 76 29 53 9 82 93 24 40 94 56\r\n", "output": ["-1"]}, {"input": "100\r\n33 44 16 91 71 86 84 45 12 97 18 1 42 67 89 45 62 56 72 70 59 62 96 13 24 19 81 61 99 65 12 26 59 61 6 19 71 49 52 17 56 6 8 98 75 83 39 75 45 8 98 35 25 3 51 89 82 50 82 30 74 63 77 60 23 36 55 49 74 73 66 62 100 44 26 72 24 84 100 54 87 65 87 61 54 29 38 99 91 63 47 44 28 11 14 29 51 55 28 95\r\n", "output": ["-1"]}, {"input": "100\r\n17 14 81 16 30 51 62 47 3 42 71 63 45 67 91 20 35 45 15 94 83 89 7 32 49 68 73 14 94 45 64 64 15 56 46 32 92 92 10 32 58 86 15 17 41 59 95 69 71 74 92 90 82 64 59 93 74 58 84 21 61 51 47 1 93 91 47 61 13 53 97 65 80 78 41 1 89 4 21 27 45 28 21 96 29 96 49 75 41 46 6 33 50 31 30 3 21 8 34 7\r\n", "output": ["-1"]}, {"input": "100\r\n42 40 91 4 21 49 59 37 1 62 23 2 32 88 48 39 35 50 67 11 20 19 63 98 63 20 63 95 25 82 34 55 6 93 65 40 62 84 84 47 79 22 5 51 5 16 63 43 57 81 76 44 19 61 68 80 47 30 32 72 72 26 76 12 37 2 70 14 86 77 48 26 89 87 25 8 74 18 13 8 1 45 37 10 96 100 80 48 59 73 8 67 18 66 10 26 3 65 22 8\r\n", "output": ["-1"]}, {"input": "100\r\n49 94 43 50 70 25 37 19 66 89 98 83 57 98 100 61 89 56 75 61 2 14 28 14 60 84 82 89 100 25 57 80 51 37 74 40 90 68 24 56 17 86 87 83 52 65 7 18 5 2 53 79 83 56 55 35 29 79 46 97 25 10 47 1 61 74 4 71 34 85 39 17 7 84 22 80 38 60 89 83 80 81 87 11 41 15 57 53 45 75 58 51 85 12 93 8 90 3 1 59\r\n", "output": ["-1"]}, {"input": "100\r\n84 94 72 32 61 90 61 2 76 42 35 82 90 29 51 27 65 99 38 41 44 73 100 58 56 64 54 31 14 58 57 64 90 49 73 80 74 19 31 86 73 44 39 43 28 95 23 5 85 5 74 81 34 44 86 30 50 57 94 56 53 42 53 87 92 78 53 49 78 60 37 63 41 19 15 68 25 77 87 48 23 100 54 27 68 84 43 92 76 55 2 94 100 20 92 18 76 83 100 99\r\n", "output": ["-1"]}, {"input": "100\r\n82 62 73 22 56 69 88 72 76 99 13 30 64 21 89 37 5 7 16 38 42 96 41 6 34 18 35 8 31 92 63 87 58 75 9 53 80 46 33 100 68 36 24 3 77 45 2 51 78 54 67 48 15 1 79 57 71 97 17 52 4 98 85 14 47 83 84 49 27 91 19 29 25 44 11 43 60 86 61 94 32 10 59 93 65 20 50 55 66 95 90 70 39 26 12 74 40 81 23 28\r\n", "output": ["1260"]}, {"input": "100\r\n23 12 62 61 32 22 34 91 49 44 59 26 7 89 98 100 60 21 30 9 68 97 33 71 67 83 45 38 5 8 2 65 16 69 18 82 72 27 78 73 35 48 29 36 66 54 95 37 10 19 20 77 1 17 87 70 42 4 50 53 63 94 93 56 24 88 55 6 11 58 39 75 90 40 57 79 47 31 41 51 52 85 14 13 99 64 25 46 15 92 28 86 43 76 84 96 3 74 81 80\r\n", "output": ["6864"]}, {"input": "100\r\n88 41 92 79 21 91 44 2 27 96 9 64 73 87 45 13 39 43 16 42 99 54 95 5 75 1 48 4 15 47 34 71 76 62 17 70 81 80 53 90 67 3 38 58 32 25 29 63 6 50 51 14 37 97 24 52 65 40 31 98 100 77 8 33 61 11 49 84 89 78 56 20 94 35 86 46 85 36 82 93 7 59 10 60 69 57 12 74 28 22 30 66 18 68 72 19 26 83 23 55\r\n", "output": ["360"]}, {"input": "100\r\n37 60 72 43 66 70 13 6 27 41 36 52 44 92 89 88 64 90 77 32 78 58 35 31 97 50 95 82 7 65 99 22 16 28 85 46 26 38 15 79 34 96 23 39 42 75 51 83 33 57 3 53 4 48 18 8 98 24 55 84 20 30 14 25 40 29 91 69 68 17 54 94 74 49 73 11 62 81 59 86 61 45 19 80 76 67 21 2 71 87 10 1 63 9 100 93 47 56 5 12\r\n", "output": ["1098"]}, {"input": "100\r\n79 95 49 70 84 28 89 18 5 3 57 30 27 19 41 46 12 88 2 75 58 44 31 16 8 83 87 68 90 29 67 13 34 17 1 72 80 15 20 4 22 37 92 7 98 96 69 76 45 91 82 60 93 78 86 39 21 94 77 26 14 59 24 56 35 71 52 38 48 100 32 74 9 54 47 63 23 55 51 81 53 33 6 36 62 11 42 73 43 99 50 97 61 85 66 65 25 10 64 40\r\n", "output": ["13090"]}, {"input": "100\r\n74 71 86 6 75 16 62 25 95 45 29 36 97 5 8 78 26 69 56 57 60 15 55 87 14 23 68 11 31 47 3 24 7 54 49 80 33 76 30 65 4 53 93 20 37 84 35 1 66 40 46 17 12 73 42 96 38 2 32 72 58 51 90 22 99 89 88 21 85 28 63 10 92 18 61 98 27 19 81 48 34 94 50 83 59 77 9 44 79 43 39 100 82 52 70 41 67 13 64 91\r\n", "output": ["4020"]}, {"input": "100\r\n58 65 42 100 48 22 62 16 20 2 19 8 60 28 41 90 39 31 74 99 34 75 38 82 79 29 24 84 6 95 49 43 94 81 51 44 77 72 1 55 47 69 15 33 66 9 53 89 97 67 4 71 57 18 36 88 83 91 5 61 40 70 10 23 26 30 59 25 68 86 85 12 96 46 87 14 32 11 93 27 54 37 78 92 52 21 80 13 50 17 56 35 73 98 63 3 7 45 64 76\r\n", "output": ["1098"]}, {"input": "100\r\n60 68 76 27 73 9 6 10 1 46 3 34 75 11 33 89 59 16 21 50 82 86 28 95 71 31 58 69 20 42 91 79 18 100 8 36 92 25 61 22 45 39 23 66 32 65 80 51 67 84 35 43 98 2 97 4 13 81 24 19 70 7 90 37 62 48 41 94 40 56 93 44 47 83 15 17 74 88 64 30 77 5 26 29 57 12 63 14 38 87 99 52 78 49 96 54 55 53 85 72\r\n", "output": ["132"]}, {"input": "100\r\n72 39 12 50 13 55 4 94 22 61 33 14 29 93 28 53 59 97 2 24 6 98 52 21 62 84 44 41 78 82 71 89 88 63 57 42 67 16 30 1 27 66 35 26 36 90 95 65 7 48 47 11 34 76 69 3 100 60 32 45 40 87 18 81 51 56 73 85 25 31 8 77 37 58 91 20 83 92 38 17 9 64 43 5 10 99 46 23 75 74 80 68 15 19 70 86 79 54 49 96\r\n", "output": ["4620"]}, {"input": "100\r\n91 50 1 37 65 78 73 10 68 84 54 41 80 59 2 96 53 5 19 58 82 3 88 34 100 76 28 8 44 38 17 15 63 94 21 72 57 31 33 40 49 56 6 52 95 66 71 20 12 16 35 75 70 39 4 60 45 9 89 18 87 92 85 46 23 79 22 24 36 81 25 43 11 86 67 27 32 69 77 26 42 98 97 93 51 61 48 47 62 90 74 64 83 30 14 55 13 29 99 7\r\n", "output": ["3498"]}, {"input": "100\r\n40 86 93 77 68 5 32 77 1 79 68 33 29 36 38 3 69 46 72 7 27 27 30 40 21 18 69 69 32 10 82 97 1 34 87 81 92 67 47 3 52 89 25 41 88 79 5 46 41 82 87 1 77 41 54 16 6 92 18 10 37 45 71 25 16 66 39 94 60 13 48 64 28 91 80 36 4 53 50 28 30 45 92 79 93 71 96 66 65 73 57 71 48 78 76 53 96 76 81 89\r\n", "output": ["-1"]}, {"input": "100\r\n2 35 14 84 13 36 35 50 61 6 85 13 65 12 30 52 25 84 46 28 84 78 45 7 64 47 3 4 89 99 83 92 38 75 25 44 47 55 44 80 20 26 88 37 64 57 81 8 7 28 34 94 9 37 39 54 53 59 3 26 19 40 59 38 54 43 61 67 43 67 6 25 63 54 9 77 73 54 17 40 14 76 51 74 44 56 18 40 31 38 37 11 87 77 92 79 96 22 59 33\r\n", "output": ["-1"]}, {"input": "100\r\n68 45 33 49 40 52 43 60 71 83 43 47 6 34 5 94 99 74 65 78 31 52 51 72 8 12 70 87 39 68 2 82 90 71 82 44 43 34 50 26 59 62 90 9 52 52 81 5 72 27 71 95 32 6 23 27 26 63 66 3 35 58 62 87 45 16 64 82 62 40 22 15 88 21 50 58 15 49 45 99 78 8 81 55 90 91 32 86 29 30 50 74 96 43 43 6 46 88 59 12\r\n", "output": ["-1"]}, {"input": "100\r\n83 4 84 100 21 83 47 79 11 78 40 33 97 68 5 46 93 23 54 93 61 67 88 8 91 11 46 10 48 39 95 29 81 36 71 88 45 64 90 43 52 49 59 57 45 83 74 89 22 67 46 2 63 84 20 30 51 26 70 84 35 70 21 86 88 79 7 83 13 56 74 54 83 96 31 57 91 69 60 43 12 34 31 23 70 48 96 58 20 36 87 17 39 100 31 69 21 54 49 42\r\n", "output": ["-1"]}, {"input": "100\r\n35 12 51 32 59 98 65 84 34 83 75 72 35 31 17 55 35 84 6 46 23 74 81 98 61 9 39 40 6 15 44 79 98 3 45 41 64 56 4 27 62 27 68 80 99 21 32 26 60 82 5 1 98 75 49 26 60 25 57 18 69 88 51 64 74 97 81 78 62 32 68 77 48 71 70 64 17 1 77 25 95 68 33 80 11 55 18 42 24 73 51 55 82 72 53 20 99 15 34 54\r\n", "output": ["-1"]}, {"input": "100\r\n82 56 26 86 95 27 37 7 8 41 47 87 3 45 27 34 61 95 92 44 85 100 7 36 23 7 43 4 34 48 88 58 26 59 89 46 47 13 6 13 40 16 6 32 76 54 77 3 5 22 96 22 52 30 16 99 90 34 27 14 86 16 7 72 49 82 9 21 32 59 51 90 93 38 54 52 23 13 89 51 18 96 92 71 3 96 31 74 66 20 52 88 55 95 88 90 56 19 62 68\r\n", "output": ["-1"]}, {"input": "100\r\n58 40 98 67 44 23 88 8 63 52 95 42 28 93 6 24 21 12 94 41 95 65 38 77 17 41 94 99 84 8 5 10 90 48 18 7 72 16 91 82 100 30 73 41 15 70 13 23 39 56 15 74 42 69 10 86 21 91 81 15 86 72 56 19 15 48 28 38 81 96 7 8 90 44 13 99 99 9 70 26 95 95 77 83 78 97 2 74 2 76 97 27 65 68 29 20 97 91 58 28\r\n", "output": ["-1"]}, {"input": "100\r\n99 7 60 94 9 96 38 44 77 12 75 88 47 42 88 95 59 4 12 96 36 16 71 6 26 19 88 63 25 53 90 18 95 82 63 74 6 60 84 88 80 95 66 50 21 8 61 74 61 38 31 19 28 76 94 48 23 80 83 58 62 6 64 7 72 100 94 90 12 63 44 92 32 12 6 66 49 80 71 1 20 87 96 12 56 23 10 77 98 54 100 77 87 31 74 19 42 88 52 17\r\n", "output": ["-1"]}, {"input": "100\r\n36 66 56 95 69 49 32 50 93 81 18 6 1 4 78 49 2 1 87 54 78 70 22 26 95 22 30 54 93 65 74 79 48 3 74 21 88 81 98 89 15 80 18 47 27 52 93 97 57 38 38 70 55 26 21 79 43 30 63 25 98 8 18 9 94 36 86 43 24 96 78 43 54 67 32 84 14 75 37 68 18 30 50 37 78 1 98 19 37 84 9 43 4 95 14 38 73 4 78 39\r\n", "output": ["-1"]}, {"input": "100\r\n37 3 68 45 91 57 90 83 55 17 42 26 23 46 51 43 78 83 12 42 28 17 56 80 71 41 32 82 41 64 56 27 32 40 98 6 60 98 66 82 65 27 69 28 78 57 93 81 3 64 55 85 48 18 73 40 48 50 60 9 63 54 55 7 23 93 22 34 75 18 100 16 44 31 37 85 27 87 69 37 73 89 47 10 34 30 11 80 21 30 24 71 14 28 99 45 68 66 82 81\r\n", "output": ["-1"]}, {"input": "100\r\n98 62 49 47 84 1 77 88 76 85 21 50 2 92 72 66 100 99 78 58 33 83 27 89 71 97 64 94 4 13 17 8 32 20 79 44 12 56 7 9 43 6 26 57 18 23 39 69 30 55 16 96 35 91 11 68 67 31 38 90 40 48 25 41 54 82 15 22 37 51 81 65 60 34 24 14 5 87 74 19 46 3 80 45 61 86 10 28 52 73 29 42 70 53 93 95 63 75 59 36\r\n", "output": ["42"]}, {"input": "100\r\n57 60 40 66 86 52 88 4 54 31 71 19 37 16 73 95 98 77 92 59 35 90 24 96 10 45 51 43 91 63 1 80 14 82 21 29 2 74 99 8 79 76 56 44 93 17 12 33 87 46 72 83 36 49 69 22 3 38 15 13 34 20 42 48 25 28 18 9 50 32 67 84 62 97 68 5 27 65 30 6 81 26 39 41 55 11 70 23 7 53 64 85 100 58 78 75 94 47 89 61\r\n", "output": ["353430"]}, {"input": "100\r\n60 2 18 55 53 58 44 32 26 70 90 4 41 40 25 69 13 73 22 5 16 23 21 86 48 6 99 78 68 49 63 29 35 76 14 19 97 12 9 51 100 31 81 43 52 91 47 95 96 38 62 10 36 46 87 28 20 93 54 27 94 7 11 37 33 61 24 34 72 3 74 82 77 67 8 88 80 59 92 84 56 57 83 65 50 98 75 17 39 71 42 66 15 45 79 64 1 30 89 85\r\n", "output": ["1235"]}, {"input": "100\r\n9 13 6 72 98 70 5 100 26 75 25 87 35 10 95 31 41 80 91 38 61 64 29 71 52 63 24 74 14 56 92 85 12 73 59 23 3 39 30 42 68 47 16 18 8 93 96 67 48 89 53 77 49 62 44 33 83 57 81 55 28 76 34 36 88 37 17 11 40 90 46 84 94 60 4 51 69 21 50 82 97 1 54 2 65 32 15 22 79 27 99 78 20 43 7 86 45 19 66 58\r\n", "output": ["2376"]}, {"input": "100\r\n84 39 28 52 82 49 47 4 88 15 29 38 92 37 5 16 83 7 11 58 45 71 23 31 89 34 69 100 90 53 66 50 24 27 14 19 98 1 94 81 77 87 70 54 85 26 42 51 99 48 10 57 95 72 3 33 43 41 22 97 62 9 40 32 44 91 76 59 2 65 20 61 60 64 78 86 55 75 80 96 93 73 13 68 74 25 35 30 17 8 46 36 67 79 12 21 56 63 6 18\r\n", "output": ["330"]}, {"input": "100\r\n95 66 71 30 14 70 78 75 20 85 10 90 53 9 56 88 38 89 77 4 34 81 33 41 65 99 27 44 61 21 31 83 50 19 58 40 15 47 76 7 5 74 37 1 86 67 43 96 63 92 97 25 59 42 73 60 57 80 62 6 12 51 16 45 36 82 93 54 46 35 94 3 11 98 87 22 69 100 23 48 2 49 28 55 72 8 91 13 68 39 24 64 17 52 18 26 32 29 84 79\r\n", "output": ["1071"]}, {"input": "100\r\n73 21 39 30 78 79 15 46 18 60 2 1 45 35 74 26 43 49 96 59 89 61 34 50 42 84 16 41 92 31 100 64 25 27 44 98 86 47 29 71 97 11 95 62 48 66 20 53 22 83 76 32 77 63 54 99 87 36 9 70 17 52 72 38 81 19 23 65 82 37 24 10 91 93 56 12 88 58 51 33 4 28 8 3 40 7 67 69 68 6 80 13 5 55 14 85 94 75 90 57\r\n", "output": ["7315"]}, {"input": "100\r\n44 43 76 48 53 13 9 60 20 18 82 31 28 26 58 3 85 93 69 73 100 42 2 12 30 50 84 7 64 66 47 56 89 88 83 37 63 68 27 52 49 91 62 45 67 65 90 75 81 72 87 5 38 33 6 57 35 97 77 22 51 23 80 99 11 8 15 71 16 4 92 1 46 70 54 96 34 19 86 40 39 25 36 78 29 10 95 59 55 61 98 14 79 17 32 24 21 74 41 94\r\n", "output": ["290"]}, {"input": "100\r\n31 77 71 33 94 74 19 20 46 21 14 22 6 93 68 54 55 2 34 25 44 90 91 95 61 51 82 64 99 76 7 11 52 86 50 70 92 66 87 97 45 49 39 79 26 32 75 29 83 47 18 62 28 27 88 60 67 81 4 24 3 80 16 85 35 42 9 65 23 15 36 8 12 13 10 57 73 69 48 78 43 1 58 63 38 84 40 56 98 30 17 72 96 41 53 5 37 89 100 59\r\n", "output": ["708"]}, {"input": "100\r\n49 44 94 57 25 2 97 64 83 14 38 31 88 17 32 33 75 81 15 54 56 30 55 66 60 86 20 5 80 28 67 91 89 71 48 3 23 35 58 7 96 51 13 100 39 37 46 85 99 45 63 16 92 9 41 18 24 84 1 29 72 77 27 70 62 43 69 78 36 53 90 82 74 11 34 19 76 21 8 52 61 98 68 6 40 26 50 93 12 42 87 79 47 4 59 10 73 95 22 65\r\n", "output": ["1440"]}, {"input": "100\r\n81 59 48 7 57 38 19 4 31 33 74 66 9 67 95 91 17 26 23 44 88 35 76 5 2 11 32 41 13 21 80 73 75 22 72 87 65 3 52 61 25 86 43 55 99 62 53 34 85 63 60 71 10 27 29 47 24 42 15 40 16 96 6 45 54 93 8 70 92 12 83 77 64 90 56 28 20 97 36 46 1 49 14 100 68 50 51 98 79 89 78 37 39 82 58 69 30 94 84 18\r\n", "output": ["87"]}, {"input": "100\r\n62 50 16 53 19 18 63 26 47 85 59 39 54 92 95 35 71 69 29 94 98 68 37 75 61 25 88 73 36 89 46 67 96 12 58 41 64 45 34 32 28 74 15 43 66 97 70 90 42 13 56 93 52 21 60 20 17 79 49 5 72 83 23 51 2 77 65 55 11 76 91 81 100 44 30 8 4 10 7 99 31 87 82 86 14 9 40 78 22 48 80 38 57 33 24 6 1 3 27 84\r\n", "output": ["777"]}, {"input": "100\r\n33 66 80 63 41 88 39 48 86 68 76 81 59 99 93 100 43 37 11 64 91 22 7 57 87 58 72 60 35 79 18 94 70 25 69 31 3 27 53 30 29 54 83 36 56 55 84 34 51 73 90 95 92 85 47 44 97 5 10 12 65 61 40 98 17 23 1 82 16 50 74 28 24 4 2 52 67 46 78 13 89 77 6 15 8 62 45 32 21 75 19 14 71 49 26 38 20 42 96 9\r\n", "output": ["175"]}, {"input": "100\r\n66 48 77 30 76 54 64 37 20 40 27 21 89 90 23 55 53 22 81 97 28 63 45 14 38 44 59 6 34 78 10 69 75 79 72 42 99 68 29 83 62 33 26 17 46 35 80 74 50 1 85 16 4 56 43 57 88 5 19 51 73 9 94 47 8 18 91 52 86 98 12 32 3 60 100 36 96 49 24 13 67 25 65 93 95 87 61 92 71 82 31 41 84 70 39 58 7 2 15 11\r\n", "output": ["5187"]}, {"input": "100\r\n2 61 67 86 93 56 83 59 68 43 15 20 49 17 46 60 19 21 24 84 8 81 55 31 73 99 72 41 91 47 85 50 4 90 23 66 95 5 11 79 58 77 26 80 40 52 92 74 100 6 82 57 65 14 96 27 32 3 88 16 97 35 30 51 29 38 13 87 76 63 98 18 25 37 48 62 75 36 94 69 78 39 33 44 42 54 9 53 12 70 22 34 89 7 10 64 45 28 1 71\r\n", "output": ["9765"]}, {"input": "100\r\n84 90 51 80 67 7 43 77 9 72 97 59 44 40 47 14 65 42 35 8 85 56 53 32 58 48 62 29 96 92 18 5 60 98 27 69 25 33 83 30 82 46 87 76 70 73 55 21 31 99 50 13 16 34 81 89 22 10 61 78 4 36 41 19 68 64 17 74 28 11 94 52 6 24 1 12 3 66 38 26 45 54 75 79 95 20 2 71 100 91 23 49 63 86 88 37 93 39 15 57\r\n", "output": ["660"]}, {"input": "100\r\n58 66 46 88 94 95 9 81 61 78 65 19 40 17 20 86 89 62 100 14 73 34 39 35 43 90 69 49 55 74 72 85 63 41 83 36 70 98 11 84 24 26 99 30 68 51 54 31 47 33 10 75 7 77 16 28 1 53 67 91 44 64 45 60 8 27 4 42 6 79 76 22 97 92 29 80 82 96 3 2 71 37 5 52 93 13 87 23 56 50 25 38 18 21 12 57 32 59 15 48\r\n", "output": ["324"]}, {"input": "100\r\n9 94 1 12 46 51 77 59 15 34 45 49 8 80 4 35 91 20 52 27 78 36 73 95 58 61 11 79 42 41 5 7 60 40 70 72 74 17 30 19 3 68 37 67 13 29 54 25 26 63 10 71 32 83 99 88 65 97 39 2 33 43 82 75 62 98 44 66 89 81 76 85 92 87 56 31 14 53 16 96 24 23 64 38 48 55 28 86 69 21 100 84 47 6 57 22 90 93 18 50\r\n", "output": ["12870"]}, {"input": "100\r\n40 97 71 53 25 31 50 62 68 39 17 32 88 81 73 58 36 98 64 6 65 33 91 8 74 51 27 28 89 15 90 84 79 44 41 54 49 3 5 10 99 34 82 48 59 13 69 18 66 67 60 63 4 96 26 95 45 76 57 22 14 72 93 83 11 70 56 35 61 16 19 21 1 52 38 43 85 92 100 37 42 23 2 55 87 75 29 80 30 77 12 78 46 47 20 24 7 86 9 94\r\n", "output": ["825"]}, {"input": "100\r\n85 59 62 27 61 12 80 15 1 100 33 84 79 28 69 11 18 92 2 99 56 81 64 50 3 32 17 7 63 21 53 89 54 46 90 72 86 26 51 23 8 19 44 48 5 25 42 14 29 35 55 82 6 83 88 74 67 66 98 4 70 38 43 37 91 40 78 96 9 75 45 95 93 30 68 47 65 34 58 39 73 16 49 60 76 10 94 87 41 71 13 57 97 20 24 31 22 77 52 36\r\n", "output": ["1650"]}, {"input": "100\r\n2 3 1 5 6 7 8 4 10 11 12 13 14 15 9 17 18 19 20 21 22 23 24 25 26 16 28 29 30 31 32 33 34 35 36 37 38 39 27 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 40 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 57 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 76 99 100\r\n", "output": ["111546435"]}, {"input": "26\r\n2 3 1 5 6 7 8 4 10 11 12 13 14 15 9 17 18 19 20 21 22 23 24 25 26 16\r\n", "output": ["1155"]}, {"input": "100\r\n2 1 4 5 3 7 8 9 10 6 12 13 14 15 16 17 11 19 20 21 22 23 24 25 26 27 28 18 30 31 32 33 34 35 36 37 38 39 40 41 29 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 42 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 59 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 78\r\n", "output": ["111546435"]}, {"input": "6\r\n2 3 4 1 6 5\r\n", "output": ["2"]}, {"input": "39\r\n2 3 1 5 6 7 8 4 10 11 12 13 14 15 9 17 18 19 20 21 22 23 24 25 26 16 28 29 30 31 32 33 34 35 36 37 38 39 27\r\n", "output": ["15015"]}, {"input": "15\r\n2 3 4 5 1 7 8 9 10 6 12 13 14 15 11\r\n", "output": ["5"]}, {"input": "98\r\n2 3 1 5 6 7 8 4 10 11 12 13 14 15 9 17 18 19 20 21 22 23 24 25 26 16 28 29 30 31 32 33 34 35 36 37 38 39 27 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 40 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 57 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 76\r\n", "output": ["111546435"]}, {"input": "100\r\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 20 38 39 40 41 42 43 44 45 46 47 48 49 37 51 52 53 54 55 56 57 58 59 60 50 62 63 64 65 66 67 61 69 70 71 72 68 74 75 76 77 78 79 80 81 73 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 82 98 99 100\r\n", "output": ["116396280"]}, {"input": "4\r\n2 3 4 2\r\n", "output": ["-1"]}, {"input": "93\r\n2 3 4 5 1 7 8 9 10 11 12 6 14 15 16 17 18 19 20 21 22 23 13 25 26 27 28 29 30 31 32 33 34 35 36 24 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 37 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 54 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 73\r\n", "output": ["4849845"]}, {"input": "15\r\n2 3 1 5 6 7 8 4 10 11 12 13 14 15 9\r\n", "output": ["105"]}, {"input": "41\r\n2 3 4 5 6 7 8 9 10 11 1 13 14 15 16 17 18 19 20 21 22 23 24 12 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 25\r\n", "output": ["2431"]}, {"input": "100\r\n2 3 1 5 6 7 8 4 10 11 12 13 14 15 9 17 18 19 20 21 22 23 24 25 26 16 28 29 30 31 32 33 34 35 36 37 38 39 27 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 40 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 57 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 76 100 99\r\n", "output": ["111546435"]}, {"input": "24\r\n2 3 1 5 6 7 8 4 10 11 12 13 14 15 9 17 18 19 20 21 22 23 24 16\r\n", "output": ["315"]}, {"input": "90\r\n2 3 1 5 6 7 8 4 10 11 12 13 14 15 9 17 18 19 20 21 22 23 24 25 26 16 28 29 30 31 32 33 34 35 36 37 38 39 27 41 42 43 44 45 46 47 48 49 50 51 52 53 54 40 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 55 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 72\r\n", "output": ["4849845"]}, {"input": "99\r\n2 3 1 5 6 7 8 4 10 11 12 13 14 15 9 17 18 19 20 21 22 23 24 16 26 27 28 29 30 31 32 33 34 35 25 37 38 39 40 41 42 43 44 45 46 47 48 36 50 51 52 53 54 55 56 57 58 59 60 61 62 63 49 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 64 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 81\r\n", "output": ["14549535"]}, {"input": "75\r\n2 3 1 5 6 7 8 4 10 11 12 13 14 15 9 17 18 19 20 21 22 23 24 25 26 16 28 29 30 31 32 33 34 35 36 37 38 39 27 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 40 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 57\r\n", "output": ["4849845"]}, {"input": "9\r\n2 3 4 5 6 7 8 9 1\r\n", "output": ["9"]}, {"input": "26\r\n2 3 1 5 6 7 8 4 10 11 12 13 14 15 9 26 16 17 18 19 20 21 22 23 24 25\r\n", "output": ["1155"]}, {"input": "99\r\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 1 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 51\r\n", "output": ["1225"]}, {"input": "96\r\n2 3 1 5 6 7 8 4 10 11 12 13 14 15 9 17 18 19 20 21 22 23 24 25 26 16 28 29 30 31 32 33 34 35 36 37 38 39 27 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 40 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 57 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 76\r\n", "output": ["4849845"]}, {"input": "100\r\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 18 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 37 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 57 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 78\r\n", "output": ["1560090"]}, {"input": "48\r\n2 3 1 5 6 7 8 4 10 11 12 13 14 15 9 17 18 19 20 21 22 23 24 16 26 27 28 29 30 31 32 33 34 35 25 37 38 39 40 41 42 43 44 45 46 47 48 36\r\n", "output": ["45045"]}, {"input": "100\r\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1\r\n", "output": ["50"]}, {"input": "12\r\n2 3 4 5 1 7 8 9 10 11 12 6\r\n", "output": ["35"]}, {"input": "12\r\n2 3 4 1 6 7 8 9 10 11 12 5\r\n", "output": ["4"]}, {"input": "100\r\n2 1 5 3 4 10 6 7 8 9 17 11 12 13 14 15 16 28 18 19 20 21 22 23 24 25 26 27 41 29 30 31 32 33 34 35 36 37 38 39 40 58 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 77 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 100 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99\r\n", "output": ["111546435"]}, {"input": "100\r\n2 3 4 5 6 7 8 9 10 11 1 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 12 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 29 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 48 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 71 100\r\n", "output": ["2369851"]}]
100
100
100
[{'input': '100\r\n74 71 86 6 75 16 62 25 95 45 29 36 97 5 8 78 26 69 56 57 60 15 55 87 14 23 68 11 31 47 3 24 7 54 49 80 33 76 30 65 4 53 93 20 37 84 35 1 66 40 46 17 12 73 42 96 38 2 32 72 58 51 90 22 99 89 88 21 85 28 63 10 92 18 61 98 27 19 81 48 34 94 50 83 59 77 9 44 79 43 39 100 82 52 70 41 67 13 64 91\r\n', 'output': ['4020']}, {'input': '39\r\n2 3 1 5 6 7 8 4 10 11 12 13 14 15 9 17 18 19 20 21 22 23 24 25 26 16 28 29 30 31 32 33 34 35 36 37 38 39 27\r\n', 'output': ['15015']}, {'input': '100\r\n53 12 13 98 57 83 52 61 69 54 13 92 91 27 16 91 86 75 93 29 16 59 14 2 37 74 34 30 98 17 3 72 83 93 21 72 52 89 57 58 60 29 94 16 45 20 76 64 78 67 76 68 41 47 50 36 9 75 79 11 10 88 71 22 36 60 44 19 79 43 49 24 6 57 8 42 51 58 60 2 84 48 79 55 74 41 89 10 45 70 76 29 53 9 82 93 24 40 94 56\r\n', 'output': ['-1']}, {'input': '100\r\n83 4 84 100 21 83 47 79 11 78 40 33 97 68 5 46 93 23 54 93 61 67 88 8 91 11 46 10 48 39 95 29 81 36 71 88 45 64 90 43 52 49 59 57 45 83 74 89 22 67 46 2 63 84 20 30 51 26 70 84 35 70 21 86 88 79 7 83 13 56 74 54 83 96 31 57 91 69 60 43 12 34 31 23 70 48 96 58 20 36 87 17 39 100 31 69 21 54 49 42\r\n', 'output': ['-1']}, {'input': '100\r\n40 97 71 53 25 31 50 62 68 39 17 32 88 81 73 58 36 98 64 6 65 33 91 8 74 51 27 28 89 15 90 84 79 44 41 54 49 3 5 10 99 34 82 48 59 13 69 18 66 67 60 63 4 96 26 95 45 76 57 22 14 72 93 83 11 70 56 35 61 16 19 21 1 52 38 43 85 92 100 37 42 23 2 55 87 75 29 80 30 77 12 78 46 47 20 24 7 86 9 94\r\n', 'output': ['825']}]
[{'input': '100\r\n98 62 49 47 84 1 77 88 76 85 21 50 2 92 72 66 100 99 78 58 33 83 27 89 71 97 64 94 4 13 17 8 32 20 79 44 12 56 7 9 43 6 26 57 18 23 39 69 30 55 16 96 35 91 11 68 67 31 38 90 40 48 25 41 54 82 15 22 37 51 81 65 60 34 24 14 5 87 74 19 46 3 80 45 61 86 10 28 52 73 29 42 70 53 93 95 63 75 59 36\r\n', 'output': ['42']}, {'input': '41\r\n2 3 4 5 6 7 8 9 10 11 1 13 14 15 16 17 18 19 20 21 22 23 24 12 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 25\r\n', 'output': ['2431']}, {'input': '100\r\n57 60 40 66 86 52 88 4 54 31 71 19 37 16 73 95 98 77 92 59 35 90 24 96 10 45 51 43 91 63 1 80 14 82 21 29 2 74 99 8 79 76 56 44 93 17 12 33 87 46 72 83 36 49 69 22 3 38 15 13 34 20 42 48 25 28 18 9 50 32 67 84 62 97 68 5 27 65 30 6 81 26 39 41 55 11 70 23 7 53 64 85 100 58 78 75 94 47 89 61\r\n', 'output': ['353430']}, {'input': '12\r\n2 3 4 5 1 7 8 9 10 11 12 6\r\n', 'output': ['35']}, {'input': '9\r\n2 3 4 5 6 7 8 9 1\r\n', 'output': ['9']}]
[{'input': '100\r\n58 40 98 67 44 23 88 8 63 52 95 42 28 93 6 24 21 12 94 41 95 65 38 77 17 41 94 99 84 8 5 10 90 48 18 7 72 16 91 82 100 30 73 41 15 70 13 23 39 56 15 74 42 69 10 86 21 91 81 15 86 72 56 19 15 48 28 38 81 96 7 8 90 44 13 99 99 9 70 26 95 95 77 83 78 97 2 74 2 76 97 27 65 68 29 20 97 91 58 28\r\n', 'output': ['-1']}, {'input': '100\r\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100\r\n', 'output': ['1']}, {'input': '100\r\n57 60 40 66 86 52 88 4 54 31 71 19 37 16 73 95 98 77 92 59 35 90 24 96 10 45 51 43 91 63 1 80 14 82 21 29 2 74 99 8 79 76 56 44 93 17 12 33 87 46 72 83 36 49 69 22 3 38 15 13 34 20 42 48 25 28 18 9 50 32 67 84 62 97 68 5 27 65 30 6 81 26 39 41 55 11 70 23 7 53 64 85 100 58 78 75 94 47 89 61\r\n', 'output': ['353430']}, {'input': '100\r\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 18 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 37 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 57 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 78\r\n', 'output': ['1560090']}, {'input': '41\r\n2 3 4 5 6 7 8 9 10 11 1 13 14 15 16 17 18 19 20 21 22 23 24 12 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 25\r\n', 'output': ['2431']}]
[{'input': '100\r\n35 12 51 32 59 98 65 84 34 83 75 72 35 31 17 55 35 84 6 46 23 74 81 98 61 9 39 40 6 15 44 79 98 3 45 41 64 56 4 27 62 27 68 80 99 21 32 26 60 82 5 1 98 75 49 26 60 25 57 18 69 88 51 64 74 97 81 78 62 32 68 77 48 71 70 64 17 1 77 25 95 68 33 80 11 55 18 42 24 73 51 55 82 72 53 20 99 15 34 54\r\n', 'output': ['-1']}, {'input': '12\r\n2 3 4 5 1 7 8 9 10 11 12 6\r\n', 'output': ['35']}, {'input': '41\r\n2 3 4 5 6 7 8 9 10 11 1 13 14 15 16 17 18 19 20 21 22 23 24 12 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 25\r\n', 'output': ['2431']}, {'input': '4\r\n2 1 4 3\r\n', 'output': ['1']}, {'input': '100\r\n88 41 92 79 21 91 44 2 27 96 9 64 73 87 45 13 39 43 16 42 99 54 95 5 75 1 48 4 15 47 34 71 76 62 17 70 81 80 53 90 67 3 38 58 32 25 29 63 6 50 51 14 37 97 24 52 65 40 31 98 100 77 8 33 61 11 49 84 89 78 56 20 94 35 86 46 85 36 82 93 7 59 10 60 69 57 12 74 28 22 30 66 18 68 72 19 26 83 23 55\r\n', 'output': ['360']}]
[{'input': '100\r\n73 21 39 30 78 79 15 46 18 60 2 1 45 35 74 26 43 49 96 59 89 61 34 50 42 84 16 41 92 31 100 64 25 27 44 98 86 47 29 71 97 11 95 62 48 66 20 53 22 83 76 32 77 63 54 99 87 36 9 70 17 52 72 38 81 19 23 65 82 37 24 10 91 93 56 12 88 58 51 33 4 28 8 3 40 7 67 69 68 6 80 13 5 55 14 85 94 75 90 57\r\n', 'output': ['7315']}, {'input': '100\r\n40 86 93 77 68 5 32 77 1 79 68 33 29 36 38 3 69 46 72 7 27 27 30 40 21 18 69 69 32 10 82 97 1 34 87 81 92 67 47 3 52 89 25 41 88 79 5 46 41 82 87 1 77 41 54 16 6 92 18 10 37 45 71 25 16 66 39 94 60 13 48 64 28 91 80 36 4 53 50 28 30 45 92 79 93 71 96 66 65 73 57 71 48 78 76 53 96 76 81 89\r\n', 'output': ['-1']}, {'input': '100\r\n98 39 44 79 31 99 96 72 97 54 83 15 81 65 59 75 3 51 83 40 28 54 41 93 56 94 93 58 20 53 21 7 81 17 71 31 31 88 34 22 55 67 57 92 34 88 87 23 36 33 41 33 17 10 71 28 79 6 3 60 67 99 68 8 39 29 49 17 82 43 100 86 64 47 55 66 58 57 50 49 8 11 15 91 42 44 72 28 18 32 81 22 20 78 55 51 37 94 34 4\r\n', 'output': ['-1']}, {'input': '4\r\n2 3 4 2\r\n', 'output': ['-1']}, {'input': '100\r\n60 2 18 55 53 58 44 32 26 70 90 4 41 40 25 69 13 73 22 5 16 23 21 86 48 6 99 78 68 49 63 29 35 76 14 19 97 12 9 51 100 31 81 43 52 91 47 95 96 38 62 10 36 46 87 28 20 93 54 27 94 7 11 37 33 61 24 34 72 3 74 82 77 67 8 88 80 59 92 84 56 57 83 65 50 98 75 17 39 71 42 66 15 45 79 64 1 30 89 85\r\n', 'output': ['1235']}]
100
100
100
100
100
100
91.67
100
100
100
100
88.89
100
100
100
155
100
98.334
97.778
["4 4\n....\n.S1.\n....\n....\n10", "7 7\n.......\n.1###2.\n.#...#.\n.#.B.#.\n.3...4.\n..##...\n......S\n100\n100\n100\n100", "7 8\n........\n........\n....1B..\n.S......\n....2...\n3.......\n........\n100\n-100\n100", "1 1\nS"]
The first line contains two integers n and m (1 ≤ n, m ≤ 20) — the sizes of the table. Next n lines each contains m characters — the description of the table. The description means the following: character "B" is a cell with a bomb; character "S" is the starting cell, you can assume that it's empty; digit c (1-8) is treasure with index c; character "." is an empty cell; character "#" is an obstacle. Assume that the map has t treasures. Next t lines contain the prices of the treasures. The i-th line contains the price of the treasure with index i, vi ( - 200 ≤ vi ≤ 200). It is guaranteed that the treasures are numbered from 1 to t. It is guaranteed that the map has not more than 8 objects in total. Objects are bombs and treasures. It is guaranteed that the map has exactly one character "S".
624a0d6cf305fcf67d3f1cdc1c5fef8d
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; const int dx[]={1,-1,0,0}; const int dy[]={0,0,1,-1}; const int INF=1000000000; int n,m,sx,sy,tx[10],ty[10],tp[10],tn,bx[10],by[10],bn; int f[21][21][256][256],pr[256],ans; int qx[2000010],qy[2000010],qt[2000010],qb[2000010],l,r; char a[51][51]; int main() { scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) scanf("%s",a[i]+1); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) { if(a[i][j]=='S') sx=i,sy=j; if(a[i][j]>='0'&&a[i][j]<='9') tx[a[i][j]-'0']=i,ty[a[i][j]-'0']=j,tn++; if(a[i][j]=='B') bx[++bn]=i,by[bn]=j; } for(int i=1;i<=tn;i++) scanf("%d",&tp[i]); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<(1<<tn);k++) for(int l=0;l<(1<<bn);l++) f[i][j][k][l]=INF; l=r=1; qx[1]=sx,qy[1]=sy,qt[1]=0,qb[1]=0; f[sx][sy][0][0]=0; while(l<=r) { int ox=qx[l],oy=qy[l],ot=qt[l],ob=qb[l++]; for(int k=0;k<4;k++) { int nx=ox+dx[k],ny=oy+dy[k],nt=ot,nb=ob; if(a[nx][ny]!='.'&&a[nx][ny]!='S') continue; for(int i=1;i<=tn;i++) { if(ny<=ty[i]) continue; if(nx==tx[i]-1&&ox==tx[i]) nt^=(1<<(i-1)); if(ox==tx[i]-1&&nx==tx[i]) nt^=(1<<(i-1)); } for(int i=1;i<=bn;i++) { if(ny<=by[i]) continue; if(nx==bx[i]-1&&ox==bx[i]) nb^=(1<<(i-1)); if(ox==bx[i]-1&&nx==bx[i]) nb^=(1<<(i-1)); } if(f[nx][ny][nt][nb]>f[ox][oy][ot][ob]+1) f[nx][ny][nt][nb]=f[ox][oy][ot][ob]+1,qx[++r]=nx,qy[r]=ny,qt[r]=nt,qb[r]=nb; } } for(int i=0;i<(1<<tn);i++) for(int j=1;j<=tn;j++) if(i&(1<<(j-1))) pr[i]+=tp[j]; for(int i=0;i<(1<<tn);i++) ans=max(ans,pr[i]-f[sx][sy][i][0]); printf("%d\n",ans); return 0; }
["2", "364", "0", "0"]
C++
NoteIn the first example the answer will look as follows. In the second example the answer will look as follows. In the third example you cannot get profit.In the fourth example you cannot get profit as you cannot construct a closed path with more than one cell.
Print a single integer — the maximum possible profit you can get.
You have a map as a rectangle table. Each cell of the table is either an obstacle, or a treasure with a certain price, or a bomb, or an empty cell. Your initial position is also given to you.You can go from one cell of the map to a side-adjacent one. At that, you are not allowed to go beyond the borders of the map, enter the cells with treasures, obstacles and bombs. To pick the treasures, you need to build a closed path (starting and ending in the starting cell). The closed path mustn't contain any cells with bombs inside. Let's assume that the sum of the treasures' values that are located inside the closed path equals v, and besides, you've made k single moves (from one cell to another) while you were going through the path, then such path brings you the profit of v - k rubles.Your task is to build a closed path that doesn't contain any bombs and brings maximum profit.Note that the path can have self-intersections. In order to determine if a cell lies inside a path or not, use the following algorithm: Assume that the table cells are points on the plane (the table cell on the intersection of the i-th column and the j-th row is point (i, j)). And the given path is a closed polyline that goes through these points. You need to find out if the point p of the table that is not crossed by the polyline lies inside the polyline. Let's draw a ray that starts from point p and does not intersect other points of the table (such ray must exist). Let's count the number of segments of the polyline that intersect the painted ray. If this number is odd, we assume that point p (and consequently, the table cell) lie inside the polyline (path). Otherwise, we assume that it lies outside.
[{"input": "4 4\r\n....\r\n.S1.\r\n....\r\n....\r\n10\r\n", "output": ["2"]}, {"input": "7 7\r\n.......\r\n.1###2.\r\n.#...#.\r\n.#.B.#.\r\n.3...4.\r\n..##...\r\n......S\r\n100\r\n100\r\n100\r\n100\r\n", "output": ["364"]}, {"input": "7 8\r\n........\r\n........\r\n....1B..\r\n.S......\r\n....2...\r\n3.......\r\n........\r\n100\r\n-100\r\n100\r\n", "output": ["0"]}, {"input": "1 1\r\nS\r\n", "output": ["0"]}, {"input": "10 11\r\n..#...#.#.#\r\n#..##.#####\r\n7#.#5.#####\r\n..##.##.###\r\n#.3##.##...\r\n###.#.##1.#\r\n.#....#..##\r\n.###.######\r\n##42.#S#..#\r\n...####.#.6\r\n-31\r\n30\r\n-6\r\n-12\r\n-30\r\n1\r\n55\r\n", "output": ["0"]}, {"input": "10 11\r\n.....#1..##\r\n..#3..#S#.#\r\n........#..\r\n..##...7...\r\n....#.#.#..\r\n.#...#.#.65\r\n.#...##.#2.\r\n......#..##\r\n#.4.......#\r\n.#...#.#...\r\n0\r\n-36\r\n1\r\n56\r\n57\r\n-31\r\n-16\r\n", "output": ["0"]}, {"input": "10 11\r\n........S..\r\n...........\r\n5........1.\r\n.7#........\r\n...64.#....\r\n...........\r\n..........#\r\n.2.........\r\n.....3.....\r\n...........\r\n-9\r\n33\r\n9\r\n-20\r\n12\r\n10\r\n-29\r\n", "output": ["8"]}, {"input": "10 11\r\n#....1#....\r\n.#.5.#.3S#.\r\n###.##...##\r\n###.#......\r\n.#.#..#.#..\r\n#..2.#.####\r\n...#..#7##.\r\n#4.##..#.6.\r\n.#......#..\r\n...#..##...\r\n55\r\n-13\r\n44\r\n46\r\n22\r\n-26\r\n56\r\n", "output": ["0"]}, {"input": "10 11\r\n#......#..4\r\n#.#..##....\r\n##.....##.#\r\n#1..#....##\r\n..#.#.#.#.#\r\n##..#6.#.##\r\n#7#...2..#5\r\n..#.#.#....\r\n.#..S.#3.#.\r\n..###.##.##\r\n-33\r\n-39\r\n58\r\n20\r\n33\r\n54\r\n-25\r\n", "output": ["0"]}, {"input": "10 11\r\n.....##.##.\r\n#.#.#.S..#.\r\n....#....##\r\n.3.##.2.7..\r\n.#..#....4#\r\n#.####..#.#\r\n...#....5.#\r\n.6.##...#.#\r\n..##..#..##\r\n.#1##..#.##\r\n38\r\n-37\r\n-2\r\n-27\r\n29\r\n47\r\n-14\r\n", "output": ["0"]}, {"input": "10 11\r\n..##.#..#.1\r\n##.##..#...\r\n..###.#..#.\r\n#...5#.3.##\r\n##6#.#...#.\r\nS.##4#...##\r\n###.#......\r\n.#..#..#...\r\n..#..#7.###\r\n#.....#.2..\r\n11\r\n5\r\n59\r\n19\r\n1\r\n-23\r\n-11\r\n", "output": ["0"]}, {"input": "10 11\r\n###..#..##7\r\n..#.#.4#.##\r\n......5...#\r\n.#.1#......\r\n.#.#.......\r\n.#....#.#..\r\n##.######62\r\n##...#3....\r\n.#.#..#..##\r\nS....##..#.\r\n-6\r\n-23\r\n-15\r\n12\r\n40\r\n-3\r\n30\r\n", "output": ["0"]}, {"input": "10 11\r\n...........\r\n...........\r\n.#.B.......\r\n......1#...\r\n...........\r\n....B......\r\n...B...#...\r\n.......#.2.\r\n....B......\r\n...#.....#S\r\n50\r\n-1\r\n", "output": ["26"]}, {"input": "10 11\r\n.3.....#...\r\n...........\r\n....6#.....\r\n#..........\r\n...#.7.....\r\n.S.......5.\r\n........4..\r\n#...#..2...\r\n...........\r\n..........1\r\n2\r\n56\r\n45\r\n-34\r\n29\r\n26\r\n-17\r\n", "output": ["41"]}, {"input": "10 11\r\n...........\r\n.....#.#..#\r\n...#.4#....\r\n##.1.......\r\n#....3.##.#\r\n..6....#...\r\n#.##...#.S.\r\n.#......#7.\r\n....5.#2...\r\n...#.......\r\n9\r\n28\r\n56\r\n-14\r\n32\r\n-12\r\n15\r\n", "output": ["76"]}, {"input": "10 11\r\n###.#4.#.#.\r\n#.....#.#.#\r\n.#..#####..\r\n#.#..#6.##.\r\n#..23##..##\r\n##..##....#\r\n#..##....7.\r\n#.###.#.#.#\r\n#.S##5#..#1\r\n###.#..##..\r\n4\r\n15\r\n30\r\n-18\r\n-30\r\n38\r\n40\r\n", "output": ["0"]}, {"input": "10 11\r\n1#.7###....\r\n###.#####5#\r\n#.#.#.####.\r\n.###..###..\r\n.#3#...#.#.\r\n.###4##....\r\n##.#..#.2..\r\n#..#.##6#..\r\n.#.########\r\n##.S...###.\r\n34\r\n57\r\n1\r\n53\r\n-24\r\n11\r\n-38\r\n", "output": ["0"]}, {"input": "10 11\r\n.#.3.#.....\r\n.........1.\r\n.......5#..\r\n#..#..##...\r\n...#.....4.\r\n2..........\r\n....6....7.\r\n......#....\r\n.........#.\r\n...S.......\r\n49\r\n-37\r\n58\r\n-17\r\n33\r\n9\r\n-17\r\n", "output": ["59"]}, {"input": "10 11\r\n##....##2#.\r\n##...#.###.\r\n...#.......\r\n...#.#.#.#.\r\n.#.###..#5.\r\n#..#S#.#...\r\n#3#.7##.###\r\n#.#.####.#.\r\n#.###.64#1.\r\n.#.#..#.##.\r\n-33\r\n52\r\n-4\r\n-32\r\n-3\r\n29\r\n-27\r\n", "output": ["0"]}, {"input": "10 11\r\n...#...##.#\r\n........##.\r\n5.#..#.S.#.\r\n#..........\r\n.....#..#.7\r\n6...4......\r\n#..3###2.#.\r\n.#...##.##.\r\n.#.#...1...\r\n.....#.#...\r\n-34\r\n38\r\n1\r\n-8\r\n58\r\n50\r\n50\r\n", "output": ["0"]}, {"input": "10 11\r\n##.#.###.#.\r\n.1###.#.5##\r\n##.....#.##\r\n#.#.#######\r\n#4#7##.##.#\r\n.###.###.#.\r\n..#S.#.####\r\n..2###.####\r\n.....##..6#\r\n.3##..###..\r\n50\r\n-21\r\n-6\r\n5\r\n29\r\n56\r\n42\r\n", "output": ["0"]}, {"input": "10 11\r\n62.#.#.1.#.\r\n#####..##..\r\n..#.##.#.##\r\n####.#..#.S\r\n7.#.#.#####\r\n....##.##.#\r\n####.##.#.#\r\n.#...##.###\r\n..#3....#..\r\n.....5.#..4\r\n6\r\n40\r\n-21\r\n14\r\n19\r\n5\r\n1\r\n", "output": ["0"]}, {"input": "10 11\r\n..#.##.1...\r\n##.#..##6#.\r\n..#.#..#..4\r\n.....S.#.#.\r\n#####.#.##.\r\n7#####.5###\r\n#3..##.....\r\n#..#.#...2.\r\n.###...##.#\r\n.#....#.#.#\r\n-18\r\n1\r\n-8\r\n-7\r\n-27\r\n13\r\n15\r\n", "output": ["0"]}, {"input": "20 20\r\n....................\r\n....................\r\n....................\r\n....................\r\n....................\r\n.........6..........\r\n..........5.........\r\n...................8\r\n....................\r\n....................\r\n...............7....\r\n....................\r\n....3...............\r\n..............4.....\r\n2...................\r\n....................\r\n....1...............\r\n....................\r\n....................\r\nS...................\r\n1\r\n200\r\n30\r\n20\r\n34\r\n-2\r\n15\r\n100\r\n", "output": ["36"]}, {"input": "10 11\r\n.#.1....#..\r\n#.........#\r\n4..##..5..#\r\n6.##......#\r\n.3...#.7...\r\n....#......\r\n##...#.....\r\n..#S.#.##.#\r\n.#......#..\r\n#.....#.2#.\r\n34\r\n41\r\n47\r\n-7\r\n19\r\n36\r\n47\r\n", "output": ["42"]}, {"input": "20 20\r\n..#.....#..#........\r\n....##.##..#..#.#...\r\n....#.#...#..#.#.#..\r\n.#.........#........\r\n........#.#.#.#..#.#\r\n.....#...6..........\r\n.#.#.#....5.....#...\r\n.#..#.##...#....##.8\r\n...##.#......#.....#\r\n.#.##.......#.....#.\r\n..#......##....7.#.#\r\n....#...#...#...#.#.\r\n..#.3...............\r\n...##.#.#.....4#...#\r\n2...................\r\n.##....#......#.....\r\n##..1..........#....\r\n......##....##....##\r\n..#............#..#.\r\nS.................#.\r\n30\r\n80\r\n70\r\n60\r\n34\r\n-22\r\n15\r\n100\r\n", "output": ["106"]}, {"input": "20 20\r\n#..#.....#.#.#......\r\n...#...##.7.........\r\n........#..#.......#\r\n.......#.....#.....#\r\n.......#......#.....\r\n..#.........#......#\r\n...#.#..#.#...#....#\r\n...##....6...#...1..\r\n.............#.....S\r\n.......5.....#......\r\n......#........#.#..\r\n.....#..#..#...#....\r\n..#......#.##.......\r\n.#..................\r\n#...................\r\n.....#.#....8...3...\r\n#....4#..#..........\r\n....#.....##.....#.#\r\n##2..........#......\r\n#.#..#..#......#....\r\n86\r\n-14\r\n65\r\n54\r\n27\r\n53\r\n33\r\n63\r\n", "output": ["288"]}, {"input": "20 20\r\n.#....#...###..##...\r\n#...#..####.#.#...#.\r\n.#.#...###.##.......\r\n##....#.##...##...##\r\n...#.##........#4..#\r\n....###.....##...#.#\r\n..#.#..#.##..###....\r\n.........8....#.....\r\n.##..#..#.####..#.#.\r\n.##.#......##..##...\r\n..####..#..#...#...5\r\n...#....#..##.....##\r\n.#.....#....7....#.#\r\n#S....###...###..##.\r\n#..#.#.#..#6..##.#..\r\n2..........#..##..#1\r\n..#...###....####..#\r\n........#.#3...##...\r\n##.####...#...#.#...\r\n.......#....#.#.....\r\n-16\r\n93\r\n-23\r\n7\r\n12\r\n85\r\n51\r\n10\r\n", "output": ["0"]}, {"input": "20 20\r\n#..#....#.#....###..\r\n#.....#.....##....##\r\n#.###........##.....\r\n#..####.#.##...#.#..\r\n.##....#.....#5...#.\r\n.....#####1.###.#..#\r\n#.###...#..##.6.....\r\n#4.#.#.....8..#.####\r\n##.#....#.....3#.##.\r\n#..##........##.....\r\n.#.#..####2......#..\r\n.#.#......##.##.#...\r\n#....##.#.###..#...#\r\n.#.#.##.#..##.#.#...\r\n....#.##..#..#.##.##\r\n.#.......7###....#.#\r\n..##.##....#.##....#\r\n####....#...#..#.#..\r\n#.#.#.#.##.....###.#\r\n####........###.#S#.\r\n0\r\n78\r\n27\r\n78\r\n-25\r\n47\r\n-19\r\n84\r\n", "output": ["0"]}, {"input": "20 20\r\n...##...#..#...3.#..\r\n.......##4#.##.#.##.\r\n...#....#....#....#.\r\n.##...#.#.##.###.#..\r\n.##......5...#....##\r\n.#..#.#.#.#.......1.\r\n##.##..#.##.#..#...S\r\n....#.....#.##......\r\n...2...#........#..#\r\n..8#....#.##...#.#..\r\n.....7.#..#.....#...\r\n.#...##......#.#.6..\r\n......#...###..#...#\r\n....#..#............\r\n......#..#.#....#...\r\n#....##.#....#......\r\n.##.......###.#.##.#\r\n..#.....####.#..#...\r\n#...#...#..##.....#.\r\n.......#.#.#..#.#.#.\r\n58\r\n83\r\n96\r\n66\r\n69\r\n60\r\n7\r\n10\r\n", "output": ["96"]}, {"input": "20 20\r\n....###.......#.#...\r\n.....##......#.#....\r\n##.##........##.....\r\n.#..........#....#..\r\n#......#..#.....##..\r\n##.#......#...#.....\r\n5.#.#..##.......2...\r\n#....###..#.....#...\r\n....#.#....#......#.\r\n.#....#......#....#.\r\n...S#......#........\r\n3...#..#.##.6#..#..#\r\n.......##.7....##...\r\n#...#...#.##..#..#8#\r\n........###..#......\r\n....#..#....#...#...\r\n#.#..#..#.......4...\r\n#.#..#.......#...1..\r\n.#...#.#..#.###.##..\r\n#....##.......##....\r\n55\r\n-12\r\n-18\r\n46\r\n43\r\n78\r\n52\r\n82\r\n", "output": ["90"]}, {"input": "20 20\r\n.....#........#.....\r\n...#.2...1..........\r\n...........#........\r\n..#.................\r\n..#............7...#\r\n..#...#.............\r\n..................#.\r\n#...................\r\n....................\r\n..#.....#.....#.....\r\n.S......#......#....\r\n....................\r\n#.#...45.....8......\r\n....................\r\n....................\r\n.........#........#.\r\n.......6...#........\r\n....#..#............\r\n.#..............3...\r\n...........#........\r\n69\r\n17\r\n65\r\n58\r\n46\r\n-14\r\n82\r\n84\r\n", "output": ["334"]}, {"input": "4 4\r\n....\r\n.S1.\r\n...#\r\n....\r\n10\r\n", "output": ["0"]}, {"input": "20 20\r\n..........#.....1...\r\n...........#.#......\r\n........#.......S.#.\r\n.....2.....#...#.3..\r\n...#......4.........\r\n..6.................\r\n...........#.....8..\r\n................#...\r\n....................\r\n....................\r\n....................\r\n......#.............\r\n....................\r\n..5.................\r\n7................#..\r\n....................\r\n..............#.....\r\n..........#.........\r\n....................\r\n.....#.........#....\r\n57\r\n4\r\n49\r\n22\r\n32\r\n-7\r\n-2\r\n57\r\n", "output": ["100"]}, {"input": "20 20\r\n.#.......#..#.#....#\r\n...#........#.#..#..\r\n#.##....##.#.....#3.\r\n.#..#.#....#......##\r\n..###......#.....#..\r\n..#..#..1#.6........\r\n..###...#.....#...##\r\n.......#..##...#....\r\n........#...#..##...\r\n.###..#.....2..#....\r\n#.....#.#.###...#...\r\n.....#.#.###........\r\n....#.#...#.........\r\n.......##...4.#.....\r\n..#8.............#..\r\n#..#...#...S#.......\r\n.........#.#........\r\n....7##......#.##...\r\n#.............#.#...\r\n#...#.5.#...........\r\n63\r\n94\r\n82\r\n96\r\n44\r\n38\r\n79\r\n16\r\n", "output": ["296"]}, {"input": "20 20\r\n..4..#.....#.3#.##..\r\n##.......#..........\r\n.#........#..#......\r\n.#........#..S...6#.\r\n..#.#72...........#.\r\n..........##.####.##\r\n......#.............\r\n###.#......#.#......\r\n##.....#.##..#...##.\r\n..##...#..........#.\r\n...8#...#....##...#.\r\n...#..#.....#.....#.\r\n.#...#..#..#.....#.#\r\n.#.##.......##.##...\r\n.###....#.#....#.#..\r\n#.....#......#..5..#\r\n.1..#.....#.#.#...#.\r\n.#............#.#...\r\n....#...#.....##.#.#\r\n#.#....#.....#......\r\n4\r\n62\r\n87\r\n30\r\n90\r\n79\r\n91\r\n28\r\n", "output": ["127"]}, {"input": "20 20\r\n...#........##......\r\n......#......#...#..\r\n##..................\r\n......6....#........\r\n..#.................\r\n.7........##.....#..\r\n....5.....#....#....\r\n.#........#.......#.\r\n.............#......\r\n....................\r\n.#...............8..\r\n..#.........4..#....\r\n....#.........#.....\r\n...........#....S...\r\n.........#..........\r\n........#.........#.\r\n..................##\r\n.##.....#.#3..1....2\r\n.....#....#...#..#..\r\n..........#.........\r\n13\r\n96\r\n50\r\n87\r\n36\r\n-20\r\n22\r\n50\r\n", "output": ["140"]}, {"input": "20 20\r\n......#...##........\r\n......#..#.#.##.##.#\r\n.....##.##.#.##.###.\r\n.#...#.#.##...#....#\r\n...3#.#.#..#..4..#..\r\n...#.........##..#..\r\n.....#.##..#........\r\n.......#..#.#....#..\r\n......#.##......#.#.\r\n#..#...#....###.S...\r\n....#...........##..\r\n.....#.#..#.....#...\r\n#..#....#..##.#...5#\r\n.##......#.#..#.#..#\r\n.....#....#.....#7.#\r\n..#......#...###.#..\r\n...##...2#.1#..#.#..\r\n.###...........#...#\r\n..#..##...#8........\r\n.....#.#.....6..###.\r\n-13\r\n40\r\n37\r\n36\r\n52\r\n62\r\n52\r\n-22\r\n", "output": ["51"]}, {"input": "20 20\r\n........#...........\r\n...#.......#.#.....#\r\n....................\r\n.#........#.........\r\n....................\r\n..#....#.3..........\r\n.....#..#......#....\r\n....#..............1\r\n.#.........#.....##.\r\n#2..................\r\n.............#......\r\n..#.................\r\n......8..........##.\r\n...........7........\r\n...................4\r\n........#.........5S\r\n...........#........\r\n.....#...........#..\r\n..................6.\r\n....................\r\n25\r\n-21\r\n-2\r\n27\r\n49\r\n-23\r\n6\r\n45\r\n", "output": ["11"]}, {"input": "20 20\r\n.#................#.\r\n.#...#####.#..#.##.S\r\n5#....#..#.#.#.##..#\r\n.#.....##.#.#...#..#\r\n......####.##.##.#..\r\n##....#....#........\r\n..#...#........#...#\r\n.#..#.###..#.##.##.#\r\n.#4...##........#.#.\r\n..#.........#.......\r\n....##.#.....#.###..\r\n.8..#....#.#........\r\n#..#....###....###3#\r\n#...#.#.###..##....7\r\n...#..........##.#..\r\n...6.#.........#....\r\n..#.##.##.....#..##.\r\n.......#........##1.\r\n.#....###......#...#\r\n......#....##2#.....\r\n16\r\n33\r\n-14\r\n4\r\n-5\r\n-16\r\n66\r\n54\r\n", "output": ["0"]}, {"input": "20 20\r\n.#.##.##...#.####...\r\n.#.#.......#......#.\r\n#.#...#.....#......#\r\n.##.8.##.#....##..##\r\n##..#..#.#.#....#.##\r\n##.#.#####.#.#.#...#\r\n.....4.###...###.#.#\r\n##.####.##.#.#...#..\r\n.#..#.##..#.#..#....\r\n..#.#.##...##..#....\r\n#..##..#..#.....#.##\r\n...#.##....#####...#\r\n...6#5..#....#......\r\n###...#.#.#..##.....\r\n#..#....##.##.###..#\r\n..#.##...##..#######\r\n.#.##.2#.3.....#..##\r\n#....#.#7#.##.#....S\r\n##.#.......#...#.#..\r\n..##.####1.#####.#..\r\n16\r\n67\r\n-19\r\n15\r\n35\r\n55\r\n30\r\n-23\r\n", "output": ["0"]}, {"input": "20 20\r\n....................\r\n....................\r\n.............6......\r\n#........5..........\r\n....................\r\n....................\r\n....................\r\n......3.............\r\n.......1............\r\n...............#....\r\n.............4......\r\n....................\r\n....................\r\n....................\r\n....................\r\n....7...............\r\n......2...8.........\r\n...S................\r\n....................\r\n....................\r\n33\r\n55\r\n19\r\n29\r\n29\r\n44\r\n31\r\n-7\r\n", "output": ["186"]}, {"input": "20 20\r\n#...4....#..#...#...\r\n..#.....#..#.......#\r\n##.##.##.###.#....5.\r\n####...#.#.#.....#..\r\n......#.#.#...#.....\r\n#...#.###..#....#...\r\n..#..#......#...#...\r\n#.....#.....#.####..\r\n...6..#.2....##.....\r\n#.####.#......1#..#.\r\n..#.#...#..#..#.##..\r\n#....#.....#..#.....\r\n##..##.#............\r\n......###.....###..3\r\n.#.#.......7..#.#..#\r\n..###.#..8........#.\r\n#.##...........##...\r\n#..#....#.#.##...#.S\r\n#.............#.....\r\n.#........###......#\r\n57\r\n28\r\n-26\r\n69\r\n58\r\n-13\r\n54\r\n45\r\n", "output": ["67"]}, {"input": "5 5\r\n.....\r\n.S1..\r\n.2...\r\n...#.\r\n.....\r\n10\r\n5\r\n", "output": ["3"]}, {"input": "20 20\r\n....#......#S.####2#\r\n#........#....##..#.\r\n.....#...#.######...\r\n.#.#..##.#..##.#...#\r\n.......#..#....#.#.#\r\n..##........###.##.#\r\n##.##.#.#....###.###\r\n###3#..#.#....##7#..\r\n##.......#......#...\r\n#..#...4....#...###.\r\n#####.##...#.##.#.#.\r\n###.#......####.##..\r\n.#.#.#..###...#.#..#\r\n#...#.....6...###..#\r\n.###.##.##.##......#\r\n.#..#..#.#...###..#.\r\n..#......##....#....\r\n..5#.#....#.##.#...#\r\n..#....#..########.#\r\n##8.##1#..#....#..##\r\n24\r\n55\r\n6\r\n69\r\n18\r\n18\r\n-8\r\n69\r\n", "output": ["29"]}, {"input": "20 20\r\n....#......#S.####2#\r\n#........#....##..#.\r\n.....#...#.######...\r\n.#.#..##.#..##.#...#\r\n.......#..#....#.#.#\r\n..##........###.##.#\r\n##.##.#.#....###.###\r\n###3#..#.#....##7#..\r\n##.......#......#...\r\n#..#...4....#...###.\r\n#####.##...#.##.#.#.\r\n###.#......####.##..\r\n.#.#.#..###...#.#..#\r\n#...#.....6...###..#\r\n.###.##.##.##......#\r\n.#..#..#.#...###..#.\r\n..#......##....#....\r\n..5#.#....#.##.#...#\r\n..#....#..########.#\r\n##8.##1#..#....#..##\r\n24\r\n55\r\n6\r\n69\r\n18\r\n18\r\n-8\r\n69\r\n", "output": ["29"]}, {"input": "20 20\r\n....................\r\n....................\r\n....................\r\n....................\r\n.......3............\r\n....................\r\n.......B............\r\n....................\r\n.......1............\r\n....................\r\n...SB..B............\r\n....................\r\n.......2............\r\n....................\r\n.......B............\r\n....................\r\n.......4............\r\n....................\r\n....................\r\n....................\r\n50\r\n50\r\n50\r\n50\r\n", "output": ["148"]}, {"input": "12 12\r\n............\r\n......B.....\r\n........1...\r\n............\r\n.......4....\r\n..B#..S.....\r\n............\r\n............\r\n.2...#......\r\n.....B......\r\nB..........#\r\n.......3....\r\n5\r\n-5\r\n33\r\n-9\r\n", "output": ["0"]}, {"input": "12 12\r\n............\r\n............\r\n..B........B\r\n............\r\n.........2..\r\n...4........\r\n....3....B..\r\n..1B........\r\n............\r\n.S..........\r\n............\r\n............\r\n16\r\n-3\r\n18\r\n23\r\n", "output": ["0"]}, {"input": "12 12\r\n.....#......\r\n.....##B...#\r\n.........3..\r\n......#.....\r\n...........#\r\n.....B.....S\r\n...#2.......\r\n...........1\r\n............\r\n..........4.\r\n............\r\n...B.....B..\r\n25\r\n9\r\n-3\r\n4\r\n", "output": ["0"]}, {"input": "12 12\r\n...#........\r\n..B....B.#..\r\n.......#....\r\n.....B......\r\n............\r\n............\r\n...#1.....#.\r\nB.4...3..2#.\r\n...#..#.....\r\n..#..#......\r\n......#..S..\r\n..........#.\r\n-2\r\n23\r\n15\r\n-5\r\n", "output": ["12"]}, {"input": "12 12\r\n...#........\r\n..B.B.......\r\n.....#.....#\r\n............\r\n.......1....\r\n......3.....\r\n.....2......\r\n............\r\n...B.4......\r\n........B...\r\n....#.#.S...\r\n............\r\n-1\r\n2\r\n27\r\n-7\r\n", "output": ["4"]}, {"input": "12 12\r\n...........#\r\n.#..#...B.#.\r\n1...........\r\n3........#..\r\n.....B......\r\n#.........#B\r\n....B2......\r\n.#.....#....\r\n............\r\n4S.........#\r\n...##.#...#.\r\n.....##..#..\r\n37\r\n39\r\n1\r\n32\r\n", "output": ["0"]}, {"input": "12 12\r\n............\r\n..#S#..B.#..\r\n........##..\r\n...#.......#\r\n.1..#...B...\r\n............\r\n............\r\n2...B...#...\r\n.#........B.\r\n.......#....\r\n...#..#..#..\r\n.3......#.4.\r\n13\r\n-6\r\n3\r\n33\r\n", "output": ["0"]}, {"input": "10 10\r\n..........\r\n..........\r\n..........\r\n.....2....\r\n...S...B..\r\n..........\r\n.3..B1.#..\r\n.......#..\r\n.5.....4..\r\n...#.....#\r\n100\r\n10\r\n14\r\n11\r\n20\r\n", "output": ["18"]}, {"input": "12 12\r\n.#..........\r\n#...B.......\r\n#...#.......\r\n............\r\nB...........\r\n.3..#B...#..\r\n..2#.#......\r\n#......#4...\r\n...BS.#.....\r\n......#.....\r\n...........1\r\n............\r\n-4\r\n-6\r\n6\r\n10\r\n", "output": ["0"]}, {"input": "12 12\r\n............\r\n.....3......\r\n####.BB.....\r\n.....#......\r\n..#...B.2...\r\n4...#.B....#\r\n...#..#.....\r\n.....#1#S...\r\n.#..#.......\r\n.....##....#\r\n............\r\n............\r\n9\r\n30\r\n18\r\n35\r\n", "output": ["18"]}, {"input": "12 12\r\n4.........#.\r\n...........#\r\n..S.......B.\r\n..........#.\r\n.....#.#....\r\n.....B...#..\r\n............\r\n....#......#\r\n............\r\n.....3..B...\r\n....B....1..\r\n...2........\r\n20\r\n30\r\n29\r\n17\r\n", "output": ["0"]}, {"input": "8 8\r\n...#.#..\r\n.....1..\r\n..#3..##\r\n.S#....#\r\n.BB..#..\r\n....B#..\r\n...2.4..\r\n.....#B.\r\n44\r\n16\r\n30\r\n0\r\n", "output": ["0"]}, {"input": "8 8\r\nB.......\r\n.#1S...B\r\nB....B..\r\n....#.#.\r\n.#......\r\n...4....\r\n#.2##3..\r\n........\r\n32\r\n24\r\n-8\r\n37\r\n", "output": ["31"]}, {"input": "8 8\r\n..#.#...\r\n.2..B..#\r\n.B.S....\r\n.B#...1.\r\n#......B\r\n......4.\r\n#.3#.##.\r\n.#.#...#\r\n34\r\n24\r\n5\r\n29\r\n", "output": ["0"]}, {"input": "8 8\r\n..#.B#..\r\n..1.4...\r\n...3...#\r\n.B..B#..\r\n#..B2...\r\n#S......\r\n.#.#..#.\r\n.......#\r\n49\r\n-8\r\n-4\r\n28\r\n", "output": ["0"]}, {"input": "8 8\r\nB......S\r\n...B..2.\r\n...B4.3.\r\n........\r\n........\r\n.1......\r\n........\r\n...B....\r\n26\r\n-6\r\n15\r\n45\r\n", "output": ["9"]}, {"input": "8 8\r\n#.#....#\r\n....1...\r\n..#.....\r\n..#..S#.\r\n.2......\r\n...4..3.\r\n...#.BB.\r\n.#.B..#B\r\n6\r\n41\r\n49\r\n30\r\n", "output": ["27"]}, {"input": "8 8\r\n..#.....\r\n...#....\r\n.4....1#\r\n..3.....\r\n#B....B.\r\n......B.\r\n.#..B.2.\r\n##.S#...\r\n36\r\n9\r\n10\r\n-6\r\n", "output": ["0"]}, {"input": "10 10\r\n..........\r\n...6##....\r\n.##..#....\r\n.....2....\r\n...S......\r\n..........\r\n.3..B1.#..\r\n.......#..\r\n.5.B...4..\r\n...#.....#\r\n100\r\n10\r\n14\r\n11\r\n20\r\n50\r\n", "output": ["64"]}, {"input": "8 8\r\n.#......\r\nS..#.B.#\r\n.B..21B#\r\n......#.\r\n...#3B..\r\n#....#..\r\n.4...##.\r\n...#...#\r\n46\r\n17\r\n26\r\n0\r\n", "output": ["0"]}, {"input": "12 12\r\n...#...##...\r\n....#.B.....\r\n...........#\r\n###.....B..#\r\n...#...B....\r\n......S##..#\r\n#..#..#.....\r\n...##.#.#..#\r\n.#...B..B##B\r\n.#..#.....B.\r\n#....#...1..\r\n.....#.....#\r\n26\r\n", "output": ["0"]}, {"input": "12 12\r\n..#.B#......\r\n##...#...#..\r\n.....#.#.1#.\r\n.....#.#B...\r\nB.....S.....\r\n#..........#\r\n.#......B...\r\n...#.##.#...\r\n..#.....#...\r\n....#.......\r\n........B...\r\n..B.##....B.\r\n4\r\n", "output": ["0"]}, {"input": "12 12\r\n............\r\n...........B\r\n..B.........\r\n............\r\n....B.......\r\n............\r\n......B.....\r\n#...........\r\n........B#S.\r\n#..#..#.....\r\n..B......1..\r\n.B..........\r\n40\r\n", "output": ["30"]}, {"input": "12 12\r\n............\r\n.....##.1..#\r\n.......B...#\r\n......#...#.\r\n.B.....S....\r\n....B.......\r\n....B.......\r\n.........#..\r\nB..........#\r\n............\r\nB......B..#.\r\n.....#......\r\n13\r\n", "output": ["0"]}, {"input": "12 12\r\n..B....#..#.\r\n.#..#......B\r\n............\r\n.B..#....#.#\r\nB.....#.....\r\n##....#....B\r\n....#.#...#.\r\n.......#...#\r\n.#.......#.#\r\n#.#..1.##S.#\r\n..#...#.....\r\nB....B....#.\r\n-3\r\n", "output": ["0"]}, {"input": "12 12\r\n............\r\n.B...B......\r\n....#......B\r\n.......#.B..\r\n.#..........\r\n........#.#.\r\n............\r\n............\r\n............\r\n............\r\nS.B...1..B..\r\n......B.....\r\n-8\r\n", "output": ["0"]}, {"input": "12 12\r\n...B...B...#\r\n.S..........\r\n..###.#.##.#\r\n.#.##..B....\r\n.##.1.......\r\n.......#...#\r\n#..#..B#..##\r\n...#.....#..\r\n.....#......\r\n..B.#...#B..\r\n#B#..#.#....\r\n...#.....#.#\r\n38\r\n", "output": ["20"]}, {"input": "12 12\r\n..#.....B...\r\n.#..........\r\n..#.........\r\n..#.B.......\r\nB..#S#...#.#\r\n............\r\n..B##.#.1#..\r\n...#B#...#..\r\n.....B..#...\r\n.....##.....\r\n..B.....#.#.\r\n..##.#...#.#\r\n35\r\n", "output": ["13"]}, {"input": "12 12\r\n...........#\r\n.#B.......#B\r\n.....#......\r\n....#.......\r\n....#.....B.\r\n......#.....\r\n.1.SB#......\r\n..#..#......\r\n...........B\r\n...BB.......\r\n.#.....#....\r\n....#.......\r\n31\r\n", "output": ["19"]}, {"input": "10 10\r\n..........\r\n...5##....\r\n.##..#....\r\n.....2....\r\n...S.B....\r\n..........\r\n.3..B1.#..\r\n.......#..\r\n...B...4..\r\n...#.....#\r\n100\r\n10\r\n14\r\n11\r\n20\r\n", "output": ["2"]}, {"input": "12 12\r\n......B.....\r\n....B...S#..\r\n#....#......\r\n........#...\r\n............\r\n....#...B.B.\r\n.#.....#..#.\r\n..##........\r\n...#.......B\r\n.##.1....#..\r\n#...B......#\r\n..##...B....\r\n42\r\n", "output": ["0"]}, {"input": "20 20\r\n......##.#....#.....\r\n.................#..\r\n##....#........#...#\r\n.......#....1.......\r\nB#...........##..#..\r\n##....##............\r\n........#..#....#.#.\r\n...##.#.5.#.#.#...#.\r\n..#...#..#..........\r\n................#.#.\r\n#.......#..##.##..#.\r\n.#.....#...#S...##..\r\n....#...............\r\n...#.##..#....#..3..\r\n..#.................\r\n#....#..2...B..#....\r\n........#.###.....##\r\n.#.......##.....4.##\r\n.....#.#B.......#..#\r\n###..#......#.......\r\n2\r\n-9\r\n-21\r\n-29\r\n2\r\n", "output": ["0"]}, {"input": "20 20\r\n....#......#.......#\r\n..##.#......##....##\r\n.#....##....#B.3...#\r\n.2..#........#.#..#.\r\n.......#.#..#......S\r\n..#...#........#....\r\n....#.#....#4..5...#\r\n.#.......#..#...#.#.\r\n.#.#...##.#...##..#.\r\n..B..#...#...##.#...\r\n....#.......#.#....#\r\n.#..#.........#...#.\r\n..#.....#.#.#...#...\r\n..........##.#...#..\r\n.##.......1..#....##\r\n#..#...#...#...#....\r\n..B.#..#.........##.\r\n..#..#.#.#.##....#..\r\n......##.#........#.\r\n.#........#....#....\r\n-21\r\n37\r\n38\r\n-21\r\n-12\r\n", "output": ["22"]}, {"input": "20 20\r\n..#.......#.........\r\n.#..................\r\n..#............#....\r\n..................#.\r\n.......S..#.........\r\n.#B.................\r\n..........#.........\r\n...#.....#.....#....\r\n....2#..............\r\n..5...............1.\r\n...#..#.......#.....\r\n#..#................\r\n....................\r\n...#...........B3...\r\n.............#......\r\n...4..#........B....\r\n#......#..#...##...#\r\n....#.............#.\r\n.............#.....#\r\n.#.......#..........\r\n-17\r\n-12\r\n22\r\n28\r\n-22\r\n", "output": ["0"]}, {"input": "20 20\r\n.##.#.............#.\r\n.........B.....#....\r\n....................\r\n..#.#...........##.#\r\n....#.........#...S.\r\n....................\r\n.#..........#.....#.\r\n.....#..#......#...#\r\n...........#....4...\r\n....#......#........\r\n.....#..B#.........#\r\n.#....#....3#......#\r\n#.......#...........\r\n......#......#.....#\r\n.......#.#..##......\r\n..#...5#....#...#...\r\n..........#....#.#..\r\n.....2..............\r\n#........1....#.....\r\n..............B.....\r\n39\r\n-1\r\n49\r\n46\r\n-3\r\n", "output": ["84"]}, {"input": "20 20\r\n....B......#........\r\n......#..#..........\r\n.....#B.#......#.#..\r\n....................\r\n#..#.#....#.#..#....\r\n#...................\r\n..#.........#.......\r\n..#.#...............\r\n...1..B.............\r\n...#...........#..3#\r\n......#.............\r\n.....4...#....#.....\r\n...................#\r\n.....#..............\r\n......#.......5...#.\r\n........#.#.#.#.#...\r\n...#.S..............\r\n....................\r\n.........#....2.....\r\n.........#...#......\r\n13\r\n-14\r\n24\r\n23\r\n18\r\n", "output": ["5"]}, {"input": "20 20\r\n.............#......\r\n.#..........#......#\r\n.B.#.S..45........##\r\n......#.......#.#...\r\n.....#...#..#.......\r\n.....##.............\r\n..B.###.......#.....\r\n....#....#....#.....\r\n.....#..............\r\n#.......#...........\r\n......#.......#.....\r\n....#..#............\r\n..#.....#.#.#.......\r\n.#.....##.##..#.....\r\n..##........3.......\r\n#.....2#..1#........\r\n#.#...#..#.........#\r\n................#..#\r\n...............#..B.\r\n##...#..............\r\n-13\r\n45\r\n14\r\n47\r\n-27\r\n", "output": ["19"]}, {"input": "20 20\r\n....#.#..#........##\r\n.##.....3..#..#.....\r\n.......#.#.....2.#..\r\n.#...#.#......##...#\r\n##..##....#4#.###5#.\r\n#....#..#.#.#...##..\r\n..#....#..#.#...#..#\r\n.S..#......1......#.\r\n.##...#...#........B\r\n...#.##....#.#.....#\r\n.....#..#.###.......\r\n.#....#.#....#.#....\r\n.B#...#.####.......#\r\n.#......####........\r\n...####.###....#....\r\n###.#.............##\r\n.##..##...#..#......\r\n..#.#####....#....B.\r\n...#...........#.##.\r\n..##......#...##.#..\r\n43\r\n33\r\n44\r\n2\r\n-1\r\n", "output": ["0"]}, {"input": "20 20\r\n.#.##....#....##....\r\n#.###....#....##..#.\r\n..............#...##\r\n#..........#.#.1..##\r\n..#.....##..#.##..#.\r\n#.#...#.#......##.#.\r\n...##..#.#...#......\r\n#...##...#..#..#..#.\r\n#S#...#..#.#...#.#3#\r\n.....#...#...#......\r\n..........#..4#..B2.\r\n#...##..#.#.##.....#\r\n.....#...#.##.#...#.\r\n.###....#.#.........\r\n.#.#..###..##.....#.\r\n...##.#...#..##....#\r\n.5.....##B...#.#.##.\r\n...#....#.#...#.###.\r\n#.#......#..#..B....\r\n###.#.#.....##...#..\r\n44\r\n12\r\n23\r\n7\r\n33\r\n", "output": ["9"]}, {"input": "20 20\r\n.............#..#..#\r\n.5..................\r\n.#........#.#B...#..\r\n#.###..B........#.##\r\n.............###.1..\r\n..#...2.....#....#..\r\n....................\r\n.........#4..#......\r\n#......#....#..#..#.\r\n.#.....#.........#.#\r\n.........#.#.#......\r\n.........#..##......\r\n#........#......#.3.\r\n.#............#.###.\r\n.........#.#.#......\r\n##.#....###...#.....\r\n....##......#B......\r\n...#.....##..#......\r\n.#......##.S......#.\r\n...#.....#....#...##\r\n-23\r\n26\r\n-10\r\n-11\r\n30\r\n", "output": ["0"]}, {"input": "10 10\r\n..........\r\n...###....\r\n.##..#....\r\n.......2..\r\n...S.B.1..\r\n.....B....\r\n....B..#..\r\n.......#..\r\n...B......\r\n...#.....#\r\n30\r\n-5\r\n", "output": ["7"]}, {"input": "20 20\r\n....#..#.....#......\r\n..............###...\r\n.#...........#......\r\n..#..#..#...........\r\n......1.......##....\r\n............2....#..\r\n....#......##.......\r\n.....#..#.....B.....\r\nB.......#.#...#.....\r\n..#.....#......#....\r\n.#.4.......#........\r\n.....#..#...#.......\r\n#..#...........#....\r\n....#...............\r\n.....#...........#..\r\n....#.....#.#..5....\r\n#..#................\r\n#............3......\r\n........##...#.#....\r\n...............BS.##\r\n14\r\n-26\r\n-8\r\n-10\r\n-1\r\n", "output": ["0"]}, {"input": "20 20\r\n.#..................\r\n.##....#...3.....#.B\r\n#.###...#..#...B....\r\n.....#..#.#.....#...\r\n#.....#.#..##..#.1#.\r\n.....#.........#....\r\n....#.#......#.....#\r\n..........#.........\r\n...#..#............#\r\n.............#.2..#.\r\n.#.............#....\r\n####.....#.#.#.#...#\r\n...#..#........#...#\r\n#....#.#..#..###....\r\n....#.......B.#..#.B\r\n...........#....4..#\r\n.#..................\r\n..#.#....#...#......\r\n..#...#...##..S.....\r\n.....#.....#.....#..\r\n2\r\n-21\r\n-23\r\n17\r\n", "output": ["0"]}, {"input": "20 20\r\n................#.B.\r\n....................\r\n..#..........B......\r\n....................\r\n....#...............\r\n....................\r\n....................\r\n....................\r\n....................\r\n....................\r\n........S.........4.\r\n..2.................\r\n............1.......\r\n....................\r\n....................\r\n....................\r\n....................\r\n....B........B......\r\n................3...\r\n....................\r\n-22\r\n-22\r\n17\r\n-14\r\n", "output": ["0"]}, {"input": "20 20\r\n.....#..#....#....#.\r\n.#.....#........###.\r\n............B#....#.\r\n..#........#.#.#....\r\n#......#..#.........\r\n.#.......#.........#\r\n#.....##.#.#..#.....\r\n#....#.#...2#..S...B\r\n.........#....#.....\r\n.......#....#..B#...\r\n#....##..#.....#..#.\r\n.........#...#...#..\r\n.......##....#...3..\r\n.#...........#.#..B.\r\n.....14.#.....#..###\r\n....#.....#.#...##..\r\n........##.......#..\r\n#..#...........#....\r\n.....#...#..#.##....\r\n................##..\r\n-3\r\n33\r\n7\r\n18\r\n", "output": ["17"]}, {"input": "20 20\r\n...#....#........#..\r\n.#B##.#...#......#..\r\n..#...##..#.#..##.#.\r\n#...#.#...#..B..#.#.\r\n.....#.#.##.#.#.....\r\n.#.#.##....###.....#\r\n...##...#...#.#...#.\r\n#......##....##.....\r\n#.#..#...#1.#.#B#..#\r\n..#........#..##....\r\n....#...#...##B.#.#.\r\n#..#.#..##.#..3.####\r\n....##.......#..##S.\r\n.........#.....4#.#.\r\n.2.........#......#.\r\n.#...#.#.....#..##.#\r\n..#....#...#.....##.\r\n#..##....#..#..#..#.\r\n#.#...##..#.##.#..#.\r\n..................#.\r\n37\r\n-30\r\n-17\r\n10\r\n", "output": ["0"]}, {"input": "20 20\r\n##.#......##.###..#.\r\n#..#................\r\n#.............#2....\r\n#.............##..#.\r\n...##.....##........\r\n#....#..............\r\n......###.B...##.##.\r\n....#.##........#.#.\r\n...##..#.#..B..##.#.\r\n...#........#.##.#..\r\n......#........#....\r\n....#..#.#......##.#\r\n...#........#.#..#..\r\n.....##.#..#..#.###.\r\n#..S....###.#...#...\r\n....##..#.#..3..#.#.\r\n.........1.......#..\r\n......#...B......#.#\r\n.....4..##.#.....##.\r\n.B#...#.............\r\n38\r\n-3\r\n37\r\n-27\r\n", "output": ["0"]}, {"input": "20 20\r\n#..#...B#..........#\r\n.#.##..#...#..##...B\r\n#....#...........#..\r\n..#..........#..#..#\r\n....#1.....#....#...\r\n...#.#####.#.#...##.\r\n#........#..#..#.#..\r\n.........#.##..#.B.#\r\n............S...#...\r\n.....##...#.....#...\r\n.#.#..##..#......#..\r\n..4.###........#.#..\r\n.....3..#..#......B.\r\n.#.......#....#.....\r\n...##..#...#.#....#.\r\n#......#............\r\n.......2...##.......\r\n.............##.....\r\n....#...............\r\n#.#....#.#..#......#\r\n-5\r\n-26\r\n39\r\n42\r\n", "output": ["47"]}, {"input": "20 20\r\n....#.#.........#...\r\n..##.#.......#.#....\r\n..#......##.#.#...#.\r\n.S##..#.....##...#..\r\n.#...#.......#B#....\r\n#...#......#...##...\r\n...#..........B.#.#.\r\n...........3.#...##.\r\n............#...B#..\r\n..#..#...#.....1....\r\n.....#......#.......\r\n...#...#...##..#.#..\r\n##........#.........\r\n.#....#......#...#..\r\n#.#..#..#...#....2..\r\n.##..........#...#..\r\n..#...........4.....\r\n....#.##.....#..#.B.\r\n#...#..###.#.#....##\r\n............#.......\r\n47\r\n-28\r\n8\r\n-24\r\n", "output": ["0"]}, {"input": "20 20\r\nB.......##..#.#.....\r\n.....#.#....2....#.#\r\n#...##...##..##...#.\r\n.#........1......##.\r\n.......#.##.......##\r\n.#B.#...#..#...#....\r\n#..#.#.......##.#..#\r\n...#..#.###........#\r\n..S....#.#.#.#......\r\n.....#..##....#.#.#.\r\n#B#..#..............\r\n.#3..4#.#.##........\r\n#####.#.............\r\n......###........###\r\n.#........#....#...#\r\n.........#..#..#....\r\n##..#......###.#...#\r\n..#.#..###.....#####\r\n#.#....#.......#...#\r\n..#...#B#.###.#...#.\r\n35\r\n-17\r\n0\r\n-2\r\n", "output": ["0"]}, {"input": "20 20\r\n......##.##....#....\r\n.....#........#..##.\r\n#..#..#.##....###...\r\n.#.......#.........#\r\n#.#.#..##.......##..\r\n#..##......##......#\r\n.....#........##.#4.\r\n#...##.#......#.##.#\r\n#..B..#....##.#..3..\r\n..##..#....#.....#.#\r\n.#..#..##........#..\r\n..#...#.2.#####.....\r\n...#...#..#.........\r\n.###....#.#....#....\r\n#..#.#..B#...#B.....\r\n..#.#.#..##.......#.\r\n.......#.#B#.#......\r\n..S..#.#............\r\n#.......#...#.....1#\r\n.#....#.#..#...#.#.#\r\n22\r\n26\r\n11\r\n33\r\n", "output": ["0"]}, {"input": "10 11\r\n...........\r\n...........\r\n.#..B......\r\n....B.1....\r\n...S.#.....\r\n....B......\r\n....B..#...\r\n.......#...\r\n....B......\r\n...#.....#.\r\n30\r\n", "output": ["0"]}, {"input": "20 20\r\n......#.............\r\n.##.................\r\n...........#.#.##..#\r\n.#..................\r\n.#.#................\r\n............#......#\r\n....................\r\n.B.#................\r\n.B.....#1..B.#.#..2.\r\n....................\r\n..#S................\r\n..........3....#....\r\n......4......#....##\r\n...#..#.#.....#.#...\r\n..........#.........\r\n#..B............#...\r\n#...................\r\n...#.......#........\r\n#..............##...\r\n.................#..\r\n27\r\n22\r\n20\r\n27\r\n", "output": ["46"]}, {"input": "20 20\r\n.##..#.#.#...#..#...\r\n.S.#.....#...#...##.\r\n.#......#...#......#\r\n........#...........\r\n.............#.#..#.\r\n.#..2.#1...#...#..#.\r\n......#.6....#7.#..#\r\n.#....#....#...#...#\r\n..........#.......#.\r\n......#....#..#.....\r\n.#.........#.3#.##8.\r\n.#.###..........#..#\r\n##...##.........###.\r\n..#...#...#.#.....#.\r\n....#.#.4.#....#....\r\n.5##......#.....#..#\r\n..#........##....#.#\r\n#.#.#.#...#......#..\r\n......#.............\r\n..#.....#......#..#.\r\n75\r\n39\r\n54\r\n77\r\n19\r\n20\r\n9\r\n69\r\n", "output": ["219"]}, {"input": "20 20\r\n##.###.#.#..#.#..#..\r\n#..........#.#..#...\r\n..#.#.#.....#.#####.\r\n.###..........#.#.#.\r\n....#...#.........#.\r\n.#.#....#.##.7...##.\r\n..#..S....#....#.##.\r\n..#...5#.#...#.#.###\r\n.....###.#...##.#...\r\n.##..####.#..###.#..\r\n#....#..#...1.#..#..\r\n##..#..............#\r\n..........#..#..#.#.\r\n#....3....#.#....#..\r\n..#.6.#..#.#..##..##\r\n...#.......#...#..#.\r\n.....###.8#...#..#..\r\n....##.4#....#......\r\n#2.##.#.#...#..#####\r\n........#...##...#..\r\n16\r\n-31\r\n44\r\n44\r\n-10\r\n76\r\n-48\r\n30\r\n", "output": ["84"]}, {"input": "20 20\r\n..............#.....\r\n............#.#.....\r\n#......#.#.....#....\r\n...#..........6#....\r\n....................\r\n...#...#..#........#\r\n.............#.#.#..\r\n...#7.........#...#.\r\n..........#...#.....\r\n........2...........\r\n#....#..##.#....##.#\r\n#.#.....#.#....#....\r\n#..........#..#.#...\r\n.#....1..........#..\r\n..#.................\r\n#.....###.#.....#.#.\r\n#....3.....#........\r\n...#4..#.#.S.#..5...\r\n.....#.......8..#.#.\r\n.........#.......#..\r\n9\r\n97\r\n1\r\n3\r\n7\r\n-42\r\n-10\r\n59\r\n", "output": ["125"]}, {"input": "20 20\r\n....................\r\n#...................\r\n..#.................\r\n........2...........\r\n.8..................\r\n.....4......#..S....\r\n....................\r\n....................\r\n...6.........5......\r\n....................\r\n.........#..........\r\n.................1..\r\n....................\r\n....................\r\n...3.......#........\r\n....................\r\n....................\r\n..................7.\r\n....................\r\n....#...............\r\n16\r\n-45\r\n7\r\n49\r\n54\r\n45\r\n-18\r\n-41\r\n", "output": ["117"]}, {"input": "20 20\r\n#................#..\r\n................#.#.\r\n.....##...#.3.7#.#..\r\n......S..#.#........\r\n....4##.#.....1..#..\r\n#..#...#.#..........\r\n..##........##.#....\r\n.2#...##....##....##\r\n##.5..#..#.#..#.#..#\r\n..#.##...#......#...\r\n.......#...#......##\r\n..............##.#.#\r\n.6..##.#........#.#.\r\n.#..#.#.#........#..\r\n......#.#..........#\r\n.#.#....#........#..\r\n..#...........8.##..\r\n...........#...#..#.\r\n.#..........#...#...\r\n#..#..#.#....###....\r\n-28\r\n86\r\n19\r\n56\r\n-43\r\n11\r\n21\r\n-21\r\n", "output": ["0"]}, {"input": "20 20\r\n#................#..\r\n................#.#.\r\n.....##...#.3.7#.#..\r\n......S..#.#........\r\n....4##.#.....1..#..\r\n#..#...#.#..........\r\n..##........##.#....\r\n.2#...##....##....##\r\n##.5..#..#.#..#.#..#\r\n..#.##...#......#...\r\n.......#...#......##\r\n..............##.#.#\r\n.6..##.#........#.#.\r\n.#..#.#.#........#..\r\n......#.#..........#\r\n.#.#....#........#..\r\n..#...........8.##..\r\n...........#...#..#.\r\n.#..........#...#...\r\n#..#..#.#....###....\r\n-28\r\n86\r\n19\r\n56\r\n-43\r\n11\r\n21\r\n-21\r\n", "output": ["0"]}, {"input": "20 20\r\n........#.....##..##\r\n#....##......#..#...\r\n.......#...#.....#..\r\n#...##..#.#.#.#.....\r\n.........#...5..##..\r\n...##...#...#.......\r\n..#.#.....##..#.#.#.\r\n..##.......##....#..\r\n#.....#.....#..###.#\r\n..3S.###........#...\r\n.#..#....#4......#..\r\n.......#.....#.#.#.#\r\n#.#....#..#..#.1..#.\r\n.#...6........#...#.\r\n..#.....#...#.#2..#.\r\n...#.#..#......####.\r\n...........#...#....\r\n##.8.##..###..#....#\r\n...7..#.###....#...#\r\n..#....#..#.........\r\n14\r\n-24\r\n44\r\n65\r\n5\r\n-25\r\n40\r\n99\r\n", "output": ["75"]}, {"input": "20 20\r\n........#......#....\r\n..6..#..............\r\n.2..#1.........S#...\r\n....................\r\n..............#...#.\r\n..............#.....\r\n...#......#......#..\r\n................3.#.\r\n...................#\r\n....#..........#....\r\n..#......#..........\r\n#.............#...#.\r\n.............8......\r\n.............#...#..\r\n....................\r\n..4.....#...#..#....\r\n.#..............#...\r\n...............#..7.\r\n.......#..5..##.....\r\n.........#.....#....\r\n-19\r\n-32\r\n13\r\n7\r\n52\r\n60\r\n-9\r\n77\r\n", "output": ["45"]}, {"input": "20 20\r\n.....#.........#....\r\n..#..##...##........\r\n..........#.#.#.#...\r\n.#.............#....\r\n..............#.....\r\nS#......8..#..#.....\r\n..........###....#..\r\n....#....#...##...##\r\n....#......#.#......\r\n#..#.6..#...........\r\n...#.........3...#..\r\n.......#........#...\r\n...............#....\r\n.....#..21.....#...#\r\n#...........#....#.#\r\n........4.....#...7.\r\n..#..........#......\r\n#................#5.\r\n.##.......#.........\r\n...#...#..........#.\r\n79\r\n-16\r\n28\r\n-16\r\n92\r\n61\r\n60\r\n-38\r\n", "output": ["180"]}, {"input": "20 20\r\n...#.......#..#.#.#.\r\n......#.#.#.##.#....\r\n.....#..#...........\r\n#..##.....#.#.......\r\n....#.............#.\r\n...#.....##...##...#\r\n...#..............#.\r\n.#..#..........##2.#\r\n.....#....##........\r\n..............#....#\r\n#....#.##....#..#...\r\n......7#...##.#.....\r\n#....#6......#...#..\r\n#.##.##....#....#5..\r\n.....#.#..#..###....\r\n..#.S.3..#..#....1##\r\n..#..##..#.......#..\r\n.#......4.##.....#..\r\n#.##.#.#..#.8.......\r\n..#.##....#...#..#.#\r\n44\r\n-43\r\n10\r\n94\r\n30\r\n40\r\n-45\r\n-13\r\n", "output": ["0"]}, {"input": "10 11\r\n...........\r\n...........\r\n.#.B.......\r\n......1....\r\n....SB.....\r\n....B......\r\n...B...#...\r\n.......#...\r\n....B......\r\n...#.....#.\r\n30\r\n", "output": ["0"]}, {"input": "20 20\r\n.###.......#...##...\r\n...S....#.....##.#.#\r\n#....#.....#........\r\n...#...##.#......#..\r\n.....##.#.##...#....\r\n...........#2.......\r\n........#......##...\r\n.......7....##..#.##\r\n..#...#.......#..#..\r\n..#.#....4#..#...5#.\r\n..#....#3#.......##.\r\n...........##..#...#\r\n.......#...#........\r\n............#.#.....\r\n...#........8....#..\r\n............#.#...#.\r\n.#......#6......#...\r\n.##.........#..#..1.\r\n.....###...#.....#..\r\n#.#......##.....#.#.\r\n49\r\n43\r\n83\r\n0\r\n-26\r\n5\r\n36\r\n53\r\n", "output": ["162"]}, {"input": "20 20\r\n.###.......#...##...\r\n...S....#.....##.#.#\r\n#....#.....#........\r\n...#...##.#......#..\r\n.....##.#.##...#....\r\n...........#2.......\r\n........#......##...\r\n.......7....##..#.##\r\n..#...#.......#..#..\r\n..#.#....4#..#...5#.\r\n..#....#3#.......##.\r\n...........##..#...#\r\n.......#...#........\r\n............#.#.....\r\n...#........8....#..\r\n............#.#...#.\r\n.#......#6......#...\r\n.##.........#..#..1.\r\n.....###...#.....#..\r\n#.#......##.....#.#.\r\n49\r\n43\r\n83\r\n0\r\n-26\r\n5\r\n36\r\n53\r\n", "output": ["162"]}, {"input": "5 5\r\n....3\r\n.....\r\n1....\r\n.524.\r\nS....\r\n36\r\n22\r\n12\r\n-23\r\n-19\r\n", "output": ["0"]}, {"input": "10 10\r\n....#.....\r\n....#.#8..\r\n6#.#..##.#\r\n.#.7..4#.S\r\n.#......#.\r\n..#..2....\r\n1......#.#\r\n..3.#.....\r\n......5...\r\n.#.##...#.\r\n8\r\n12\r\n-10\r\n17\r\n49\r\n-7\r\n33\r\n32\r\n", "output": ["82"]}, {"input": "5 5\r\n....2\r\n.51.S\r\n.3..4\r\n.....\r\n.....\r\n-2\r\n44\r\n-14\r\n-22\r\n45\r\n", "output": ["15"]}, {"input": "5 5\r\n3..5.\r\n..1..\r\n.2...\r\nS....\r\n.4...\r\n13\r\n52\r\n31\r\n-37\r\n-1\r\n", "output": ["0"]}, {"input": "7 7\r\n.......\r\n.1###2.\r\n.#...#.\r\n.#.B.#.\r\n.3...4.\r\n..##...\r\n......S\r\n100\r\n100\r\n100\r\n100\r\n", "output": ["364"]}, {"input": "5 5\r\n.....\r\n..4..\r\n3..1.\r\n.5...\r\n2S...\r\n-8\r\n29\r\n31\r\n6\r\n35\r\n", "output": ["0"]}, {"input": "5 5\r\n32...\r\n.5.S1\r\n.....\r\n..4..\r\n.....\r\n11\r\n57\r\n19\r\n-17\r\n-13\r\n", "output": ["0"]}, {"input": "5 5\r\n.....\r\n..S..\r\n5.2..\r\n3.4..\r\n.1...\r\n-4\r\n7\r\n-11\r\n29\r\n-37\r\n", "output": ["0"]}, {"input": "5 5\r\n..2.1\r\n....S\r\n...4.\r\n.....\r\n..35.\r\n-16\r\n31\r\n-40\r\n27\r\n-25\r\n", "output": ["19"]}, {"input": "5 5\r\n.....\r\n.3..5\r\n..14.\r\n.....\r\n..S2.\r\n-24\r\n-38\r\n-3\r\n48\r\n2\r\n", "output": ["0"]}, {"input": "5 5\r\n.3.2.\r\n.S...\r\n..54.\r\n.....\r\n..1..\r\n14\r\n-28\r\n-25\r\n-10\r\n31\r\n", "output": ["11"]}, {"input": "5 5\r\n.B...\r\n...S.\r\n.#...\r\n..1..\r\n#.#..\r\n2\r\n", "output": ["0"]}, {"input": "10 10\r\n...#...#..\r\n...1...#..\r\n.#..3..#..\r\n..#5.7..#.\r\n.4#...##..\r\n....#.#...\r\n..##.#...6\r\n.S.......#\r\n#........#\r\n2#.#B.....\r\n12\r\n30\r\n57\r\n37\r\n80\r\n14\r\n5\r\n", "output": ["0"]}, {"input": "10 10\r\n...#...S##\r\n#B#.....1.\r\n.......#..\r\n3#.B..#...\r\n.........B\r\n......4..#\r\n......B...\r\n.....2....\r\n..........\r\n........#.\r\n36\r\n40\r\n16\r\n-8\r\n", "output": ["0"]}, {"input": "10 10\r\n..........\r\n..1......#\r\n.....2.4.#\r\n........#.\r\n.......S..\r\n..........\r\n.#...3....\r\n..7....6#.\r\n..........\r\n....8...5.\r\n38\r\n8\r\n74\r\n24\r\n32\r\n50\r\n74\r\n27\r\n", "output": ["210"]}, {"input": "10 10\r\n..###2...#\r\n#....#....\r\n#........#\r\n8.....#.#.\r\n..6.#.#...\r\n.#....7.#.\r\n3###...4..\r\n..#...S#.5\r\n.......1..\r\n.##...####\r\n-1\r\n72\r\n63\r\n2\r\n40\r\n49\r\n13\r\n42\r\n", "output": ["0"]}, {"input": "10 10\r\n.##2#...#.\r\n##.6..#..1\r\n#..S...74.\r\n##.......#\r\n#..5#8.#..\r\n...##.3###\r\n.........#\r\n.##.###.#.\r\n#..#.#.##.\r\n#......###\r\n-4\r\n64\r\n10\r\n-4\r\n42\r\n65\r\n6\r\n0\r\n", "output": ["0"]}, {"input": "20 10\r\n...#....5.\r\n..2##.....\r\n.......##.\r\n.......#..\r\n...S##..#.\r\n.#....7...\r\n....#.#...\r\n..#.##.#..\r\n..###.#...\r\n....6#....\r\n##4#31...#\r\n..#......#\r\n#..##..##.\r\n.#.###..#.\r\n..###....#\r\n....#.#...\r\n##.8...#..\r\n.###.#.#.#\r\n.........#\r\n...#..#...\r\n-21\r\n40\r\n47\r\n130\r\n55\r\n155\r\n0\r\n32\r\n", "output": ["0"]}, {"input": "20 10\r\n..........\r\n........S.\r\n........#.\r\n......B...\r\n..3.......\r\n.....B1...\r\n....#.....\r\n..........\r\n..........\r\n..........\r\n..........\r\n.B.....B..\r\n.....2....\r\n....#.....\r\n..........\r\n..........\r\n.....#....\r\n..#.......\r\n..........\r\n........B.\r\n-20\r\n-2\r\n143\r\n", "output": ["121"]}, {"input": "10 10\r\n.#........\r\n..#...#...\r\n#....7..S.\r\n..8...#...\r\n.4..#.....\r\n.#3.......\r\n.2..#.....\r\n.##.....5.\r\n..1##.#6..\r\n......#..#\r\n58\r\n30\r\n47\r\n73\r\n-18\r\n-16\r\n25\r\n63\r\n", "output": ["262"]}, {"input": "20 20\r\n..#..##..##......#..\r\n...#..#..#..##......\r\n....S...#...#....#..\r\n#.#.....###...#...##\r\n##.....##...#..#####\r\n.#..#...........6#..\r\n....#...8.#..#......\r\n.#..5#.#......#.#...\r\n#...........3.#.#...\r\n.##.....##.........#\r\n...##.#....#.##.#...\r\n...............####.\r\n.#.........#...#...2\r\n#.#.#..#.#.#.#......\r\n#.#.1...............\r\n.#....4#......##..#.\r\n.#....#.......#...#.\r\n#........##......#.#\r\n#..###..7#....#..#.#\r\n#...#......#......#.\r\n-22\r\n-65\r\n-29\r\n71\r\n128\r\n-75\r\n180\r\n154\r\n", "output": ["483"]}, {"input": "20 20\r\n.#.######..##.#.....\r\n.......#....##...##.\r\n.#......#7.....#....\r\n##..#..#6........#..\r\n..#.##.##..#..##...#\r\n##............##....\r\n.....#..#........#.#\r\n.#............#..#..\r\n.#.#..##..#.#...#2..\r\n..................#.\r\n.....#1.###......#..\r\n....#..#...#.#....##\r\n..#.#...##...##..4#.\r\n..##.#####.##.#.###.\r\n#...##.3....#.#..##.\r\n..##.......##..#..##\r\n........#..#8...###.\r\n........#..#.#5.....\r\n#.####.....#.#.#...#\r\n.S...#...###.#.#..#.\r\n98\r\n96\r\n52\r\n-35\r\n-79\r\n47\r\n80\r\n-49\r\n", "output": ["108"]}, {"input": "20 20\r\n.........S.5....4...\r\n....................\r\n....................\r\n....................\r\n....................\r\n.........6..........\r\n....................\r\n....................\r\n...............2....\r\n....................\r\n....................\r\n..........7.........\r\n....................\r\n....................\r\n....................\r\n........3...........\r\n....................\r\n.........1..........\r\n.....8..............\r\n....................\r\n-58\r\n165\r\n57\r\n14\r\n91\r\n153\r\n-30\r\n122\r\n", "output": ["435"]}, {"input": "20 20\r\n.........#..........\r\n4...#...............\r\n.#8.......#.....S...\r\n........#.....#.....\r\n.#.##....#....3...#.\r\n...........#........\r\n..............#..#..\r\n.....6.#........#...\r\n.............#.....#\r\n#........#.....#..#.\r\n....###.#......#....\r\n..#.................\r\n#.#........#.###.#..\r\n....#.............1.\r\n.###............#...\r\n...............#...#\r\n.........#.#.....5..\r\n.......#.#..7...2.#.\r\n..........#...#.....\r\n.....#..............\r\n128\r\n91\r\n116\r\n-39\r\n-29\r\n-39\r\n85\r\n171\r\n", "output": ["335"]}, {"input": "20 20\r\n......#..#........#.\r\n##..................\r\n..#..#.....S......##\r\n..##.#.....B..#.#...\r\n#....#.......##...#.\r\n.........#.....##...\r\n.##.#.#......###....\r\n###.#..##......#....\r\n................#...\r\n.#...#...........#.#\r\n.#.#.....#........#.\r\n..#..###..#..#......\r\n.....#..#####..#....\r\n.....###.#.....B...B\r\n.....2...#...####.#.\r\n...1.##.#.4.##...#..\r\n##........#.#...##.#\r\n....##...#.#.#..#...\r\n##....B.#.###....#..\r\n...#3.#..#.##.....#.\r\n-36\r\n81\r\n169\r\n16\r\n", "output": ["0"]}, {"input": "20 20\r\n..#..##..##......#..\r\n...#..#..#..##......\r\n....S...#...#....#..\r\n#.#.....###...#...##\r\n##.....##...#..#####\r\n.#..#...........6#..\r\n....#...8.#..#......\r\n.#..5#.#......#.#...\r\n#...........3.#.#...\r\n.##.....##.........#\r\n...##.#....#.##.#...\r\n...............####.\r\n.#.........#...#...2\r\n#.#.#..#.#.#.#......\r\n#.#.1...............\r\n.#....4#......##..#.\r\n.#....#.......#...#.\r\n#........##......#.#\r\n#..###..7#....#..#.#\r\n#...#......#......#.\r\n-22\r\n-65\r\n-29\r\n71\r\n128\r\n-75\r\n180\r\n154\r\n", "output": ["483"]}, {"input": "10 11\r\n...........\r\n.5.........\r\n.7.....#...\r\n..6..4#....\r\n#.....1....\r\n....3......\r\n..2....#...\r\n#.#......#.\r\n.....S.....\r\n...........\r\n12\r\n36\r\n-31\r\n53\r\n-30\r\n-30\r\n-20\r\n", "output": ["69"]}, {"input": "20 20\r\n....................\r\n....................\r\n....................\r\n....................\r\n....................\r\n....................\r\n....3####...........\r\n....#....#..........\r\n....#.B..#..........\r\n....#....#..........\r\n.....###......####2.\r\n..............#...#.\r\n.....1####....#.B.#.\r\n.....#...#....#.....\r\n.....#.B.#.....#....\r\n.....#..............\r\n......###...........\r\n....................\r\n....................\r\n...................S\r\n100\r\n101\r\n102\r\n", "output": ["201"]}, {"input": "20 20\r\n....................\r\n....................\r\n....................\r\n...........4###.....\r\n...........#...#....\r\n...........#.B.#....\r\n....3####..#...#....\r\n....#....#.#..#.....\r\n....#.B..#.#.#......\r\n....#....#..........\r\n.....###......####2.\r\n..............#...#.\r\n.....1####....#.B.#.\r\n.....#...#....#.....\r\n.....#.B.#.....#....\r\n.....#..............\r\n......###...........\r\n....................\r\n....................\r\n...................S\r\n100\r\n101\r\n102\r\n103\r\n", "output": ["274"]}]
100
100
100
[{'input': '20 20\r\n........#...........\r\n...#.......#.#.....#\r\n....................\r\n.#........#.........\r\n....................\r\n..#....#.3..........\r\n.....#..#......#....\r\n....#..............1\r\n.#.........#.....##.\r\n#2..................\r\n.............#......\r\n..#.................\r\n......8..........##.\r\n...........7........\r\n...................4\r\n........#.........5S\r\n...........#........\r\n.....#...........#..\r\n..................6.\r\n....................\r\n25\r\n-21\r\n-2\r\n27\r\n49\r\n-23\r\n6\r\n45\r\n', 'output': ['11']}, {'input': '10 10\r\n..........\r\n...5##....\r\n.##..#....\r\n.....2....\r\n...S.B....\r\n..........\r\n.3..B1.#..\r\n.......#..\r\n...B...4..\r\n...#.....#\r\n100\r\n10\r\n14\r\n11\r\n20\r\n', 'output': ['2']}, {'input': '10 10\r\n..........\r\n..1......#\r\n.....2.4.#\r\n........#.\r\n.......S..\r\n..........\r\n.#...3....\r\n..7....6#.\r\n..........\r\n....8...5.\r\n38\r\n8\r\n74\r\n24\r\n32\r\n50\r\n74\r\n27\r\n', 'output': ['210']}, {'input': '12 12\r\n............\r\n......B.....\r\n........1...\r\n............\r\n.......4....\r\n..B#..S.....\r\n............\r\n............\r\n.2...#......\r\n.....B......\r\nB..........#\r\n.......3....\r\n5\r\n-5\r\n33\r\n-9\r\n', 'output': ['0']}, {'input': '12 12\r\n......B.....\r\n....B...S#..\r\n#....#......\r\n........#...\r\n............\r\n....#...B.B.\r\n.#.....#..#.\r\n..##........\r\n...#.......B\r\n.##.1....#..\r\n#...B......#\r\n..##...B....\r\n42\r\n', 'output': ['0']}]
[{'input': '10 11\r\n##.#.###.#.\r\n.1###.#.5##\r\n##.....#.##\r\n#.#.#######\r\n#4#7##.##.#\r\n.###.###.#.\r\n..#S.#.####\r\n..2###.####\r\n.....##..6#\r\n.3##..###..\r\n50\r\n-21\r\n-6\r\n5\r\n29\r\n56\r\n42\r\n', 'output': ['0']}, {'input': '20 20\r\n.............#..#..#\r\n.5..................\r\n.#........#.#B...#..\r\n#.###..B........#.##\r\n.............###.1..\r\n..#...2.....#....#..\r\n....................\r\n.........#4..#......\r\n#......#....#..#..#.\r\n.#.....#.........#.#\r\n.........#.#.#......\r\n.........#..##......\r\n#........#......#.3.\r\n.#............#.###.\r\n.........#.#.#......\r\n##.#....###...#.....\r\n....##......#B......\r\n...#.....##..#......\r\n.#......##.S......#.\r\n...#.....#....#...##\r\n-23\r\n26\r\n-10\r\n-11\r\n30\r\n', 'output': ['0']}, {'input': '20 20\r\n.#.######..##.#.....\r\n.......#....##...##.\r\n.#......#7.....#....\r\n##..#..#6........#..\r\n..#.##.##..#..##...#\r\n##............##....\r\n.....#..#........#.#\r\n.#............#..#..\r\n.#.#..##..#.#...#2..\r\n..................#.\r\n.....#1.###......#..\r\n....#..#...#.#....##\r\n..#.#...##...##..4#.\r\n..##.#####.##.#.###.\r\n#...##.3....#.#..##.\r\n..##.......##..#..##\r\n........#..#8...###.\r\n........#..#.#5.....\r\n#.####.....#.#.#...#\r\n.S...#...###.#.#..#.\r\n98\r\n96\r\n52\r\n-35\r\n-79\r\n47\r\n80\r\n-49\r\n', 'output': ['108']}, {'input': '20 20\r\n.....#.........#....\r\n..#..##...##........\r\n..........#.#.#.#...\r\n.#.............#....\r\n..............#.....\r\nS#......8..#..#.....\r\n..........###....#..\r\n....#....#...##...##\r\n....#......#.#......\r\n#..#.6..#...........\r\n...#.........3...#..\r\n.......#........#...\r\n...............#....\r\n.....#..21.....#...#\r\n#...........#....#.#\r\n........4.....#...7.\r\n..#..........#......\r\n#................#5.\r\n.##.......#.........\r\n...#...#..........#.\r\n79\r\n-16\r\n28\r\n-16\r\n92\r\n61\r\n60\r\n-38\r\n', 'output': ['180']}, {'input': '20 20\r\n.#.##.##...#.####...\r\n.#.#.......#......#.\r\n#.#...#.....#......#\r\n.##.8.##.#....##..##\r\n##..#..#.#.#....#.##\r\n##.#.#####.#.#.#...#\r\n.....4.###...###.#.#\r\n##.####.##.#.#...#..\r\n.#..#.##..#.#..#....\r\n..#.#.##...##..#....\r\n#..##..#..#.....#.##\r\n...#.##....#####...#\r\n...6#5..#....#......\r\n###...#.#.#..##.....\r\n#..#....##.##.###..#\r\n..#.##...##..#######\r\n.#.##.2#.3.....#..##\r\n#....#.#7#.##.#....S\r\n##.#.......#...#.#..\r\n..##.####1.#####.#..\r\n16\r\n67\r\n-19\r\n15\r\n35\r\n55\r\n30\r\n-23\r\n', 'output': ['0']}]
[{'input': '20 20\r\n....#.#.........#...\r\n..##.#.......#.#....\r\n..#......##.#.#...#.\r\n.S##..#.....##...#..\r\n.#...#.......#B#....\r\n#...#......#...##...\r\n...#..........B.#.#.\r\n...........3.#...##.\r\n............#...B#..\r\n..#..#...#.....1....\r\n.....#......#.......\r\n...#...#...##..#.#..\r\n##........#.........\r\n.#....#......#...#..\r\n#.#..#..#...#....2..\r\n.##..........#...#..\r\n..#...........4.....\r\n....#.##.....#..#.B.\r\n#...#..###.#.#....##\r\n............#.......\r\n47\r\n-28\r\n8\r\n-24\r\n', 'output': ['0']}, {'input': '10 11\r\n...#...##.#\r\n........##.\r\n5.#..#.S.#.\r\n#..........\r\n.....#..#.7\r\n6...4......\r\n#..3###2.#.\r\n.#...##.##.\r\n.#.#...1...\r\n.....#.#...\r\n-34\r\n38\r\n1\r\n-8\r\n58\r\n50\r\n50\r\n', 'output': ['0']}, {'input': '10 10\r\n...#...#..\r\n...1...#..\r\n.#..3..#..\r\n..#5.7..#.\r\n.4#...##..\r\n....#.#...\r\n..##.#...6\r\n.S.......#\r\n#........#\r\n2#.#B.....\r\n12\r\n30\r\n57\r\n37\r\n80\r\n14\r\n5\r\n', 'output': ['0']}, {'input': '20 20\r\nB.......##..#.#.....\r\n.....#.#....2....#.#\r\n#...##...##..##...#.\r\n.#........1......##.\r\n.......#.##.......##\r\n.#B.#...#..#...#....\r\n#..#.#.......##.#..#\r\n...#..#.###........#\r\n..S....#.#.#.#......\r\n.....#..##....#.#.#.\r\n#B#..#..............\r\n.#3..4#.#.##........\r\n#####.#.............\r\n......###........###\r\n.#........#....#...#\r\n.........#..#..#....\r\n##..#......###.#...#\r\n..#.#..###.....#####\r\n#.#....#.......#...#\r\n..#...#B#.###.#...#.\r\n35\r\n-17\r\n0\r\n-2\r\n', 'output': ['0']}, {'input': '10 11\r\n###..#..##7\r\n..#.#.4#.##\r\n......5...#\r\n.#.1#......\r\n.#.#.......\r\n.#....#.#..\r\n##.######62\r\n##...#3....\r\n.#.#..#..##\r\nS....##..#.\r\n-6\r\n-23\r\n-15\r\n12\r\n40\r\n-3\r\n30\r\n', 'output': ['0']}]
[{'input': '8 8\r\n..#.....\r\n...#....\r\n.4....1#\r\n..3.....\r\n#B....B.\r\n......B.\r\n.#..B.2.\r\n##.S#...\r\n36\r\n9\r\n10\r\n-6\r\n', 'output': ['0']}, {'input': '10 11\r\n.....##.##.\r\n#.#.#.S..#.\r\n....#....##\r\n.3.##.2.7..\r\n.#..#....4#\r\n#.####..#.#\r\n...#....5.#\r\n.6.##...#.#\r\n..##..#..##\r\n.#1##..#.##\r\n38\r\n-37\r\n-2\r\n-27\r\n29\r\n47\r\n-14\r\n', 'output': ['0']}, {'input': '10 11\r\n###.#4.#.#.\r\n#.....#.#.#\r\n.#..#####..\r\n#.#..#6.##.\r\n#..23##..##\r\n##..##....#\r\n#..##....7.\r\n#.###.#.#.#\r\n#.S##5#..#1\r\n###.#..##..\r\n4\r\n15\r\n30\r\n-18\r\n-30\r\n38\r\n40\r\n', 'output': ['0']}, {'input': '12 12\r\n...........#\r\n.#..#...B.#.\r\n1...........\r\n3........#..\r\n.....B......\r\n#.........#B\r\n....B2......\r\n.#.....#....\r\n............\r\n4S.........#\r\n...##.#...#.\r\n.....##..#..\r\n37\r\n39\r\n1\r\n32\r\n', 'output': ['0']}, {'input': '10 11\r\n........S..\r\n...........\r\n5........1.\r\n.7#........\r\n...64.#....\r\n...........\r\n..........#\r\n.2.........\r\n.....3.....\r\n...........\r\n-9\r\n33\r\n9\r\n-20\r\n12\r\n10\r\n-29\r\n', 'output': ['8']}]
[{'input': '20 20\r\n...##...#..#...3.#..\r\n.......##4#.##.#.##.\r\n...#....#....#....#.\r\n.##...#.#.##.###.#..\r\n.##......5...#....##\r\n.#..#.#.#.#.......1.\r\n##.##..#.##.#..#...S\r\n....#.....#.##......\r\n...2...#........#..#\r\n..8#....#.##...#.#..\r\n.....7.#..#.....#...\r\n.#...##......#.#.6..\r\n......#...###..#...#\r\n....#..#............\r\n......#..#.#....#...\r\n#....##.#....#......\r\n.##.......###.#.##.#\r\n..#.....####.#..#...\r\n#...#...#..##.....#.\r\n.......#.#.#..#.#.#.\r\n58\r\n83\r\n96\r\n66\r\n69\r\n60\r\n7\r\n10\r\n', 'output': ['96']}, {'input': '20 20\r\n#................#..\r\n................#.#.\r\n.....##...#.3.7#.#..\r\n......S..#.#........\r\n....4##.#.....1..#..\r\n#..#...#.#..........\r\n..##........##.#....\r\n.2#...##....##....##\r\n##.5..#..#.#..#.#..#\r\n..#.##...#......#...\r\n.......#...#......##\r\n..............##.#.#\r\n.6..##.#........#.#.\r\n.#..#.#.#........#..\r\n......#.#..........#\r\n.#.#....#........#..\r\n..#...........8.##..\r\n...........#...#..#.\r\n.#..........#...#...\r\n#..#..#.#....###....\r\n-28\r\n86\r\n19\r\n56\r\n-43\r\n11\r\n21\r\n-21\r\n', 'output': ['0']}, {'input': '12 12\r\n..#.B#......\r\n##...#...#..\r\n.....#.#.1#.\r\n.....#.#B...\r\nB.....S.....\r\n#..........#\r\n.#......B...\r\n...#.##.#...\r\n..#.....#...\r\n....#.......\r\n........B...\r\n..B.##....B.\r\n4\r\n', 'output': ['0']}, {'input': '12 12\r\n.....#......\r\n.....##B...#\r\n.........3..\r\n......#.....\r\n...........#\r\n.....B.....S\r\n...#2.......\r\n...........1\r\n............\r\n..........4.\r\n............\r\n...B.....B..\r\n25\r\n9\r\n-3\r\n4\r\n', 'output': ['0']}, {'input': '10 11\r\n#......#..4\r\n#.#..##....\r\n##.....##.#\r\n#1..#....##\r\n..#.#.#.#.#\r\n##..#6.#.##\r\n#7#...2..#5\r\n..#.#.#....\r\n.#..S.#3.#.\r\n..###.##.##\r\n-33\r\n-39\r\n58\r\n20\r\n33\r\n54\r\n-25\r\n', 'output': ['0']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
156
100
100
100
["2 5", "3 3", "5 4", "13 37"]
The only line contains two integers $$$n$$$ and $$$x$$$ ($$$2 \le n \le 500; 1 \le x \le 500$$$).
1908d1c8c6b122a4c6633a7af094f17f
#include<bits/stdc++.h> using namespace std; #define int long long #define lr(a) memset(a,0,sizeof(a)) const int N=550,mod=998244353; int n,x,C[N][N],pw[N][N]; //组合数&幂 int dp[N][N],ans; //dp[n][x] void init(){ lr(dp),lr(pw),lr(C); for(int i=0;i<=510;i++)C[i][0]=pw[i][0]=1; //还有这里!i要从0开始,不然C[n][n]就等于0鸟QWQWQWQ for(int i=1;i<=510;i++) for(int j=1;j<=510;j++) C[i][j]=(C[i-1][j-1]+C[i-1][j]+mod)%mod, pw[i][j]=(pw[i][j-1]*i+mod)%mod; scanf("%lld%lld",&n,&x); } int solve(){ for(int peo=2;peo<=n;peo++){ for(int i=1;i<=x;i++){ if(i<=peo-1)dp[peo][i]=(pw[i][peo]-pw[i-1][peo]+mod)%mod; //错在这里了! i和peo刚开始写反了!qwq else{ for(int k=2;k<=peo;k++){ dp[peo][i]=(dp[peo][i]+dp[k][i-(peo-1)]%mod*C[peo][k]%mod*pw[peo-1][peo-k]+mod)%mod; } } } } for(int maxn=1;maxn<=x;maxn++){ ans=(ans+dp[n][maxn]+mod)%mod; } return ans; } signed main(){ init(); printf("%lld\n",solve()); }
["5", "15", "1024", "976890680"]
C++
null
Print one integer — the number of ways to choose the initial health points for each hero $$$a_i$$$, where $$$1 \le a_i \le x$$$, so that there is no winner of the fight, taken modulo $$$998244353$$$.
There are $$$n$$$ heroes fighting in the arena. Initially, the $$$i$$$-th hero has $$$a_i$$$ health points.The fight in the arena takes place in several rounds. At the beginning of each round, each alive hero deals $$$1$$$ damage to all other heroes. Hits of all heroes occur simultaneously. Heroes whose health is less than $$$1$$$ at the end of the round are considered killed.If exactly $$$1$$$ hero remains alive after a certain round, then he is declared the winner. Otherwise, there is no winner.Your task is to calculate the number of ways to choose the initial health points for each hero $$$a_i$$$, where $$$1 \le a_i \le x$$$, so that there is no winner of the fight. The number of ways can be very large, so print it modulo $$$998244353$$$. Two ways are considered different if at least one hero has a different amount of health. For example, $$$[1, 2, 1]$$$ and $$$[2, 1, 1]$$$ are different.
[{"input": "2 5\n", "output": ["5\n", "5 \n", "5", "5\n\n", "5\n", "5 \n\n"]}, {"input": "3 3\n", "output": ["15\n\n", "15 \n\n", "15", "15\n", "15\n", "15 \n"]}, {"input": "5 4\n", "output": ["1024 \n\n", "1024", "1024\n", "1024\n\n", "1024\n", "1024 \n"]}, {"input": "13 37\n", "output": ["976890680\n\n", "976890680\n", "976890680 \n", "976890680 \n\n", "976890680", "976890680\n"]}, {"input": "5 40\n", "output": ["6613840 \n\n", "6613840", "6613840\n\n", "6613840\n", "6613840 \n", "6613840\n"]}, {"input": "4 33\n", "output": ["74061\n", "74061", "74061\n", "74061 \n", "74061 \n\n", "74061\n\n"]}, {"input": "6 26\n", "output": ["37929526\n", "37929526\n\n", "37929526 \n", "37929526 \n\n", "37929526", "37929526\n"]}, {"input": "7 22\n", "output": ["433133716\n", "433133716", "433133716\n\n", "433133716 \n", "433133716\n", "433133716 \n\n"]}, {"input": "10 15\n", "output": ["801988713 \n\n", "801988713\n", "801988713", "801988713\n\n", "801988713\n", "801988713 \n"]}, {"input": "2 500\n", "output": ["500\n", "500", "500 \n", "500\n", "500\n\n", "500 \n\n"]}, {"input": "3 500\n", "output": ["375500 \n", "375500", "375500\n", "375500\n\n", "375500\n", "375500 \n\n"]}, {"input": "4 500\n", "output": ["250499992 \n\n", "250499992 \n", "250499992", "250499992\n", "250499992\n", "250499992\n\n"]}, {"input": "5 500\n", "output": ["940552292\n", "940552292 \n\n", "940552292\n\n", "940552292\n", "940552292", "940552292 \n"]}, {"input": "8 333\n", "output": ["97191222 \n", "97191222", "97191222\n", "97191222\n\n", "97191222\n", "97191222 \n\n"]}, {"input": "6 478\n", "output": ["28573939\n\n", "28573939", "28573939 \n", "28573939 \n\n", "28573939\n", "28573939\n"]}, {"input": "11 345\n", "output": ["932713620\n", "932713620 \n", "932713620 \n\n", "932713620\n", "932713620", "932713620\n\n"]}, {"input": "15 255\n", "output": ["259067064 \n", "259067064 \n\n", "259067064", "259067064\n\n", "259067064\n", "259067064\n"]}, {"input": "13 337\n", "output": ["434551606 \n\n", "434551606", "434551606\n", "434551606\n", "434551606 \n", "434551606\n\n"]}, {"input": "10 500\n", "output": ["263020220 \n\n", "263020220", "263020220\n\n", "263020220 \n", "263020220\n", "263020220\n"]}, {"input": "25 500\n", "output": ["571274201\n", "571274201\n", "571274201", "571274201 \n\n", "571274201 \n", "571274201\n\n"]}, {"input": "49 499\n", "output": ["816854007", "816854007\n", "816854007 \n", "816854007\n\n", "816854007\n", "816854007 \n\n"]}, {"input": "50 500\n", "output": ["165073862\n\n", "165073862\n", "165073862 \n\n", "165073862 \n", "165073862\n", "165073862"]}, {"input": "99 499\n", "output": ["796227309\n\n", "796227309 \n", "796227309 \n\n", "796227309\n", "796227309\n", "796227309"]}, {"input": "99 500\n", "output": ["424278934 \n\n", "424278934\n", "424278934 \n", "424278934\n", "424278934", "424278934\n\n"]}, {"input": "111 500\n", "output": ["802132036\n", "802132036", "802132036 \n\n", "802132036 \n", "802132036\n", "802132036\n\n"]}, {"input": "154 500\n", "output": ["924911664\n\n", "924911664", "924911664\n", "924911664\n", "924911664 \n", "924911664 \n\n"]}, {"input": "200 500\n", "output": ["458968932", "458968932\n\n", "458968932\n", "458968932 \n", "458968932\n", "458968932 \n\n"]}, {"input": "222 500\n", "output": ["382157018\n", "382157018 \n", "382157018", "382157018 \n\n", "382157018\n\n", "382157018\n"]}, {"input": "285 499\n", "output": ["987275082 \n\n", "987275082\n\n", "987275082 \n", "987275082\n", "987275082", "987275082\n"]}, {"input": "300 500\n", "output": ["567125736\n", "567125736 \n\n", "567125736\n", "567125736", "567125736 \n", "567125736\n\n"]}, {"input": "365 500\n", "output": ["552203508\n", "552203508 \n", "552203508 \n\n", "552203508\n", "552203508", "552203508\n\n"]}, {"input": "444 500\n", "output": ["563065086", "563065086\n", "563065086\n\n", "563065086 \n", "563065086\n", "563065086 \n\n"]}, {"input": "444 499\n", "output": ["835857576 \n\n", "835857576\n", "835857576 \n", "835857576\n", "835857576\n\n", "835857576"]}, {"input": "500 333\n", "output": ["736893443\n", "736893443", "736893443\n\n", "736893443\n", "736893443 \n", "736893443 \n\n"]}, {"input": "500 500\n", "output": ["587613361\n", "587613361", "587613361\n\n", "587613361 \n\n", "587613361\n", "587613361 \n"]}, {"input": "499 499\n", "output": ["772771385", "772771385\n", "772771385 \n\n", "772771385\n\n", "772771385\n", "772771385 \n"]}, {"input": "111 222\n", "output": ["460833105 \n", "460833105\n", "460833105\n", "460833105", "460833105\n\n", "460833105 \n\n"]}, {"input": "123 433\n", "output": ["632273638\n", "632273638\n", "632273638", "632273638 \n", "632273638 \n\n", "632273638\n\n"]}, {"input": "383 477\n", "output": ["158983764", "158983764\n", "158983764\n\n", "158983764\n", "158983764 \n\n", "158983764 \n"]}, {"input": "99 333\n", "output": ["897436821\n", "897436821\n\n", "897436821 \n", "897436821", "897436821 \n\n", "897436821\n"]}, {"input": "484 497\n", "output": ["320480021 \n\n", "320480021", "320480021\n", "320480021\n\n", "320480021\n", "320480021 \n"]}, {"input": "411 77\n", "output": ["525290835 \n", "525290835", "525290835\n\n", "525290835 \n\n", "525290835\n", "525290835\n"]}, {"input": "124 212\n", "output": ["806210307\n", "806210307", "806210307 \n\n", "806210307\n\n", "806210307\n", "806210307 \n"]}, {"input": "369 404\n", "output": ["345642117 \n\n", "345642117 \n", "345642117", "345642117\n\n", "345642117\n", "345642117\n"]}, {"input": "246 389\n", "output": ["778435960\n", "778435960 \n", "778435960\n\n", "778435960 \n\n", "778435960\n", "778435960"]}, {"input": "92 270\n", "output": ["125864547\n\n", "125864547 \n\n", "125864547 \n", "125864547", "125864547\n", "125864547\n"]}, {"input": "271 208\n", "output": ["80367024\n", "80367024", "80367024\n\n", "80367024 \n", "80367024 \n\n", "80367024\n"]}, {"input": "289 466\n", "output": ["807999264\n", "807999264 \n\n", "807999264 \n", "807999264", "807999264\n\n", "807999264\n"]}, {"input": "249 320\n", "output": ["405917309 \n", "405917309 \n\n", "405917309\n", "405917309\n", "405917309", "405917309\n\n"]}, {"input": "91 367\n", "output": ["369540872\n", "369540872\n", "369540872 \n", "369540872\n\n", "369540872", "369540872 \n\n"]}, {"input": "39 78\n", "output": ["146956559 \n", "146956559\n", "146956559", "146956559\n\n", "146956559 \n\n", "146956559\n"]}, {"input": "465 367\n", "output": ["135201268\n", "135201268\n", "135201268", "135201268 \n\n", "135201268 \n", "135201268\n\n"]}, {"input": "34 177\n", "output": ["771060153 \n\n", "771060153 \n", "771060153\n", "771060153\n", "771060153", "771060153\n\n"]}, {"input": "460 235\n", "output": ["27900542\n", "27900542 \n\n", "27900542\n", "27900542 \n", "27900542\n\n", "27900542"]}, {"input": "421 44\n", "output": ["312830719\n\n", "312830719", "312830719 \n\n", "312830719\n", "312830719 \n", "312830719\n"]}, {"input": "390 208\n", "output": ["709071139\n", "709071139 \n\n", "709071139\n", "709071139\n\n", "709071139 \n", "709071139"]}, {"input": "251 203\n", "output": ["921135826\n\n", "921135826", "921135826\n", "921135826 \n\n", "921135826 \n", "921135826\n"]}, {"input": "191 22\n", "output": ["285057520", "285057520 \n", "285057520\n", "285057520\n\n", "285057520 \n\n", "285057520\n"]}, {"input": "198 236\n", "output": ["93097976\n\n", "93097976", "93097976\n", "93097976 \n\n", "93097976 \n", "93097976\n"]}, {"input": "376 314\n", "output": ["795015160\n", "795015160\n", "795015160 \n", "795015160", "795015160 \n\n", "795015160\n\n"]}, {"input": "26 178\n", "output": ["373528200\n", "373528200 \n", "373528200", "373528200 \n\n", "373528200\n\n", "373528200\n"]}, {"input": "189 92\n", "output": ["283119998\n", "283119998\n\n", "283119998\n", "283119998", "283119998 \n\n", "283119998 \n"]}, {"input": "13 93\n", "output": ["962803010 \n", "962803010\n", "962803010\n\n", "962803010\n", "962803010 \n\n", "962803010"]}, {"input": "71 439\n", "output": ["299896905 \n\n", "299896905", "299896905\n", "299896905\n", "299896905 \n", "299896905\n\n"]}, {"input": "438 46\n", "output": ["312807374 \n\n", "312807374 \n", "312807374\n\n", "312807374\n", "312807374\n", "312807374"]}, {"input": "357 328\n", "output": ["186454845\n\n", "186454845 \n\n", "186454845\n", "186454845 \n", "186454845\n", "186454845"]}, {"input": "384 467\n", "output": ["946997121", "946997121 \n\n", "946997121\n", "946997121 \n", "946997121\n", "946997121\n\n"]}, {"input": "371 306\n", "output": ["512015273 \n", "512015273\n\n", "512015273 \n\n", "512015273", "512015273\n", "512015273\n"]}, {"input": "265 181\n", "output": ["178439722\n", "178439722", "178439722 \n\n", "178439722\n\n", "178439722\n", "178439722 \n"]}, {"input": "311 33\n", "output": ["836810892\n", "836810892\n", "836810892", "836810892 \n\n", "836810892 \n", "836810892\n\n"]}, {"input": "298 51\n", "output": ["631137022\n\n", "631137022 \n\n", "631137022", "631137022 \n", "631137022\n", "631137022\n"]}, {"input": "193 402\n", "output": ["490804249", "490804249\n", "490804249\n", "490804249 \n", "490804249 \n\n", "490804249\n\n"]}, {"input": "119 371\n", "output": ["207908744 \n\n", "207908744", "207908744\n", "207908744\n", "207908744\n\n", "207908744 \n"]}, {"input": "459 365\n", "output": ["266156666\n\n", "266156666\n", "266156666", "266156666\n", "266156666 \n", "266156666 \n\n"]}, {"input": "222 422\n", "output": ["858431457 \n", "858431457\n", "858431457\n", "858431457\n\n", "858431457", "858431457 \n\n"]}, {"input": "195 15\n", "output": ["518355052", "518355052 \n\n", "518355052 \n", "518355052\n\n", "518355052\n", "518355052\n"]}, {"input": "224 375\n", "output": ["555865043 \n", "555865043\n", "555865043", "555865043 \n\n", "555865043\n", "555865043\n\n"]}, {"input": "246 348\n", "output": ["875068738\n", "875068738 \n", "875068738\n", "875068738", "875068738\n\n", "875068738 \n\n"]}, {"input": "291 150\n", "output": ["491847623 \n\n", "491847623", "491847623\n\n", "491847623\n", "491847623 \n", "491847623\n"]}, {"input": "171 489\n", "output": ["316053655\n", "316053655 \n\n", "316053655 \n", "316053655", "316053655\n", "316053655\n\n"]}, {"input": "162 427\n", "output": ["10603436\n", "10603436\n\n", "10603436 \n", "10603436", "10603436\n", "10603436 \n\n"]}, {"input": "350 463\n", "output": ["580010430", "580010430\n", "580010430\n", "580010430 \n", "580010430\n\n", "580010430 \n\n"]}, {"input": "161 37\n", "output": ["141211019 \n\n", "141211019", "141211019\n", "141211019 \n", "141211019\n\n", "141211019\n"]}, {"input": "500 1\n", "output": ["1\n", "1", "1 \n\n", "1\n\n", "1 \n", "1\n"]}, {"input": "164 500\n", "output": ["411608690\n", "411608690 \n", "411608690\n\n", "411608690\n", "411608690 \n\n", "411608690"]}, {"input": "499 500\n", "output": ["724043052", "724043052 \n", "724043052\n", "724043052 \n\n", "724043052\n", "724043052\n\n"]}]
100
100
100
[{'input': '198 236\n', 'output': ['93097976\n\n', '93097976', '93097976\n', '93097976 \n\n', '93097976 \n', '93097976\n']}, {'input': '371 306\n', 'output': ['512015273 \n', '512015273\n\n', '512015273 \n\n', '512015273', '512015273\n', '512015273\n']}, {'input': '224 375\n', 'output': ['555865043 \n', '555865043\n', '555865043', '555865043 \n\n', '555865043\n', '555865043\n\n']}, {'input': '4 500\n', 'output': ['250499992 \n\n', '250499992 \n', '250499992', '250499992\n', '250499992\n', '250499992\n\n']}, {'input': '5 40\n', 'output': ['6613840 \n\n', '6613840', '6613840\n\n', '6613840\n', '6613840 \n', '6613840\n']}]
[{'input': '500 500\n', 'output': ['587613361\n', '587613361', '587613361\n\n', '587613361 \n\n', '587613361\n', '587613361 \n']}, {'input': '13 337\n', 'output': ['434551606 \n\n', '434551606', '434551606\n', '434551606\n', '434551606 \n', '434551606\n\n']}, {'input': '11 345\n', 'output': ['932713620\n', '932713620 \n', '932713620 \n\n', '932713620\n', '932713620', '932713620\n\n']}, {'input': '164 500\n', 'output': ['411608690\n', '411608690 \n', '411608690\n\n', '411608690\n', '411608690 \n\n', '411608690']}, {'input': '111 222\n', 'output': ['460833105 \n', '460833105\n', '460833105\n', '460833105', '460833105\n\n', '460833105 \n\n']}]
[{'input': '246 348\n', 'output': ['875068738\n', '875068738 \n', '875068738\n', '875068738', '875068738\n\n', '875068738 \n\n']}, {'input': '50 500\n', 'output': ['165073862\n\n', '165073862\n', '165073862 \n\n', '165073862 \n', '165073862\n', '165073862']}, {'input': '438 46\n', 'output': ['312807374 \n\n', '312807374 \n', '312807374\n\n', '312807374\n', '312807374\n', '312807374']}, {'input': '91 367\n', 'output': ['369540872\n', '369540872\n', '369540872 \n', '369540872\n\n', '369540872', '369540872 \n\n']}, {'input': '111 222\n', 'output': ['460833105 \n', '460833105\n', '460833105\n', '460833105', '460833105\n\n', '460833105 \n\n']}]
[{'input': '376 314\n', 'output': ['795015160\n', '795015160\n', '795015160 \n', '795015160', '795015160 \n\n', '795015160\n\n']}, {'input': '99 333\n', 'output': ['897436821\n', '897436821\n\n', '897436821 \n', '897436821', '897436821 \n\n', '897436821\n']}, {'input': '265 181\n', 'output': ['178439722\n', '178439722', '178439722 \n\n', '178439722\n\n', '178439722\n', '178439722 \n']}, {'input': '246 389\n', 'output': ['778435960\n', '778435960 \n', '778435960\n\n', '778435960 \n\n', '778435960\n', '778435960']}, {'input': '13 93\n', 'output': ['962803010 \n', '962803010\n', '962803010\n\n', '962803010\n', '962803010 \n\n', '962803010']}]
[{'input': '5 500\n', 'output': ['940552292\n', '940552292 \n\n', '940552292\n\n', '940552292\n', '940552292', '940552292 \n']}, {'input': '71 439\n', 'output': ['299896905 \n\n', '299896905', '299896905\n', '299896905\n', '299896905 \n', '299896905\n\n']}, {'input': '3 500\n', 'output': ['375500 \n', '375500', '375500\n', '375500\n\n', '375500\n', '375500 \n\n']}, {'input': '99 499\n', 'output': ['796227309\n\n', '796227309 \n', '796227309 \n\n', '796227309\n', '796227309\n', '796227309']}, {'input': '154 500\n', 'output': ['924911664\n\n', '924911664', '924911664\n', '924911664\n', '924911664 \n', '924911664 \n\n']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
157
100
100
100
["1 1", "2 1", "3 2"]
The first and the only line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^5, 1 \le k \le \min(2^n - 1, 10^9)$$$) — the number of rounds in the tournament and the number of outcomes that sponsors can change.
dc7b887afcc2e95c4e90619ceda63071
#include <cstdio> #include <algorithm> using LL = long long; const int N = 1e5 + 100, P = 1e9 + 7; int n, num; int fac[N], ifac[N]; int ans = 0; int qpow(int x, int y = P - 2) { int res = 1; for (; y; y >>= 1, x = LL(x) * x % P) if (y & 1) res = LL(x) * res % P; return res; } void adj(int &x){ x += (x >> 31) & P; } int C(int x, int y){ return LL(fac[x]) * ifac[y] % P * ifac[x - y] % P; } int main() { scanf("%d %d", &n, &num); fac[0] = fac[1] = ifac[0] = ifac[1] = 1; for (int i = 2; i <= n; ++i) fac[i] = LL(i) * fac[i - 1] % P; ifac[n] = qpow(fac[n]); for (int i = n - 1; i > 1; --i) ifac[i] = LL(i + 1) * ifac[i + 1] % P; num = std::min(n, num); for (int i = 0; i <= num; ++i) adj(ans += C(n, i) - P); printf("%d\n", ans); return 0; }
["2", "3", "7"]
C++
NoteIn the first example, there is only one match between players $$$1$$$ and $$$2$$$, so the sponsors can always make player $$$2$$$ wins.The tournament grid from the second example is shown in the picture in the statement.
Print exactly one integer — the minimum number of the winner modulo $$$10^9 + 7$$$
Madoka decided to entrust the organization of a major computer game tournament "OSU"!In this tournament, matches are held according to the "Olympic system". In other words, there are $$$2^n$$$ participants in the tournament, numbered with integers from $$$1$$$ to $$$2^n$$$. There are $$$n$$$ rounds in total in the tournament. In the $$$i$$$-th round there are $$$2^{n - i}$$$ matches between two players (one of whom is right, the other is left), after which the winners go further along the tournament grid, and the losing participants are eliminated from the tournament. Herewith, the relative order in the next round does not change. And the winner of the tournament — is the last remaining participant.But the smaller the participant's number, the more he will pay Madoka if he wins, so Madoka wants the participant with the lowest number to win. To do this, she can arrange the participants in the first round as she likes, and also determine for each match who will win — the participant on the left or right.But Madoka knows that tournament sponsors can change the winner in matches no more than $$$k$$$ times. (That is, if the participant on the left won before the change, then the participant on the right will win after the change, and if the participant on the right won, then the participant on the left will win after the change). So, the first image shows the tournament grid that Madoka made, where the red lines denote who should win the match. And the second one shows the tournament grid, after one change in the outcome of the match by sponsors (a match between $$$1$$$ and $$$3$$$ players). Print the minimum possible number of the winner in the tournament, which Madoka can get regardless of changes in sponsors. But since the answer can be very large, output it modulo $$$10^9 + 7$$$. Note that we need to minimize the answer, and only then take it modulo.
[{"input": "1 1\n", "output": ["2\n", "2 ", "2", "2 \n", "2\n\n", "\n2", "2\n\n", "2\n"]}, {"input": "2 1\n", "output": ["\n3\n", "\n3", "3\n\n", "3 \n", "3\n\n", "3 ", "3\n", "3\n", "3"]}, {"input": "3 2\n", "output": ["7", "7\n\n", "\n7\n", "7\n", "7 ", "7 \n", "7\n\n", "\n7", "7\n"]}, {"input": "5 3\n", "output": ["\n26", "26 \n", "26", "26\n", "\n26\n", "26\n\n", "26 ", "26\n\n", "26\n"]}, {"input": "5 5\n", "output": ["32 \n", "\n32", "32 ", "32\n\n", "32", "32\n", "32\n\n", "32\n"]}, {"input": "5 31\n", "output": ["32 \n", "\n32", "32 ", "32\n\n", "32", "32\n", "32\n\n", "32\n"]}, {"input": "11994 11995\n", "output": ["685385528 \n", "685385528 ", "685385528\n", "685385528\n", "685385528\n\n", "\n685385528", "685385528\n\n", "685385528"]}, {"input": "99999 3123\n", "output": ["575224395\n", "575224395\n\n", "575224395 ", "575224395\n", "\n575224395\n", "575224395", "\n575224395", "575224395 \n", "575224395\n\n"]}, {"input": "100000 1000000000\n", "output": ["607723520\n", "607723520\n", "\n607723520", "607723520\n\n", "607723520\n\n", "607723520 ", "607723520", "607723520 \n"]}, {"input": "100000 1\n", "output": ["100001 \n", "100001", "\n100001", "100001\n\n", "100001 ", "100001\n", "100001\n\n", "\n100001\n", "100001\n"]}, {"input": "100000 13\n", "output": ["185515077\n", "\n185515077", "185515077", "185515077\n", "\n185515077\n", "185515077 \n", "185515077 ", "185515077\n\n", "185515077\n\n"]}, {"input": "100000 53228\n", "output": ["871774727", "871774727\n\n", "\n871774727\n", "871774727 ", "871774727 \n", "871774727\n", "\n871774727", "871774727\n\n", "871774727\n"]}, {"input": "87532 32150\n", "output": ["\n165162987", "165162987\n", "165162987", "165162987 \n", "165162987\n", "\n165162987\n", "165162987\n\n", "165162987\n\n", "165162987 "]}, {"input": "30 99999999\n", "output": ["73741817\n\n", "73741817\n", "73741817\n\n", "73741817", "73741817 ", "\n73741817", "73741817 \n", "73741817\n"]}]
100
100
100
[{'input': '100000 13\n', 'output': ['185515077\n', '\n185515077', '185515077', '185515077\n', '\n185515077\n', '185515077 \n', '185515077 ', '185515077\n\n', '185515077\n\n']}, {'input': '1 1\n', 'output': ['2\n', '2 ', '2', '2 \n', '2\n\n', '\n2', '2\n\n', '2\n']}, {'input': '5 31\n', 'output': ['32 \n', '\n32', '32 ', '32\n\n', '32', '32\n', '32\n\n', '32\n']}, {'input': '3 2\n', 'output': ['7', '7\n\n', '\n7\n', '7\n', '7 ', '7 \n', '7\n\n', '\n7', '7\n']}, {'input': '11994 11995\n', 'output': ['685385528 \n', '685385528 ', '685385528\n', '685385528\n', '685385528\n\n', '\n685385528', '685385528\n\n', '685385528']}]
[{'input': '99999 3123\n', 'output': ['575224395\n', '575224395\n\n', '575224395 ', '575224395\n', '\n575224395\n', '575224395', '\n575224395', '575224395 \n', '575224395\n\n']}, {'input': '5 5\n', 'output': ['32 \n', '\n32', '32 ', '32\n\n', '32', '32\n', '32\n\n', '32\n']}, {'input': '100000 1\n', 'output': ['100001 \n', '100001', '\n100001', '100001\n\n', '100001 ', '100001\n', '100001\n\n', '\n100001\n', '100001\n']}, {'input': '3 2\n', 'output': ['7', '7\n\n', '\n7\n', '7\n', '7 ', '7 \n', '7\n\n', '\n7', '7\n']}, {'input': '100000 13\n', 'output': ['185515077\n', '\n185515077', '185515077', '185515077\n', '\n185515077\n', '185515077 \n', '185515077 ', '185515077\n\n', '185515077\n\n']}]
[{'input': '5 5\n', 'output': ['32 \n', '\n32', '32 ', '32\n\n', '32', '32\n', '32\n\n', '32\n']}, {'input': '2 1\n', 'output': ['\n3\n', '\n3', '3\n\n', '3 \n', '3\n\n', '3 ', '3\n', '3\n', '3']}, {'input': '5 31\n', 'output': ['32 \n', '\n32', '32 ', '32\n\n', '32', '32\n', '32\n\n', '32\n']}, {'input': '100000 13\n', 'output': ['185515077\n', '\n185515077', '185515077', '185515077\n', '\n185515077\n', '185515077 \n', '185515077 ', '185515077\n\n', '185515077\n\n']}, {'input': '11994 11995\n', 'output': ['685385528 \n', '685385528 ', '685385528\n', '685385528\n', '685385528\n\n', '\n685385528', '685385528\n\n', '685385528']}]
[{'input': '99999 3123\n', 'output': ['575224395\n', '575224395\n\n', '575224395 ', '575224395\n', '\n575224395\n', '575224395', '\n575224395', '575224395 \n', '575224395\n\n']}, {'input': '3 2\n', 'output': ['7', '7\n\n', '\n7\n', '7\n', '7 ', '7 \n', '7\n\n', '\n7', '7\n']}, {'input': '11994 11995\n', 'output': ['685385528 \n', '685385528 ', '685385528\n', '685385528\n', '685385528\n\n', '\n685385528', '685385528\n\n', '685385528']}, {'input': '100000 1\n', 'output': ['100001 \n', '100001', '\n100001', '100001\n\n', '100001 ', '100001\n', '100001\n\n', '\n100001\n', '100001\n']}, {'input': '100000 1000000000\n', 'output': ['607723520\n', '607723520\n', '\n607723520', '607723520\n\n', '607723520\n\n', '607723520 ', '607723520', '607723520 \n']}]
[{'input': '2 1\n', 'output': ['\n3\n', '\n3', '3\n\n', '3 \n', '3\n\n', '3 ', '3\n', '3\n', '3']}, {'input': '5 31\n', 'output': ['32 \n', '\n32', '32 ', '32\n\n', '32', '32\n', '32\n\n', '32\n']}, {'input': '87532 32150\n', 'output': ['\n165162987', '165162987\n', '165162987', '165162987 \n', '165162987\n', '\n165162987\n', '165162987\n\n', '165162987\n\n', '165162987 ']}, {'input': '100000 1000000000\n', 'output': ['607723520\n', '607723520\n', '\n607723520', '607723520\n\n', '607723520\n\n', '607723520 ', '607723520', '607723520 \n']}, {'input': '99999 3123\n', 'output': ['575224395\n', '575224395\n\n', '575224395 ', '575224395\n', '\n575224395\n', '575224395', '\n575224395', '575224395 \n', '575224395\n\n']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
158
100
100
100
["12 5", "31 12"]
The only line of the input contains two integers n and m (1 ≤ n, m ≤ 1018). n is the initial value of variable a, and m is the initial value of variable b.
1f505e430eb930ea2b495ab531274114
#include<iostream> using namespace std; long long n,m; int main() { cin>>n>>m; while(n&&m) if(n>=2*m)n%=2*m; else if(m>=2*n)m%=2*n; else break; cout<<n<<' '<<m<<endl; return 0; }
["0 1", "7 12"]
C++
NoteExplanations to the samples: a = 12, b = 5 a = 2, b = 5 a = 2, b = 1 a = 0, b = 1; a = 31, b = 12 a = 7, b = 12.
Print two integers — the values of a and b after the end of the process.
You have two variables a and b. Consider the following sequence of actions performed with these variables: If a = 0 or b = 0, end the process. Otherwise, go to step 2; If a ≥ 2·b, then set the value of a to a - 2·b, and repeat step 1. Otherwise, go to step 3; If b ≥ 2·a, then set the value of b to b - 2·a, and repeat step 1. Otherwise, end the process.Initially the values of a and b are positive integers, and so the process will be finite.You have to determine the values of a and b after the process ends.
[{"input": "12 5\r\n", "output": ["0 1"]}, {"input": "31 12\r\n", "output": ["7 12"]}, {"input": "1000000000000000000 7\r\n", "output": ["8 7"]}, {"input": "31960284556200 8515664064180\r\n", "output": ["14928956427840 8515664064180"]}, {"input": "1000000000000000000 1000000000000000000\r\n", "output": ["1000000000000000000 1000000000000000000"]}, {"input": "1 1000\r\n", "output": ["1 0"]}, {"input": "1 1000000\r\n", "output": ["1 0"]}, {"input": "1 1000000000000000\r\n", "output": ["1 0"]}, {"input": "1 99999999999999999\r\n", "output": ["1 1"]}, {"input": "1 4\r\n", "output": ["1 0"]}, {"input": "1000000000000001 500000000000000\r\n", "output": ["1 0"]}, {"input": "1 1000000000000000000\r\n", "output": ["1 0"]}, {"input": "2 4\r\n", "output": ["2 0"]}, {"input": "2 1\r\n", "output": ["0 1"]}, {"input": "6 19\r\n", "output": ["6 7"]}, {"input": "22 5\r\n", "output": ["0 1"]}, {"input": "10000000000000000 100000000000000001\r\n", "output": ["0 1"]}, {"input": "1 1000000000000\r\n", "output": ["1 0"]}, {"input": "2 1000000000000000\r\n", "output": ["2 0"]}, {"input": "2 10\r\n", "output": ["2 2"]}, {"input": "51 100\r\n", "output": ["51 100"]}, {"input": "3 1000000000000000000\r\n", "output": ["3 4"]}, {"input": "1000000000000000000 3\r\n", "output": ["4 3"]}, {"input": "1 10000000000000000\r\n", "output": ["1 0"]}, {"input": "8796203 7556\r\n", "output": ["1019 1442"]}, {"input": "5 22\r\n", "output": ["1 0"]}, {"input": "1000000000000000000 1\r\n", "output": ["0 1"]}, {"input": "1 100000000000\r\n", "output": ["1 0"]}, {"input": "2 1000000000000\r\n", "output": ["2 0"]}, {"input": "5 4567865432345678\r\n", "output": ["5 8"]}, {"input": "576460752303423487 288230376151711743\r\n", "output": ["1 1"]}, {"input": "499999999999999999 1000000000000000000\r\n", "output": ["3 2"]}, {"input": "1 9999999999999\r\n", "output": ["1 1"]}, {"input": "103 1000000000000000000\r\n", "output": ["103 196"]}, {"input": "7 1\r\n", "output": ["1 1"]}, {"input": "100000000000000001 10000000000000000\r\n", "output": ["1 0"]}, {"input": "5 10\r\n", "output": ["5 0"]}, {"input": "7 11\r\n", "output": ["7 11"]}, {"input": "1 123456789123456\r\n", "output": ["1 0"]}, {"input": "5000000000000 100000000000001\r\n", "output": ["0 1"]}, {"input": "1000000000000000 1\r\n", "output": ["0 1"]}, {"input": "1000000000000000000 499999999999999999\r\n", "output": ["2 3"]}, {"input": "10 5\r\n", "output": ["0 5"]}, {"input": "9 18917827189272\r\n", "output": ["9 0"]}, {"input": "179 100000000000497000\r\n", "output": ["179 270"]}, {"input": "5 100000000000001\r\n", "output": ["1 1"]}, {"input": "5 20\r\n", "output": ["5 0"]}, {"input": "100000001 50000000\r\n", "output": ["1 0"]}, {"input": "345869461223138161 835002744095575440\r\n", "output": ["1 0"]}, {"input": "8589934592 4294967296\r\n", "output": ["0 4294967296"]}, {"input": "4 8\r\n", "output": ["4 0"]}, {"input": "1 100000000000000000\r\n", "output": ["1 0"]}, {"input": "1000000000000000000 333333333333333\r\n", "output": ["1000 1333"]}, {"input": "25 12\r\n", "output": ["1 0"]}, {"input": "24 54\r\n", "output": ["0 6"]}, {"input": "6 12\r\n", "output": ["6 0"]}, {"input": "129200000000305 547300000001292\r\n", "output": ["1 0"]}, {"input": "1000000000000000000 49999999999999999\r\n", "output": ["20 39"]}, {"input": "1 2\r\n", "output": ["1 0"]}, {"input": "1 123456789876\r\n", "output": ["1 0"]}, {"input": "2 3\r\n", "output": ["2 3"]}, {"input": "1 3\r\n", "output": ["1 1"]}, {"input": "1 1\r\n", "output": ["1 1"]}, {"input": "19 46\r\n", "output": ["3 2"]}, {"input": "3 6\r\n", "output": ["3 0"]}, {"input": "129 1000000000000000000\r\n", "output": ["1 0"]}, {"input": "12 29\r\n", "output": ["0 1"]}, {"input": "8589934592 2147483648\r\n", "output": ["0 2147483648"]}, {"input": "2147483648 8589934592\r\n", "output": ["2147483648 0"]}, {"input": "5 6\r\n", "output": ["5 6"]}, {"input": "1000000000000000000 2\r\n", "output": ["0 2"]}, {"input": "2 7\r\n", "output": ["2 3"]}, {"input": "17174219820754872 61797504734333370\r\n", "output": ["17174219820754872 27449065092823626"]}, {"input": "49 100\r\n", "output": ["1 0"]}, {"input": "7 17\r\n", "output": ["1 1"]}, {"input": "1000000000000000000 10000001\r\n", "output": ["0 1"]}, {"input": "49999999999999999 2\r\n", "output": ["3 2"]}, {"input": "49999999999999999 1\r\n", "output": ["1 1"]}, {"input": "576460752303423487 2\r\n", "output": ["3 2"]}, {"input": "19395 19395\r\n", "output": ["19395 19395"]}, {"input": "19394 19394\r\n", "output": ["19394 19394"]}]
100
100
100
[{'input': '5 6\r\n', 'output': ['5 6']}, {'input': '576460752303423487 288230376151711743\r\n', 'output': ['1 1']}, {'input': '1 2\r\n', 'output': ['1 0']}, {'input': '1000000000000000000 2\r\n', 'output': ['0 2']}, {'input': '1000000000000000000 10000001\r\n', 'output': ['0 1']}]
[{'input': '17174219820754872 61797504734333370\r\n', 'output': ['17174219820754872 27449065092823626']}, {'input': '12 5\r\n', 'output': ['0 1']}, {'input': '1 4\r\n', 'output': ['1 0']}, {'input': '10000000000000000 100000000000000001\r\n', 'output': ['0 1']}, {'input': '5 100000000000001\r\n', 'output': ['1 1']}]
[{'input': '3 1000000000000000000\r\n', 'output': ['3 4']}, {'input': '1000000000000000000 3\r\n', 'output': ['4 3']}, {'input': '499999999999999999 1000000000000000000\r\n', 'output': ['3 2']}, {'input': '9 18917827189272\r\n', 'output': ['9 0']}, {'input': '7 11\r\n', 'output': ['7 11']}]
[{'input': '31 12\r\n', 'output': ['7 12']}, {'input': '1 100000000000000000\r\n', 'output': ['1 0']}, {'input': '345869461223138161 835002744095575440\r\n', 'output': ['1 0']}, {'input': '1 10000000000000000\r\n', 'output': ['1 0']}, {'input': '576460752303423487 2\r\n', 'output': ['3 2']}]
[{'input': '7 1\r\n', 'output': ['1 1']}, {'input': '576460752303423487 288230376151711743\r\n', 'output': ['1 1']}, {'input': '25 12\r\n', 'output': ['1 0']}, {'input': '2 7\r\n', 'output': ['2 3']}, {'input': '576460752303423487 2\r\n', 'output': ['3 2']}]
100
100
100
100
100
100
100
100
100
100
100
100
87.5
87.5
87.5
159
100
100
92.5
["10 3 5 2 3"]
The single line contains five integers C, Hr, Hb, Wr, Wb (1 ≤ C, Hr, Hb, Wr, Wb ≤ 109).
eb052ca12ca293479992680581452399
/*input 10 3 5 2 3 */ #include <bits/stdc++.h> using namespace std; long long c,wr,wb,hr,hb,ans=0; long long get(int i){ return i*hr+hb*int((c-i*wr)/wb); } int main(){ cin>>c>>hr>>hb>>wr>>wb; if(hb*wr>hr*wb){ swap(hr,hb); swap(wr,wb); } if(wr>1e4){ for(int i=0;i*wr<=c;++i) ans=max(ans,get(i)); } else if(wb>1e4){ for(int i=0;i*wb<=c;++i) ans=max(ans,i*hb+hr*int((c-i*wb)/wr)); } else{ for(int i=0;i<1e7&&i*wb<=c;i++){ ans=max(ans,i*hb+hr*int((c-i*wb)/wr)); } } cout<<ans; //assert(0); }
["16"]
C++
NoteIn the sample test Om Nom can eat two candies of each type and thus get 16 joy units.
Print a single integer — the maximum number of joy units that Om Nom can get.
A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think a bit in order to enjoy candies the most. Would you succeed with the same task if you were on his place? One day, when he came to his friend Evan, Om Nom didn't find him at home but he found two bags with candies. The first was full of blue candies and the second bag was full of red candies. Om Nom knows that each red candy weighs Wr grams and each blue candy weighs Wb grams. Eating a single red candy gives Om Nom Hr joy units and eating a single blue candy gives Om Nom Hb joy units.Candies are the most important thing in the world, but on the other hand overeating is not good. Om Nom knows if he eats more than C grams of candies, he will get sick. Om Nom thinks that it isn't proper to leave candy leftovers, so he can only eat a whole candy. Om Nom is a great mathematician and he quickly determined how many candies of what type he should eat in order to get the maximum number of joy units. Can you repeat his achievement? You can assume that each bag contains more candies that Om Nom can eat.
[{"input": "10 3 5 2 3\r\n", "output": ["16"]}, {"input": "5 3 1 6 7\r\n", "output": ["0"]}, {"input": "982068341 55 57 106 109\r\n", "output": ["513558662"]}, {"input": "930064129 32726326 25428197 83013449 64501049\r\n", "output": ["363523396"]}, {"input": "927155987 21197 15994 54746 41309\r\n", "output": ["358983713"]}, {"input": "902303498 609628987 152407246 8 2\r\n", "output": ["68758795931537065"]}, {"input": "942733698 9180 9072 1020 1008\r\n", "output": ["8484603228"]}, {"input": "951102310 39876134 24967176 70096104 43888451\r\n", "output": ["539219654"]}, {"input": "910943911 107 105 60 59\r\n", "output": ["1624516635"]}, {"input": "910943911 38162 31949 67084 56162\r\n", "output": ["518210503"]}, {"input": "910943911 9063 9045 1007 1005\r\n", "output": ["8198495199"]}, {"input": "903796108 270891702 270891702 1 1\r\n", "output": ["244830865957095816"]}, {"input": "936111602 154673223 309346447 1 2\r\n", "output": ["144791399037089047"]}, {"input": "947370735 115930744 347792233 1 3\r\n", "output": ["109829394468167085"]}, {"input": "958629867 96557265 386229061 1 4\r\n", "output": ["92562678344491221"]}, {"input": "969889000 84931386 424656931 1 5\r\n", "output": ["82374017230131800"]}, {"input": "925819493 47350513 28377591 83230978 49881078\r\n", "output": ["520855643"]}, {"input": "934395168 119 105 67 59\r\n", "output": ["1662906651"]}, {"input": "934395168 29208 38362 51342 67432\r\n", "output": ["531576348"]}, {"input": "934395168 9171 9045 1019 1005\r\n", "output": ["8409556512"]}, {"input": "946401698 967136832 483568416 2 1\r\n", "output": ["457649970001570368"]}, {"input": "962693577 967217455 967217455 2 2\r\n", "output": ["465567015261784540"]}, {"input": "989976325 646076560 969114840 2 3\r\n", "output": ["319800249268721000"]}, {"input": "901235456 485501645 971003291 2 4\r\n", "output": ["218775648435471424"]}, {"input": "912494588 389153108 972882772 2 5\r\n", "output": ["177550052841687584"]}, {"input": "995503930 29205027 18903616 51333090 33226507\r\n", "output": ["565303099"]}, {"input": "983935533 115 108 65 61\r\n", "output": ["1742049794"]}, {"input": "983935533 33986 27367 59737 48104\r\n", "output": ["559787479"]}, {"input": "983935533 7105 7056 1015 1008\r\n", "output": ["6887548731"]}, {"input": "994040035 740285170 246761723 3 1\r\n", "output": ["245291032098926983"]}, {"input": "905299166 740361314 493574209 3 2\r\n", "output": ["223416160034288041"]}, {"input": "911525551 740437472 740437472 3 3\r\n", "output": ["224975891301803200"]}, {"input": "922784684 566833132 755777509 3 4\r\n", "output": ["174354977531116762"]}, {"input": "955100178 462665160 771108601 3 5\r\n", "output": ["147297192414486195"]}, {"input": "949164751 36679609 23634069 64467968 41539167\r\n", "output": ["537909080"]}, {"input": "928443151 60 63 106 112\r\n", "output": ["525533853"]}, {"input": "928443151 25031 33442 43995 58778\r\n", "output": ["528241752"]}, {"input": "928443151 1006 1012 1006 1012\r\n", "output": ["928443150"]}, {"input": "936645623 540336743 135084185 4 1\r\n", "output": ["126526011319256470"]}, {"input": "947904756 540408420 270204210 4 2\r\n", "output": ["128063927875111380"]}, {"input": "959163888 540480074 405360055 4 3\r\n", "output": ["129602242291091928"]}, {"input": "970423020 540551739 540551739 4 4\r\n", "output": ["131140962756657945"]}, {"input": "976649406 455467553 569334442 4 5\r\n", "output": ["111208028918928288"]}, {"input": "923881933 18531902 53987967 32570076 94884602\r\n", "output": ["524563246"]}, {"input": "977983517 57 63 101 112\r\n", "output": ["551931291"]}, {"input": "977983517 29808 22786 52389 40047\r\n", "output": ["556454318"]}, {"input": "977983517 9009 9108 1001 1012\r\n", "output": ["8801851608"]}, {"input": "984283960 367291526 73458305 5 1\r\n", "output": ["72303831537144592"]}, {"input": "990510345 367358723 146943489 5 2\r\n", "output": ["72774523091497887"]}, {"input": "901769477 367425909 220455545 5 3\r\n", "output": ["66266693959035917"]}, {"input": "907995862 367493085 293994468 5 4\r\n", "output": ["66736440098722854"]}, {"input": "924287742 367560271 367560271 5 5\r\n", "output": ["67946290439275508"]}, {"input": "1000000000 1000 999 100 1000000000\r\n", "output": ["10000000000"]}, {"input": "999999999 10 499999995 2 99999999\r\n", "output": ["4999999995"]}, {"input": "999999999 1 1000000000 2 1000000000\r\n", "output": ["499999999"]}, {"input": "999999997 2 999999997 2 999999997\r\n", "output": ["999999997"]}, {"input": "1000000000 1 1 11 11\r\n", "output": ["90909090"]}, {"input": "999999999 999999998 5 999999999 5\r\n", "output": ["999999998"]}, {"input": "100000001 3 100000000 3 100000001\r\n", "output": ["100000000"]}, {"input": "999999999 2 3 1 2\r\n", "output": ["1999999998"]}, {"input": "1000000000 2 1 3 4\r\n", "output": ["666666666"]}, {"input": "999999999 10000 494999 2 99\r\n", "output": ["4999999994999"]}, {"input": "1000000000 1 1 1 1\r\n", "output": ["1000000000"]}, {"input": "998999 1000 999 1000 999\r\n", "output": ["998999"]}, {"input": "3 100 101 2 3\r\n", "output": ["101"]}, {"input": "345415838 13999 13997 13999 13997\r\n", "output": ["345415838"]}, {"input": "5000005 3 2 5 1\r\n", "output": ["10000010"]}, {"input": "1000000000 1 1 1 1000000000\r\n", "output": ["1000000000"]}, {"input": "999999999 3 2 10 3\r\n", "output": ["666666666"]}, {"input": "1000000000 1000 1000 1 1\r\n", "output": ["1000000000000"]}, {"input": "200000001 100000002 1 100000001 1\r\n", "output": ["200000002"]}, {"input": "100000000 1000000000 1 100000001 1\r\n", "output": ["100000000"]}, {"input": "1000000000 99 100 1 2\r\n", "output": ["99000000000"]}, {"input": "1000000000 5 5 1 1\r\n", "output": ["5000000000"]}, {"input": "1000000000 1 1000000000 1 1000000000\r\n", "output": ["1000000000"]}]
100
100
100
[{'input': '990510345 367358723 146943489 5 2\r\n', 'output': ['72774523091497887']}, {'input': '1000000000 1 1000000000 1 1000000000\r\n', 'output': ['1000000000']}, {'input': '998999 1000 999 1000 999\r\n', 'output': ['998999']}, {'input': '1000000000 1000 999 100 1000000000\r\n', 'output': ['10000000000']}, {'input': '942733698 9180 9072 1020 1008\r\n', 'output': ['8484603228']}]
[{'input': '977983517 29808 22786 52389 40047\r\n', 'output': ['556454318']}, {'input': '976649406 455467553 569334442 4 5\r\n', 'output': ['111208028918928288']}, {'input': '983935533 7105 7056 1015 1008\r\n', 'output': ['6887548731']}, {'input': '100000000 1000000000 1 100000001 1\r\n', 'output': ['100000000']}, {'input': '5 3 1 6 7\r\n', 'output': ['0']}]
[{'input': '910943911 38162 31949 67084 56162\r\n', 'output': ['518210503']}, {'input': '934395168 119 105 67 59\r\n', 'output': ['1662906651']}, {'input': '942733698 9180 9072 1020 1008\r\n', 'output': ['8484603228']}, {'input': '934395168 29208 38362 51342 67432\r\n', 'output': ['531576348']}, {'input': '982068341 55 57 106 109\r\n', 'output': ['513558662']}]
[{'input': '912494588 389153108 972882772 2 5\r\n', 'output': ['177550052841687584']}, {'input': '934395168 119 105 67 59\r\n', 'output': ['1662906651']}, {'input': '999999997 2 999999997 2 999999997\r\n', 'output': ['999999997']}, {'input': '100000001 3 100000000 3 100000001\r\n', 'output': ['100000000']}, {'input': '936645623 540336743 135084185 4 1\r\n', 'output': ['126526011319256470']}]
[{'input': '345415838 13999 13997 13999 13997\r\n', 'output': ['345415838']}, {'input': '1000000000 1 1 1 1\r\n', 'output': ['1000000000']}, {'input': '998999 1000 999 1000 999\r\n', 'output': ['998999']}, {'input': '936111602 154673223 309346447 1 2\r\n', 'output': ['144791399037089047']}, {'input': '999999999 999999998 5 999999999 5\r\n', 'output': ['999999998']}]
100
100
100
100
100
64.71
88.24
88.24
76.47
100
71.43
78.57
78.57
71.43
100
160
100
83.532
80
["3"]
The first line contains a single integer n (0 ≤ n ≤ 1000).
1a335a9638523ca0315282a67e18eec7
#include <bits/stdc++.h> #define ll long long int using namespace std; const int N=1010; const int MOD=(int)1e6+3; ll n,dp[N],twoPow[2*N]; void init() { twoPow[0]=1; for(int i=1;i<=2*N;i++) twoPow[i]=(twoPow[i-1]*2)%MOD; memset(dp,-1,sizeof(dp)); } ll cookie(ll a) { return (twoPow[a-1]*(twoPow[a]+1))%MOD; } ll solve(ll a) { if (a<=0) return 0; if (dp[a]!=-1) return dp[a]; dp[a]=cookie(a)%MOD; for(int i=1;a-i>0;i++) { dp[a]=(dp[a]+solve(a-i)*twoPow[i-1])%MOD; } return dp[a]; } int main() { init(); cin >> n; cout << (twoPow[2*n]-solve(n)+MOD)%MOD << endl; }
["9"]
C++
NoteIf the box possesses the base of 23 × 23 (as in the example), then the cookies will be put there in the following manner:
Print the single number, equal to the number of empty cells in the box. The answer should be printed modulo 106 + 3.
Fangy collects cookies. Once he decided to take a box and put cookies into it in some way. If we take a square k × k in size, divided into blocks 1 × 1 in size and paint there the main diagonal together with cells, which lie above it, then the painted area will be equal to the area occupied by one cookie k in size. Fangy also has a box with a square base 2n × 2n, divided into blocks 1 × 1 in size. In a box the cookies should not overlap, and they should not be turned over or rotated. See cookies of sizes 2 and 4 respectively on the figure: To stack the cookies the little walrus uses the following algorithm. He takes out of the repository the largest cookie which can fit in some place in the box and puts it there. Everything could be perfect but alas, in the repository the little walrus has infinitely many cookies of size 2 and larger, and there are no cookies of size 1, therefore, empty cells will remain in the box. Fangy wants to know how many empty cells will be left in the end.
[{"input": "3\r\n", "output": ["9"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "2\r\n", "output": ["3"]}, {"input": "4\r\n", "output": ["27"]}, {"input": "6\r\n", "output": ["243"]}, {"input": "11\r\n", "output": ["59049"]}, {"input": "14\r\n", "output": ["594320"]}, {"input": "15\r\n", "output": ["782957"]}, {"input": "7\r\n", "output": ["729"]}, {"input": "0\r\n", "output": ["1"]}, {"input": "1000\r\n", "output": ["691074"]}, {"input": "657\r\n", "output": ["874011"]}, {"input": "561\r\n", "output": ["842553"]}, {"input": "823\r\n", "output": ["858672"]}, {"input": "850\r\n", "output": ["557186"]}, {"input": "298\r\n", "output": ["999535"]}, {"input": "262\r\n", "output": ["946384"]}, {"input": "910\r\n", "output": ["678945"]}, {"input": "617\r\n", "output": ["247876"]}, {"input": "857\r\n", "output": ["562128"]}, {"input": "69\r\n", "output": ["327984"]}, {"input": "589\r\n", "output": ["889192"]}, {"input": "928\r\n", "output": ["794863"]}, {"input": "696\r\n", "output": ["695035"]}, {"input": "226\r\n", "output": ["376094"]}]
100
100
100
[{'input': '69\r\n', 'output': ['327984']}, {'input': '1000\r\n', 'output': ['691074']}, {'input': '1\r\n', 'output': ['1']}, {'input': '589\r\n', 'output': ['889192']}, {'input': '6\r\n', 'output': ['243']}]
[{'input': '298\r\n', 'output': ['999535']}, {'input': '850\r\n', 'output': ['557186']}, {'input': '4\r\n', 'output': ['27']}, {'input': '910\r\n', 'output': ['678945']}, {'input': '69\r\n', 'output': ['327984']}]
[{'input': '1\r\n', 'output': ['1']}, {'input': '823\r\n', 'output': ['858672']}, {'input': '11\r\n', 'output': ['59049']}, {'input': '298\r\n', 'output': ['999535']}, {'input': '617\r\n', 'output': ['247876']}]
[{'input': '7\r\n', 'output': ['729']}, {'input': '3\r\n', 'output': ['9']}, {'input': '850\r\n', 'output': ['557186']}, {'input': '561\r\n', 'output': ['842553']}, {'input': '657\r\n', 'output': ['874011']}]
[{'input': '823\r\n', 'output': ['858672']}, {'input': '0\r\n', 'output': ['1']}, {'input': '4\r\n', 'output': ['27']}, {'input': '2\r\n', 'output': ['3']}, {'input': '298\r\n', 'output': ['999535']}]
100
100
100
100
100
95.45
95.45
95.45
95.45
100
87.5
87.5
87.5
87.5
100
161
100
96.36
90
["3 6 100000", "6 21 100129", "58 787788 50216"]
The only line contains three integers maxn, maxa and q (1 ≤ maxn ≤ 30 000; maxn ≤ maxa ≤ 109; 104 ≤ q ≤ 105 + 129).
aac481d9e5ea3e3d43b324c8750882be
#include <bits/stdc++.h> using namespace std; const int p1 = 998244353, p2 = 469762049, Maxn = 1 << 17 | 5; int maxn, maxa, mod, rev[Maxn]; int tot, l[Maxn]; const long long lcm = p1 * (long long) p2; void get_rev(int len) { for (int i = 0; i < len; i++) rev[i] = (rev[i >> 1] >> 1) | ((i & 1) * (len >> 1)); } long long fast_pow(long long x, long long y, int p) { long long ans = 1, now = x; while (y) { if (y & 1) ans = ans * now % p; now = now * now % p; y >>= 1; } return ans; } void NTT(int now[], int len, int p, bool type = false) { l[0] = 1; int inv3 = fast_pow(3, p - 2, p); for (int i = 0; i < len; i++) if (i < rev[i]) swap(now[i], now[rev[i]]); for (int i = 1; i < len; i <<= 1) { long long w = fast_pow(type ? inv3 : 3, (p - 1) / (i << 1), p); for (int j = 1; j < i; j++) l[j] = l[j - 1] * w % p; for (int j = 0; j < len; j += (i << 1)) for (int k = j; k < i + j; k++) { int x = now[i + k] * (long long) l[k - j] % p, y = now[k]; now[k] = (x + y) % p; now[i + k] = (y - x + p) % p; } } if (type) { long long inv = fast_pow(len, p - 2, p); for (int i = 0; i < len; i++) now[i] = now[i] * inv % p; } } void multi(int x[], int y[], int result[], int len, int p) { NTT(x, len, p), NTT(y, len, p); for (int i = 0; i < len; i++) result[i] = x[i] * (long long) y[i] % p; NTT(result, len, p, true); } long long mul(long long x, long long y) { return ((unsigned long long) x * y - (long long) (x / (long double) lcm * y) * lcm + lcm) % lcm; } void multi(int x[], int y[], int result[], int len) { get_rev(len); static int tmp1[Maxn], tmp2[Maxn], tmpx[Maxn], tmpy[Maxn]; for (int i = 0; i < len; i++) tmpx[i] = x[i], tmpy[i] = y[i]; multi(tmpx, tmpy, tmp1, len, p1); for (int i = 0; i < len; i++) tmpx[i] = x[i], tmpy[i] = y[i]; multi(tmpx, tmpy, tmp2, len, p2); long long P1 = fast_pow(p2, p1 - 2, p1), P2 = fast_pow(p1, p2 - 2, p2); for (int i = 0; i < len; i++) result[i] = (mul(mul(tmp1[i], p2), P1) + mul(mul(tmp2[i], p1), P2)) % lcm % mod; } void poly_pow(int y, int len) { int now = 0; static int ans[2][Maxn]; memset(ans[0], 0, sizeof(int[len << 1])); memset(ans[1], 0, sizeof(int[len << 1])); static int tmp[Maxn], result[2][Maxn]; for (int j = 30; j >= 0; j--) { cerr << j << endl; memset(tmp, 0, sizeof(int[len << 1])); for (int i = 0; i < len; i++) tmp[i] = (ans[0][i] + ans[1][i]) % mod; tmp[0]++; for (int p = 0; p <= 1; p++) multi(tmp, ans[(now & 1) ^ p], result[p], len << 1); for (int p = 0; p <= 1; p++) for (int i = 0; i < len; i++) (ans[p][i] += result[p][i]) %= mod; now <<= 1; if (y & (1 << j)) { for (int i = len - 1; i; i--) (ans[1][i] += ans[0][i - 1] + ans[1][i - 1]) %= mod; ans[1][1]++; now++; } if (now != y) for (int i = 1; i <= maxn; i += 2) (tot += ans[1][i]) %= mod; } } int lower(int x) { int tmp = 1; for (; tmp < x; tmp <<= 1); return tmp; } int main() { scanf("%d%d%d", &maxn, &maxa, &mod); poly_pow(maxa, lower(maxn + 1)); printf("%d", tot); return 0; }
["4", "154", "46009"]
C++
NoteIn the first example, interesting test cases look as follows: 1 1 1 32 4 6 2 4 6
Output a single integer — the number of test cases which satisfy the constraints and make both wrong solutions output an incorrect answer, modulo q.
Test data generation is not an easy task! Often, generating big random test cases is not enough to ensure thorough testing of solutions for correctness.For example, consider a problem from an old Codeforces round. Its input format looks roughly as follows:The first line contains a single integer n (1 ≤ n ≤ maxn) — the size of the set. The second line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ maxa) — the elements of the set in increasing order.If you don't pay attention to the problem solution, it looks fairly easy to generate a good test case for this problem. Let n = maxn, take random distinct ai from 1 to maxa, sort them... Soon you understand that it's not that easy.Here is the actual problem solution. Let g be the greatest common divisor of a1, a2, ..., an. Let x = an / g - n. Then the correct solution outputs "Alice" if x is odd, and "Bob" if x is even.Consider two wrong solutions to this problem which differ from the correct one only in the formula for calculating x.The first wrong solution calculates x as x = an / g (without subtracting n).The second wrong solution calculates x as x = an - n (without dividing by g).A test case is interesting if it makes both wrong solutions output an incorrect answer.Given maxn, maxa and q, find the number of interesting test cases satisfying the constraints, and output it modulo q.
[{"input": "3 6 100000\r\n", "output": ["4"]}, {"input": "6 21 100129\r\n", "output": ["154"]}, {"input": "58 787788 50216\r\n", "output": ["46009"]}, {"input": "1 1 10000\r\n", "output": ["0"]}, {"input": "1 20 100000\r\n", "output": ["10"]}, {"input": "2 20 100000\r\n", "output": ["10"]}, {"input": "100 12345 100000\r\n", "output": ["22765"]}, {"input": "30000 1000000000 100123\r\n", "output": ["21272"]}, {"input": "30000 536870911 100123\r\n", "output": ["82802"]}, {"input": "200 1000000000 100123\r\n", "output": ["88152"]}, {"input": "200 536870911 100123\r\n", "output": ["11017"]}, {"input": "200 536870912 100123\r\n", "output": ["11018"]}, {"input": "1000 536870911 100123\r\n", "output": ["64128"]}, {"input": "2000 536870911 100123\r\n", "output": ["95429"]}, {"input": "4000 536870911 100123\r\n", "output": ["9643"]}, {"input": "8000 536870911 100123\r\n", "output": ["84503"]}, {"input": "16000 536870911 100123\r\n", "output": ["57489"]}, {"input": "16000 1000000000 100123\r\n", "output": ["89479"]}, {"input": "10 20 100000\r\n", "output": ["184"]}, {"input": "20 25 100000\r\n", "output": ["698"]}, {"input": "5 5 100000\r\n", "output": ["2"]}, {"input": "5 7 100000\r\n", "output": ["4"]}, {"input": "1 2 100123\r\n", "output": ["1"]}, {"input": "1 536870911 100123\r\n", "output": ["5692"]}, {"input": "1 536870912 100123\r\n", "output": ["5693"]}, {"input": "1 1000000000 100123\r\n", "output": ["85861"]}, {"input": "2 1000000000 100123\r\n", "output": ["85861"]}, {"input": "2 2 100123\r\n", "output": ["1"]}, {"input": "2 3 100123\r\n", "output": ["1"]}, {"input": "1 3 100123\r\n", "output": ["1"]}, {"input": "16383 1000000000 100129\r\n", "output": ["92305"]}, {"input": "16384 1000000000 100129\r\n", "output": ["92305"]}, {"input": "16385 1000000000 100129\r\n", "output": ["498"]}, {"input": "30000 999999999 100129\r\n", "output": ["23865"]}, {"input": "30000 536870912 100129\r\n", "output": ["90668"]}, {"input": "30000 536870913 100129\r\n", "output": ["90668"]}, {"input": "29673 671088479 10000\r\n", "output": ["67"]}, {"input": "29804 939519871 100000\r\n", "output": ["99167"]}, {"input": "29097 671084543 100123\r\n", "output": ["69927"]}, {"input": "29364 536805295 100128\r\n", "output": ["55925"]}, {"input": "29465 805306303 100129\r\n", "output": ["71904"]}, {"input": "29441 671087487 65535\r\n", "output": ["40129"]}, {"input": "29923 989593598 65536\r\n", "output": ["7161"]}, {"input": "29909 794820607 59049\r\n", "output": ["20195"]}, {"input": "29459 805306359 46656\r\n", "output": ["36813"]}, {"input": "29521 536575999 30030\r\n", "output": ["13478"]}, {"input": "29327 771678207 60060\r\n", "output": ["15506"]}, {"input": "29523 939524027 90090\r\n", "output": ["37791"]}, {"input": "29182 804781951 10201\r\n", "output": ["8309"]}, {"input": "29292 671087615 91809\r\n", "output": ["62523"]}, {"input": "29939 981434367 97969\r\n", "output": ["45387"]}, {"input": "29928 938995199 96721\r\n", "output": ["17029"]}, {"input": "29811 803209213 97343\r\n", "output": ["75766"]}, {"input": "29216 939522047 79507\r\n", "output": ["7416"]}, {"input": "29622 805175167 83521\r\n", "output": ["30548"]}, {"input": "29825 201293823 67228\r\n", "output": ["62779"]}, {"input": "29244 922681341 78125\r\n", "output": ["11842"]}, {"input": "29782 536870845 100126\r\n", "output": ["74061"]}, {"input": "29725 535755775 100118\r\n", "output": ["6811"]}, {"input": "29393 536870879 10001\r\n", "output": ["6365"]}, {"input": "29875 805036031 10002\r\n", "output": ["3441"]}, {"input": "29876 804782015 100106\r\n", "output": ["35274"]}, {"input": "1 1 100000\r\n", "output": ["0"]}, {"input": "1 2 100000\r\n", "output": ["1"]}, {"input": "2 2 100000\r\n", "output": ["1"]}, {"input": "1 3 100000\r\n", "output": ["1"]}, {"input": "2 3 100000\r\n", "output": ["1"]}, {"input": "3 3 100000\r\n", "output": ["1"]}, {"input": "1 4 100000\r\n", "output": ["2"]}, {"input": "2 4 100000\r\n", "output": ["2"]}, {"input": "3 4 100000\r\n", "output": ["2"]}, {"input": "4 4 100000\r\n", "output": ["2"]}, {"input": "1 5 100000\r\n", "output": ["2"]}, {"input": "2 5 100000\r\n", "output": ["2"]}, {"input": "3 5 100000\r\n", "output": ["2"]}, {"input": "4 5 100000\r\n", "output": ["2"]}, {"input": "5 5 100000\r\n", "output": ["2"]}, {"input": "1 6 100000\r\n", "output": ["3"]}, {"input": "2 6 100000\r\n", "output": ["3"]}, {"input": "3 6 100000\r\n", "output": ["4"]}, {"input": "4 6 100000\r\n", "output": ["4"]}, {"input": "5 6 100000\r\n", "output": ["4"]}, {"input": "6 6 100000\r\n", "output": ["4"]}, {"input": "1 7 100000\r\n", "output": ["3"]}, {"input": "2 7 100000\r\n", "output": ["3"]}, {"input": "3 7 100000\r\n", "output": ["4"]}, {"input": "4 7 100000\r\n", "output": ["4"]}, {"input": "5 7 100000\r\n", "output": ["4"]}, {"input": "6 7 100000\r\n", "output": ["4"]}, {"input": "7 7 100000\r\n", "output": ["4"]}, {"input": "1 8 100000\r\n", "output": ["4"]}, {"input": "2 8 100000\r\n", "output": ["4"]}, {"input": "3 8 100000\r\n", "output": ["5"]}, {"input": "4 8 100000\r\n", "output": ["5"]}, {"input": "5 8 100000\r\n", "output": ["5"]}, {"input": "6 8 100000\r\n", "output": ["5"]}, {"input": "7 8 100000\r\n", "output": ["5"]}, {"input": "8 8 100000\r\n", "output": ["5"]}, {"input": "30000 30000 30000\r\n", "output": ["13816"]}, {"input": "30000 59999 10000\r\n", "output": ["1987"]}, {"input": "30000 60000 10000\r\n", "output": ["5379"]}, {"input": "30000 60001 10000\r\n", "output": ["5379"]}, {"input": "30000 60002 10000\r\n", "output": ["66"]}, {"input": "29999 30000 10007\r\n", "output": ["2397"]}, {"input": "29999 29999 29999\r\n", "output": ["8411"]}]
100
100
100
[{'input': '29804 939519871 100000\r\n', 'output': ['99167']}, {'input': '2 6 100000\r\n', 'output': ['3']}, {'input': '4 7 100000\r\n', 'output': ['4']}, {'input': '6 7 100000\r\n', 'output': ['4']}, {'input': '1000 536870911 100123\r\n', 'output': ['64128']}]
[{'input': '29364 536805295 100128\r\n', 'output': ['55925']}, {'input': '16000 536870911 100123\r\n', 'output': ['57489']}, {'input': '29875 805036031 10002\r\n', 'output': ['3441']}, {'input': '29441 671087487 65535\r\n', 'output': ['40129']}, {'input': '3 6 100000\r\n', 'output': ['4']}]
[{'input': '20 25 100000\r\n', 'output': ['698']}, {'input': '2 2 100000\r\n', 'output': ['1']}, {'input': '16385 1000000000 100129\r\n', 'output': ['498']}, {'input': '30000 60000 10000\r\n', 'output': ['5379']}, {'input': '3 6 100000\r\n', 'output': ['4']}]
[{'input': '5 5 100000\r\n', 'output': ['2']}, {'input': '3 6 100000\r\n', 'output': ['4']}, {'input': '5 5 100000\r\n', 'output': ['2']}, {'input': '30000 1000000000 100123\r\n', 'output': ['21272']}, {'input': '29673 671088479 10000\r\n', 'output': ['67']}]
[{'input': '16385 1000000000 100129\r\n', 'output': ['498']}, {'input': '4 4 100000\r\n', 'output': ['2']}, {'input': '29811 803209213 97343\r\n', 'output': ['75766']}, {'input': '2 6 100000\r\n', 'output': ['3']}, {'input': '3 5 100000\r\n', 'output': ['2']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
162
100
100
100
["BBBSSC\n6 4 1\n1 2 3\n4", "BBC\n1 10 1\n1 10 1\n21", "BSC\n1 1 1\n1 1 3\n1000000000000"]
The first line of the input contains a non-empty string that describes the recipe of "Le Hamburger de Polycarpus". The length of the string doesn't exceed 100, the string contains only letters 'B' (uppercase English B), 'S' (uppercase English S) and 'C' (uppercase English C). The second line contains three integers nb, ns, nc (1 ≤ nb, ns, nc ≤ 100) — the number of the pieces of bread, sausage and cheese on Polycarpus' kitchen. The third line contains three integers pb, ps, pc (1 ≤ pb, ps, pc ≤ 100) — the price of one piece of bread, sausage and cheese in the shop. Finally, the fourth line contains integer r (1 ≤ r ≤ 1012) — the number of rubles Polycarpus has. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
8126a4232188ae7de8e5a7aedea1a97e
#include <iostream> using namespace std; string s; int need[3] = {}; int have[3] = {}; int price[3] = {}; long long r ; bool solve(long long m) { long long p = 0; for (int i = 0 ; i < 3 ; i++) { long long z = m*need[i]; z = z - have[i]; if (z > 0) { p = p + z*price[i]; } } return p <= r; } int main() { cin >> s; for (int i = 0 ; i < s.size() ; i++) { if (s[i] == 'B')need[0]++; if (s[i] == 'S')need[1]++; if (s[i] == 'C')need[2]++; } for (int i = 0 ; i < 3 ; i++) { cin >> have[i]; } for (int i = 0 ; i < 3 ; i++) cin >> price[i]; cin >> r; long long s = 0 , e = 1e15; long long ans = 0; while(s <= e) { long long middle = (s+e)/2; if (solve(middle)) { s = middle+1; ans = middle; } else e = middle - 1; } cout << ans << endl; return 0; }
["2", "7", "200000000001"]
C++
null
Print the maximum number of hamburgers Polycarpus can make. If he can't make any hamburger, print 0.
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (bread), 'S' (sausage) и 'C' (cheese). The ingredients in the recipe go from bottom to top, for example, recipe "ВSCBS" represents the hamburger where the ingredients go from bottom to top as bread, sausage, cheese, bread and sausage again.Polycarpus has nb pieces of bread, ns pieces of sausage and nc pieces of cheese in the kitchen. Besides, the shop nearby has all three ingredients, the prices are pb rubles for a piece of bread, ps for a piece of sausage and pc for a piece of cheese.Polycarpus has r rubles and he is ready to shop on them. What maximum number of hamburgers can he cook? You can assume that Polycarpus cannot break or slice any of the pieces of bread, sausage or cheese. Besides, the shop has an unlimited number of pieces of each ingredient.
[{"input": "BBBSSC\r\n6 4 1\r\n1 2 3\r\n4\r\n", "output": ["2"]}, {"input": "BBC\r\n1 10 1\r\n1 10 1\r\n21\r\n", "output": ["7"]}, {"input": "BSC\r\n1 1 1\r\n1 1 3\r\n1000000000000\r\n", "output": ["200000000001"]}, {"input": "B\r\n1 1 1\r\n1 1 1\r\n381\r\n", "output": ["382"]}, {"input": "BSC\r\n3 5 6\r\n7 3 9\r\n100\r\n", "output": ["10"]}, {"input": "BSC\r\n100 1 1\r\n100 1 1\r\n100\r\n", "output": ["51"]}, {"input": "SBBCCSBB\r\n1 50 100\r\n31 59 21\r\n100000\r\n", "output": ["370"]}, {"input": "BBBBCCCCCCCCCCCCCCCCCCCCSSSSBBBBBBBBSS\r\n100 100 100\r\n1 1 1\r\n3628800\r\n", "output": ["95502"]}, {"input": "BBBBBBBBBBCCCCCCCCCCCCCCCCCCCCSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r\n10 20 40\r\n100 100 100\r\n200\r\n", "output": ["0"]}, {"input": "BBBBBBBBBBCCCCCCCCCCCCCCCCCCCCSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r\n10 20 40\r\n100 100 100\r\n2000\r\n", "output": ["1"]}, {"input": "BBBBBBBBBBCCCCCCCCCCCCCCCCCCCCSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r\n10 20 40\r\n100 100 100\r\n300\r\n", "output": ["0"]}, {"input": "BBBBBBBBBBCCCCCCCCCCCCCCCCCCCCSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r\n10 20 40\r\n100 100 100\r\n300000000\r\n", "output": ["42858"]}, {"input": "BBBBBBBBBBCCCCCCCCCCCCCCCCCCCCSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r\n10 20 40\r\n100 100 100\r\n914159265358\r\n", "output": ["130594181"]}, {"input": "SSSSSSSSSSBBBBBBBBBCCCCCCCCCCCCCCCCCCCSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSBB\r\n31 53 97\r\n13 17 31\r\n914159265358\r\n", "output": ["647421579"]}, {"input": "BBBCSBSBBSSSSCCCCBBCSBBBBSSBBBCBSCCSSCSSCSBSSSCCCCBSCSSBSSSCCCBBCCCSCBCBBCCSCCCCSBBCCBBBBCCCCCCBSSCB\r\n91 87 17\r\n64 44 43\r\n958532915587\r\n", "output": ["191668251"]}, {"input": "CSSCBBCCCSBSCBBBCSBBBCBSBCSCBCSCBCBSBCBCSSBBSBBCBBBBSCSBBCCBCCBCBBSBSBCSCSBBSSBBCSSBCSCSCCSSBCBBCBSB\r\n56 34 48\r\n78 6 96\r\n904174875419\r\n", "output": ["140968956"]}, {"input": "CCSCCCSBBBSCBSCSCCSSBBBSSBBBSBBBCBCSSBCSCBBCCCBCBCBCCCSSBSBBCCCCCBBSCBSCBCBBCBBCSSBCSBSSCCSCCSCCBBBS\r\n33 73 67\r\n4 56 42\r\n886653164314\r\n", "output": ["277425898"]}, {"input": "SBCSSCBBSSBCSSBBBSSBSCBSSSCBBSBBBBCSBCSBSCBSCBSCBSBSSCCCCBSBCCBCBSCCCBSCCBSBBCBSSCCCCSBSBBBSSSBCSCBC\r\n94 16 85\r\n14 18 91\r\n836590091442\r\n", "output": ["217522127"]}, {"input": "BSCSBSCCSCSSCCCSBCSSBCBBSCCBSCCSSSSSSSSSCCSBSCCBBCBBSBSCCCCBCSBSBSSBBBBBSSBSSCBCCSSBSSSCBBCSBBSBCCCB\r\n67 54 8\r\n36 73 37\r\n782232051273\r\n", "output": ["154164772"]}, {"input": "CBBCBSBCCSCBSSCCBCSBCSBBSCBBCSCCBSCCSCSBBSSBSBSCBBSBBCSSSSBBBBSBBCBCSBBCBCSSBBCSBSCCSCSBCSCBSCCBBCSC\r\n71 71 52\r\n52 88 3\r\n654400055575\r\n", "output": ["137826467"]}, {"input": "CBBCBSBCCSCBSSCCBCSBCSBBSCBBCSCCBSCCSCSBBSBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBCSC\r\n100 1 1\r\n1 17 23\r\n954400055575\r\n", "output": ["1355681897"]}, {"input": "C\r\n100 100 100\r\n1 1 1\r\n1000000000000\r\n", "output": ["1000000000100"]}, {"input": "SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r\n100 100 100\r\n100 100 100\r\n1000000000000\r\n", "output": ["100000001"]}, {"input": "B\r\n100 100 100\r\n1 1 1\r\n1\r\n", "output": ["101"]}, {"input": "SC\r\n2 1 1\r\n1 1 1\r\n100000000000\r\n", "output": ["50000000001"]}, {"input": "B\r\n100 1 1\r\n1 1 1\r\n1000000000000\r\n", "output": ["1000000000100"]}, {"input": "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\n1 1 1\r\n100 100 100\r\n1000000000000\r\n", "output": ["100000000"]}, {"input": "CC\r\n1 1 1\r\n100 100 100\r\n1\r\n", "output": ["0"]}, {"input": "B\r\n100 100 100\r\n1 1 1\r\n1000000000000\r\n", "output": ["1000000000100"]}, {"input": "BSC\r\n100 100 100\r\n1 1 1\r\n1000000000000\r\n", "output": ["333333333433"]}, {"input": "BSC\r\n100 100 100\r\n1 1 1\r\n1\r\n", "output": ["100"]}]
100
100
100
[{'input': 'CSSCBBCCCSBSCBBBCSBBBCBSBCSCBCSCBCBSBCBCSSBBSBBCBBBBSCSBBCCBCCBCBBSBSBCSCSBBSSBBCSSBCSCSCCSSBCBBCBSB\r\n56 34 48\r\n78 6 96\r\n904174875419\r\n', 'output': ['140968956']}, {'input': 'BBBBBBBBBBCCCCCCCCCCCCCCCCCCCCSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r\n10 20 40\r\n100 100 100\r\n2000\r\n', 'output': ['1']}, {'input': 'BSC\r\n3 5 6\r\n7 3 9\r\n100\r\n', 'output': ['10']}, {'input': 'SC\r\n2 1 1\r\n1 1 1\r\n100000000000\r\n', 'output': ['50000000001']}, {'input': 'C\r\n100 100 100\r\n1 1 1\r\n1000000000000\r\n', 'output': ['1000000000100']}]
[{'input': 'BBBCSBSBBSSSSCCCCBBCSBBBBSSBBBCBSCCSSCSSCSBSSSCCCCBSCSSBSSSCCCBBCCCSCBCBBCCSCCCCSBBCCBBBBCCCCCCBSSCB\r\n91 87 17\r\n64 44 43\r\n958532915587\r\n', 'output': ['191668251']}, {'input': 'B\r\n100 100 100\r\n1 1 1\r\n1\r\n', 'output': ['101']}, {'input': 'SSSSSSSSSSBBBBBBBBBCCCCCCCCCCCCCCCCCCCSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSBB\r\n31 53 97\r\n13 17 31\r\n914159265358\r\n', 'output': ['647421579']}, {'input': 'CSSCBBCCCSBSCBBBCSBBBCBSBCSCBCSCBCBSBCBCSSBBSBBCBBBBSCSBBCCBCCBCBBSBSBCSCSBBSSBBCSSBCSCSCCSSBCBBCBSB\r\n56 34 48\r\n78 6 96\r\n904174875419\r\n', 'output': ['140968956']}, {'input': 'BSC\r\n100 1 1\r\n100 1 1\r\n100\r\n', 'output': ['51']}]
[{'input': 'B\r\n100 1 1\r\n1 1 1\r\n1000000000000\r\n', 'output': ['1000000000100']}, {'input': 'CBBCBSBCCSCBSSCCBCSBCSBBSCBBCSCCBSCCSCSBBSSBSBSCBBSBBCSSSSBBBBSBBCBCSBBCBCSSBBCSBSCCSCSBCSCBSCCBBCSC\r\n71 71 52\r\n52 88 3\r\n654400055575\r\n', 'output': ['137826467']}, {'input': 'BBBBBBBBBBCCCCCCCCCCCCCCCCCCCCSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r\n10 20 40\r\n100 100 100\r\n2000\r\n', 'output': ['1']}, {'input': 'B\r\n100 100 100\r\n1 1 1\r\n1000000000000\r\n', 'output': ['1000000000100']}, {'input': 'CSSCBBCCCSBSCBBBCSBBBCBSBCSCBCSCBCBSBCBCSSBBSBBCBBBBSCSBBCCBCCBCBBSBSBCSCSBBSSBBCSSBCSCSCCSSBCBBCBSB\r\n56 34 48\r\n78 6 96\r\n904174875419\r\n', 'output': ['140968956']}]
[{'input': 'CBBCBSBCCSCBSSCCBCSBCSBBSCBBCSCCBSCCSCSBBSBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBCSC\r\n100 1 1\r\n1 17 23\r\n954400055575\r\n', 'output': ['1355681897']}, {'input': 'BBBBCCCCCCCCCCCCCCCCCCCCSSSSBBBBBBBBSS\r\n100 100 100\r\n1 1 1\r\n3628800\r\n', 'output': ['95502']}, {'input': 'CSSCBBCCCSBSCBBBCSBBBCBSBCSCBCSCBCBSBCBCSSBBSBBCBBBBSCSBBCCBCCBCBBSBSBCSCSBBSSBBCSSBCSCSCCSSBCBBCBSB\r\n56 34 48\r\n78 6 96\r\n904174875419\r\n', 'output': ['140968956']}, {'input': 'C\r\n100 100 100\r\n1 1 1\r\n1000000000000\r\n', 'output': ['1000000000100']}, {'input': 'BBBBBBBBBBCCCCCCCCCCCCCCCCCCCCSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r\n10 20 40\r\n100 100 100\r\n2000\r\n', 'output': ['1']}]
[{'input': 'B\r\n1 1 1\r\n1 1 1\r\n381\r\n', 'output': ['382']}, {'input': 'B\r\n100 100 100\r\n1 1 1\r\n1\r\n', 'output': ['101']}, {'input': 'BBC\r\n1 10 1\r\n1 10 1\r\n21\r\n', 'output': ['7']}, {'input': 'BSC\r\n100 100 100\r\n1 1 1\r\n1000000000000\r\n', 'output': ['333333333433']}, {'input': 'BBBBBBBBBBCCCCCCCCCCCCCCCCCCCCSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r\n10 20 40\r\n100 100 100\r\n300\r\n', 'output': ['0']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
163
100
100
100
["sumimasen", "ninja", "codeforces"]
The first line of the input contains the string $$$s$$$ consisting of $$$|s|$$$ ($$$1\leq |s|\leq 100$$$) lowercase Latin letters.
a83144ba7d4906b7692456f27b0ef7d4
#include<bits/stdc++.h> using namespace std; string st; bool pd(int i) { return st[i]=='a'||st[i]=='e'||st[i]=='i'||st[i]=='o'||st[i]=='u'; } int main() { cin>>st; for(int i=0;i<st.size();i++) { if(!pd(i)&&!pd(i+1)&&st[i]!='n') { cout<<"NO"<<endl; return 0; } } cout<<"YES"<<endl; return 0; }
["YES", "YES", "NO"]
C++
NoteIn the first and second samples, a vowel goes after each consonant except "n", so the word is Berlanese.In the third sample, the consonant "c" goes after the consonant "r", and the consonant "s" stands on the end, so the word is not Berlanese.
Print "YES" (without quotes) if there is a vowel after every consonant except "n", otherwise print "NO". You can print each letter in any case (upper or lower).
Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant.In Berlanese, there has to be a vowel after every consonant, but there can be any letter after any vowel. The only exception is a consonant "n"; after this letter, there can be any letter (not only a vowel) or there can be no letter at all. For example, the words "harakiri", "yupie", "man", and "nbo" are Berlanese while the words "horse", "king", "my", and "nz" are not.Help Vitya find out if a word $$$s$$$ is Berlanese.
[{"input": "sumimasen\r\n", "output": ["YES"]}, {"input": "ninja\r\n", "output": ["YES"]}, {"input": "codeforces\r\n", "output": ["NO"]}, {"input": "auuaoonntanonnuewannnnpuuinniwoonennyolonnnvienonpoujinndinunnenannmuveoiuuhikucuziuhunnnmunzancenen\r\n", "output": ["YES"]}, {"input": "n\r\n", "output": ["YES"]}, {"input": "necnei\r\n", "output": ["NO"]}, {"input": "nternn\r\n", "output": ["NO"]}, {"input": "aucunuohja\r\n", "output": ["NO"]}, {"input": "a\r\n", "output": ["YES"]}, {"input": "b\r\n", "output": ["NO"]}, {"input": "nn\r\n", "output": ["YES"]}, {"input": "nnnzaaa\r\n", "output": ["YES"]}, {"input": "zn\r\n", "output": ["NO"]}, {"input": "ab\r\n", "output": ["NO"]}, {"input": "aaaaaaaaaa\r\n", "output": ["YES"]}, {"input": "aaaaaaaaab\r\n", "output": ["NO"]}, {"input": "aaaaaaaaan\r\n", "output": ["YES"]}, {"input": "baaaaaaaaa\r\n", "output": ["YES"]}, {"input": "naaaaaaaaa\r\n", "output": ["YES"]}, {"input": "nbaaaaaaaa\r\n", "output": ["YES"]}, {"input": "bbaaaaaaaa\r\n", "output": ["NO"]}, {"input": "bnaaaaaaaa\r\n", "output": ["NO"]}, {"input": "eonwonojannonnufimiiniewuqaienokacevecinfuqihatenhunliquuyebayiaenifuexuanenuaounnboancaeowonu\r\n", "output": ["YES"]}, {"input": "uixinnepnlinqaingieianndeakuniooudidonnnqeaituioeneiroionxuowudiooonayenfeonuino\r\n", "output": ["NO"]}, {"input": "nnnnnyigaveteononnnnxaalenxuiiwannntoxonyoqonlejuoxuoconnnentoinnul\r\n", "output": ["NO"]}, {"input": "ndonneasoiunhomuunnhuitonnntunntoanerekonoupunanuauenu\r\n", "output": ["YES"]}, {"input": "anujemogawautiedoneobninnibonuunaoennnyoorufonxionntinimiboonununnnnnleenqunminzayoutanlalo\r\n", "output": ["NO"]}, {"input": "y\r\n", "output": ["NO"]}, {"input": "by\r\n", "output": ["NO"]}, {"input": "yy\r\n", "output": ["NO"]}, {"input": "nbn\r\n", "output": ["NO"]}, {"input": "nz\r\n", "output": ["NO"]}, {"input": "king\r\n", "output": ["NO"]}, {"input": "g\r\n", "output": ["NO"]}, {"input": "az\r\n", "output": ["NO"]}, {"input": "x\r\n", "output": ["NO"]}, {"input": "z\r\n", "output": ["NO"]}, {"input": "yn\r\n", "output": ["NO"]}, {"input": "aeo\r\n", "output": ["YES"]}, {"input": "nb\r\n", "output": ["NO"]}, {"input": "npn\r\n", "output": ["NO"]}, {"input": "kini\r\n", "output": ["YES"]}, {"input": "pya\r\n", "output": ["NO"]}, {"input": "m\r\n", "output": ["NO"]}, {"input": "p\r\n", "output": ["NO"]}, {"input": "aaaaaaaak\r\n", "output": ["NO"]}, {"input": "aab\r\n", "output": ["NO"]}, {"input": "d\r\n", "output": ["NO"]}, {"input": "at\r\n", "output": ["NO"]}, {"input": "aaaaaak\r\n", "output": ["NO"]}, {"input": "aaz\r\n", "output": ["NO"]}, {"input": "aaab\r\n", "output": ["NO"]}, {"input": "s\r\n", "output": ["NO"]}, {"input": "nzzen\r\n", "output": ["NO"]}, {"input": "aeionnhhhn\r\n", "output": ["NO"]}, {"input": "h\r\n", "output": ["NO"]}, {"input": "ny\r\n", "output": ["NO"]}]
100
100
100
[{'input': 'nn\r\n', 'output': ['YES']}, {'input': 'nternn\r\n', 'output': ['NO']}, {'input': 'aaz\r\n', 'output': ['NO']}, {'input': 'naaaaaaaaa\r\n', 'output': ['YES']}, {'input': 'uixinnepnlinqaingieianndeakuniooudidonnnqeaituioeneiroionxuowudiooonayenfeonuino\r\n', 'output': ['NO']}]
[{'input': 'aeo\r\n', 'output': ['YES']}, {'input': 'nternn\r\n', 'output': ['NO']}, {'input': 'aaaaaak\r\n', 'output': ['NO']}, {'input': 'ninja\r\n', 'output': ['YES']}, {'input': 'kini\r\n', 'output': ['YES']}]
[{'input': 'nbaaaaaaaa\r\n', 'output': ['YES']}, {'input': 'ndonneasoiunhomuunnhuitonnntunntoanerekonoupunanuauenu\r\n', 'output': ['YES']}, {'input': 'ninja\r\n', 'output': ['YES']}, {'input': 'necnei\r\n', 'output': ['NO']}, {'input': 'yn\r\n', 'output': ['NO']}]
[{'input': 'm\r\n', 'output': ['NO']}, {'input': 'king\r\n', 'output': ['NO']}, {'input': 'aaab\r\n', 'output': ['NO']}, {'input': 'y\r\n', 'output': ['NO']}, {'input': 'a\r\n', 'output': ['YES']}]
[{'input': 'aucunuohja\r\n', 'output': ['NO']}, {'input': 'ninja\r\n', 'output': ['YES']}, {'input': 'anujemogawautiedoneobninnibonuunaoennnyoorufonxionntinimiboonununnnnnleenqunminzayoutanlalo\r\n', 'output': ['NO']}, {'input': 'codeforces\r\n', 'output': ['NO']}, {'input': 'b\r\n', 'output': ['NO']}]
100
100
100
100
100
100
100
100
100
100
95
95
100
85
100
164
100
100
95
["104 2", "223 4", "7067678 8"]
The first line contains two integers: n (1 ≤ n &lt; 1018) and m (1 ≤ m ≤ 100).
5eb90c23ffa3794fdddc5670c0373829
//codeforces 401D Roman and Numbers #include<bits/stdc++.h> #define ll long long const int maxs=(1<<18)+5; const int maxn=110; using namespace std; int cnt=-1,w[20],m; ll f[maxs][maxn],n; bool vis[10]; int main(){ for(cin>>n>>m;n;n/=10) w[++cnt]=n%10; f[0][0]=1; for(int s=1;s<1<<cnt+1;s++){ memset(vis,0,sizeof vis); for(int i=0;i<=cnt;i++){ if(s==(1<<i)&&!w[i]) break; if(!(s&(1<<i))||vis[w[i]]) continue; vis[w[i]]=1; for(int j=0;j<m;j++) f[s][(j*10+w[i])%m]=(f[s][(j*10+w[i])%m]+f[s^(1<<i)][j]); } } cout<<f[(1<<cnt+1)-1][0]; return 0; }
["3", "1", "47"]
C++
NoteIn the first sample the required numbers are: 104, 140, 410.In the second sample the required number is 232.
In a single line print a single integer — the number of numbers close to number n modulo m.
Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.Number x is considered close to number n modulo m, if: it can be obtained by rearranging the digits of number n, it doesn't have any leading zeroes, the remainder after dividing number x by m equals 0. Roman is a good mathematician, but the number of such numbers is too huge for him. So he asks you to help him.
[{"input": "104 2\r\n", "output": ["3"]}, {"input": "223 4\r\n", "output": ["1"]}, {"input": "7067678 8\r\n", "output": ["47"]}, {"input": "202 10\r\n", "output": ["1"]}, {"input": "1306432 9\r\n", "output": ["0"]}, {"input": "9653092 9\r\n", "output": ["0"]}, {"input": "600038 6\r\n", "output": ["0"]}, {"input": "4064044 4\r\n", "output": ["65"]}, {"input": "5899025 7\r\n", "output": ["153"]}, {"input": "2496234323687 2\r\n", "output": ["26611200"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "123456789123456789 2\r\n", "output": ["5557616064000"]}, {"input": "123 1\r\n", "output": ["6"]}, {"input": "6328128 6\r\n", "output": ["900"]}, {"input": "8966261 5\r\n", "output": ["0"]}, {"input": "8900064 4\r\n", "output": ["316"]}, {"input": "576021249 86\r\n", "output": ["2091"]}, {"input": "682459775 6\r\n", "output": ["0"]}, {"input": "458498549 4\r\n", "output": ["2100"]}, {"input": "511736928 87\r\n", "output": ["6267"]}, {"input": "275126649 81\r\n", "output": ["0"]}, {"input": "576279776452 33\r\n", "output": ["0"]}, {"input": "450497776413 3\r\n", "output": ["12196800"]}, {"input": "356884378713 24\r\n", "output": ["554400"]}, {"input": "89058837012 65\r\n", "output": ["60616"]}, {"input": "884654082330 71\r\n", "output": ["117073"]}, {"input": "181939172581 23\r\n", "output": ["216735"]}, {"input": "555549171905 10\r\n", "output": ["83160"]}, {"input": "347161822604 67\r\n", "output": ["409390"]}, {"input": "734944298780 13\r\n", "output": ["702988"]}, {"input": "848092188917 18\r\n", "output": ["0"]}, {"input": "379620222683264759 39\r\n", "output": ["0"]}, {"input": "173043406290107692 90\r\n", "output": ["0"]}, {"input": "195176731478682385 14\r\n", "output": ["205836996960"]}, {"input": "63436369526943580 59\r\n", "output": ["1231321437"]}, {"input": "385383273011112989 11\r\n", "output": ["39548174400"]}, {"input": "412729214864015139 96\r\n", "output": ["109654776000"]}, {"input": "227038765076961932 79\r\n", "output": ["41687924851"]}, {"input": "498744630369919412 82\r\n", "output": ["16056754308"]}, {"input": "280798391352360320 72\r\n", "output": ["0"]}, {"input": "795452688779941322 52\r\n", "output": ["63335115897"]}, {"input": "5014489842919580 5\r\n", "output": ["2724321600"]}, {"input": "9615722072995774 82\r\n", "output": ["104605125"]}, {"input": "7441738340032798 84\r\n", "output": ["0"]}, {"input": "9003489956983022 37\r\n", "output": ["399073500"]}, {"input": "2454597559364838 19\r\n", "output": ["955902382"]}, {"input": "4410755660493003 8\r\n", "output": ["2052388800"]}, {"input": "6375967545169807 15\r\n", "output": ["0"]}, {"input": "3593106551449275 59\r\n", "output": ["865762883"]}, {"input": "9458580614310278 16\r\n", "output": ["14070672000"]}, {"input": "2866933879413767 4\r\n", "output": ["5448643200"]}, {"input": "7076043389696504 4\r\n", "output": ["8627018400"]}, {"input": "36160302795340 2\r\n", "output": ["485654400"]}, {"input": "1296319391649597 4\r\n", "output": ["1180539360"]}, {"input": "4300962713274444 2\r\n", "output": ["5993507520"]}, {"input": "90876543212468024 2\r\n", "output": ["771891120000"]}, {"input": "7769468502479263 9\r\n", "output": ["0"]}, {"input": "3027468649121495 10\r\n", "output": ["13621608000"]}, {"input": "2312734624976780 10\r\n", "output": ["4540536000"]}, {"input": "6632346285917617 1\r\n", "output": ["54486432000"]}, {"input": "1240656721470018 9\r\n", "output": ["29513484000"]}, {"input": "3345289321458628 8\r\n", "output": ["3416212800"]}, {"input": "3802128082766215 4\r\n", "output": ["5340535200"]}, {"input": "12345678902468000 2\r\n", "output": ["503999496000"]}, {"input": "8227332913355818 8\r\n", "output": ["583783200"]}, {"input": "6404415286642984 10\r\n", "output": ["454053600"]}, {"input": "10000000000000000 100\r\n", "output": ["1"]}, {"input": "1 100\r\n", "output": ["0"]}, {"input": "2147483647 97\r\n", "output": ["3135"]}, {"input": "88888888888888888 88\r\n", "output": ["0"]}, {"input": "99999999999999999 99\r\n", "output": ["0"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "12468024680246802 2\r\n", "output": ["8870862000"]}, {"input": "123456789123456789 100\r\n", "output": ["0"]}, {"input": "123456789123456700 100\r\n", "output": ["163459296000"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "123456789123456789 1\r\n", "output": ["12504636144000"]}, {"input": "987654321987654321 1\r\n", "output": ["12504636144000"]}, {"input": "213780 7\r\n", "output": ["60"]}, {"input": "102233445566778899 89\r\n", "output": ["265391558945"]}, {"input": "110022334455667788 10\r\n", "output": ["1307674368000"]}]
100
100
100
[{'input': '9003489956983022 37\r\n', 'output': ['399073500']}, {'input': '223 4\r\n', 'output': ['1']}, {'input': '458498549 4\r\n', 'output': ['2100']}, {'input': '9653092 9\r\n', 'output': ['0']}, {'input': '102233445566778899 89\r\n', 'output': ['265391558945']}]
[{'input': '104 2\r\n', 'output': ['3']}, {'input': '848092188917 18\r\n', 'output': ['0']}, {'input': '1 1\r\n', 'output': ['1']}, {'input': '987654321987654321 1\r\n', 'output': ['12504636144000']}, {'input': '63436369526943580 59\r\n', 'output': ['1231321437']}]
[{'input': '450497776413 3\r\n', 'output': ['12196800']}, {'input': '123456789123456789 2\r\n', 'output': ['5557616064000']}, {'input': '3345289321458628 8\r\n', 'output': ['3416212800']}, {'input': '458498549 4\r\n', 'output': ['2100']}, {'input': '36160302795340 2\r\n', 'output': ['485654400']}]
[{'input': '9615722072995774 82\r\n', 'output': ['104605125']}, {'input': '2866933879413767 4\r\n', 'output': ['5448643200']}, {'input': '123456789123456700 100\r\n', 'output': ['163459296000']}, {'input': '1296319391649597 4\r\n', 'output': ['1180539360']}, {'input': '181939172581 23\r\n', 'output': ['216735']}]
[{'input': '7076043389696504 4\r\n', 'output': ['8627018400']}, {'input': '3802128082766215 4\r\n', 'output': ['5340535200']}, {'input': '123456789123456700 100\r\n', 'output': ['163459296000']}, {'input': '8966261 5\r\n', 'output': ['0']}, {'input': '6328128 6\r\n', 'output': ['900']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
165
100
100
100
["5 3\n0 4 5 6 7", "1 0\n0", "5 0\n1 2 3 4 5"]
The first line contains two integers n and x (1 ≤ n ≤ 100, 0 ≤ x ≤ 100) — the size of the set Dr. Evil owns, and the desired MEX. The second line contains n distinct non-negative integers not exceeding 100 that represent the set.
21f579ba807face432a7664091581cd8
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; const int maxn = 105; int n,m; int mp[maxn]; int a[maxn]; int main() { cin>>n>>m; /*int mp[maxn]; int a[maxn];*/ int cnt; //memset(mp,0,sizeof(mp)); for(int i=0;i<n;i++) { cin>>a[i]; mp[a[i]]=1; } cnt=0; if(mp[m]==1) cnt++; for(int i=0;i<m;i++) { if(mp[i]==0) cnt++; } cout<<cnt<<endl; return 0; }
["2", "1", "0"]
C++
NoteFor the first test case Dr. Evil should add 1 and 2 to the set performing 2 operations.For the second test case Dr. Evil should erase 0 from the set. After that, the set becomes empty, so the MEX of it is 0.In the third test case the set is already evil.
The only line should contain one integer — the minimal number of operations Dr. Evil should perform.
Dr. Evil kidnapped Mahmoud and Ehab in the evil land because of their performance in the Evil Olympiad in Informatics (EOI). He decided to give them some problems to let them go.Dr. Evil is interested in sets, He has a set of n integers. Dr. Evil calls a set of integers evil if the MEX of it is exactly x. the MEX of a set of integers is the minimum non-negative integer that doesn't exist in it. For example, the MEX of the set {0, 2, 4} is 1 and the MEX of the set {1, 2, 3} is 0 .Dr. Evil is going to make his set evil. To do this he can perform some operations. During each operation he can add some non-negative integer to his set or erase some element from it. What is the minimal number of operations Dr. Evil has to perform to make his set evil?
[{"input": "5 3\r\n0 4 5 6 7\r\n", "output": ["2"]}, {"input": "1 0\r\n0\r\n", "output": ["1"]}, {"input": "5 0\r\n1 2 3 4 5\r\n", "output": ["0"]}, {"input": "10 5\r\n57 1 47 9 93 37 76 70 78 15\r\n", "output": ["4"]}, {"input": "10 5\r\n99 98 93 97 95 100 92 94 91 96\r\n", "output": ["5"]}, {"input": "10 5\r\n1 2 3 4 59 45 0 58 51 91\r\n", "output": ["0"]}, {"input": "100 100\r\n79 13 21 11 3 87 28 40 29 4 96 34 8 78 61 46 33 45 99 30 92 67 22 97 39 86 73 31 74 44 62 55 57 2 54 63 80 69 25 48 77 98 17 93 15 16 89 12 43 23 37 95 14 38 83 90 49 56 72 10 20 0 50 71 70 88 19 1 76 81 52 41 82 68 85 47 6 7 35 60 18 64 75 84 27 9 65 91 94 42 53 24 66 26 59 36 51 32 5 58\r\n", "output": ["0"]}, {"input": "100 50\r\n95 78 46 92 80 18 79 58 30 72 19 89 39 29 44 65 15 100 59 8 96 9 62 67 41 42 82 14 57 32 71 77 40 5 7 51 28 53 85 23 16 35 3 91 6 11 75 61 17 66 13 47 36 56 10 22 83 60 48 24 26 97 4 33 76 86 70 0 34 64 52 43 21 49 55 74 1 73 81 25 54 63 94 84 20 68 87 12 31 88 38 93 37 90 98 69 99 45 27 2\r\n", "output": ["0"]}, {"input": "100 33\r\n28 11 79 92 88 62 77 72 7 41 96 97 67 84 44 8 81 35 38 1 64 68 46 17 98 83 31 12 74 21 2 22 47 6 36 75 65 61 37 26 25 45 59 48 100 51 93 76 78 49 3 57 16 4 87 29 55 82 70 39 53 0 60 15 24 71 58 20 66 89 95 42 13 43 63 90 85 52 50 30 54 40 56 23 27 34 32 18 10 19 69 9 99 73 91 14 5 80 94 86\r\n", "output": ["0"]}, {"input": "99 33\r\n25 76 41 95 55 20 47 59 58 84 87 92 16 27 35 65 72 63 93 54 36 96 15 86 5 69 24 46 67 73 48 60 40 6 61 74 97 10 100 8 52 26 77 18 7 62 37 2 14 66 11 56 68 91 0 64 75 99 30 21 53 1 89 81 3 98 12 88 39 38 29 83 22 90 9 28 45 43 78 44 32 57 4 50 70 17 13 51 80 85 71 94 82 19 34 42 23 79 49\r\n", "output": ["1"]}, {"input": "100 100\r\n65 56 84 46 44 33 99 74 62 72 93 67 43 92 75 88 38 34 66 12 55 76 58 90 78 8 14 45 97 59 48 32 64 18 39 89 31 51 54 81 29 36 70 77 40 22 49 27 3 1 73 13 98 42 87 37 2 57 4 6 50 25 23 79 28 86 68 61 80 17 19 10 15 63 52 11 35 60 21 16 24 85 30 91 7 5 69 20 71 82 53 94 41 95 96 9 26 83 0 47\r\n", "output": ["0"]}, {"input": "100 100\r\n58 88 12 71 22 1 40 19 73 20 67 48 57 17 69 36 100 35 33 37 72 55 52 8 89 85 47 42 78 70 81 86 11 9 68 99 6 16 21 61 53 98 23 62 32 59 51 0 87 24 50 30 65 10 80 95 7 92 25 74 60 79 91 5 13 31 75 38 90 94 46 66 93 34 14 41 28 2 76 84 43 96 3 56 49 82 27 77 64 63 4 45 18 29 54 39 15 26 83 44\r\n", "output": ["2"]}, {"input": "89 100\r\n58 96 17 41 86 34 28 84 18 40 8 77 87 89 68 79 33 35 53 49 0 6 22 12 72 90 48 55 21 50 56 62 75 2 37 95 69 74 14 20 44 46 27 32 31 59 63 60 10 85 71 70 38 52 94 30 61 51 80 26 36 23 39 47 76 45 100 57 15 78 97 66 54 13 99 16 93 73 24 4 83 5 98 81 92 25 29 88 65\r\n", "output": ["13"]}, {"input": "100 50\r\n7 95 24 76 81 78 60 69 83 84 100 1 65 31 48 92 73 39 18 89 38 97 10 42 8 55 98 51 21 90 62 77 16 91 0 94 4 37 19 17 67 35 45 41 56 20 15 85 75 28 59 27 12 54 61 68 36 5 79 93 66 11 70 49 50 34 30 25 96 46 64 14 32 22 47 40 58 23 43 9 87 82 26 53 80 52 3 86 13 99 33 71 6 88 57 74 2 44 72 63\r\n", "output": ["2"]}, {"input": "77 0\r\n27 8 20 92 21 41 53 98 17 65 67 35 81 11 55 49 61 44 2 66 51 89 40 28 52 62 86 91 64 24 18 5 94 82 96 99 71 6 39 83 26 29 16 30 45 97 80 90 69 12 13 33 76 73 46 19 78 56 88 38 42 34 57 77 47 4 59 58 7 100 95 72 9 74 15 43 54\r\n", "output": ["0"]}, {"input": "100 50\r\n55 36 0 32 81 6 17 43 24 13 30 19 8 59 71 45 15 74 3 41 99 42 86 47 2 94 35 1 66 95 38 49 4 27 96 89 34 44 92 25 51 39 54 28 80 77 20 14 48 40 68 56 31 63 33 78 69 37 18 26 83 70 23 82 91 65 67 52 61 53 7 22 60 21 12 73 72 87 75 100 90 29 64 79 98 85 5 62 93 84 50 46 97 58 57 16 9 10 76 11\r\n", "output": ["1"]}, {"input": "77 0\r\n12 8 19 87 9 54 55 86 97 7 27 85 25 48 94 73 26 1 13 57 72 69 76 39 38 91 75 40 42 28 93 21 70 84 65 11 60 90 20 95 66 89 59 47 34 99 6 61 52 100 50 3 77 81 82 53 15 24 0 45 44 14 68 96 58 5 18 35 10 98 29 74 92 49 83 71 17\r\n", "output": ["1"]}, {"input": "100 70\r\n25 94 66 65 10 99 89 6 70 31 7 40 20 92 64 27 21 72 77 98 17 43 47 44 48 81 38 56 100 39 90 22 88 76 3 83 86 29 33 55 82 79 49 11 2 16 12 78 85 69 32 97 26 15 53 24 23 91 51 67 34 35 52 5 62 50 95 18 71 13 75 8 30 42 93 36 45 60 63 46 57 41 87 0 84 54 74 37 4 58 28 19 96 61 80 9 1 14 73 68\r\n", "output": ["2"]}, {"input": "89 19\r\n14 77 85 81 79 38 91 45 55 51 50 11 62 67 73 76 2 27 16 23 3 29 65 98 78 17 4 58 22 20 34 66 64 31 72 5 32 44 12 75 80 47 18 25 99 0 61 56 71 84 48 88 10 7 86 8 49 24 43 21 37 28 33 54 46 57 40 89 36 97 6 96 39 95 26 74 1 69 9 100 52 30 83 87 68 60 92 90 35\r\n", "output": ["2"]}, {"input": "89 100\r\n69 61 56 45 11 41 42 32 28 29 0 76 7 65 13 35 36 82 10 39 26 34 38 40 92 12 17 54 24 46 88 70 66 27 100 52 85 62 22 48 86 68 21 49 53 94 67 20 1 90 77 84 31 87 58 47 95 33 4 72 93 83 8 51 91 80 99 43 71 19 44 59 98 97 64 9 81 16 79 63 25 37 3 75 2 55 50 6 18\r\n", "output": ["13"]}, {"input": "77 0\r\n38 76 24 74 42 88 29 75 96 46 90 32 59 97 98 60 41 57 80 37 100 49 25 63 95 31 61 68 53 78 27 66 84 48 94 83 30 26 36 99 71 62 45 47 70 28 35 54 34 85 79 43 91 72 86 33 67 92 77 65 69 52 82 55 87 64 56 40 50 44 51 73 89 81 58 93 39\r\n", "output": ["0"]}, {"input": "89 100\r\n38 90 80 64 35 44 56 11 15 89 23 12 49 70 72 60 63 85 92 10 45 83 8 88 41 33 16 6 61 76 62 71 87 13 25 77 74 0 1 37 96 93 7 94 21 82 34 78 4 73 65 20 81 95 50 32 48 17 69 55 68 5 51 27 53 43 91 67 59 46 86 84 99 24 22 3 97 98 40 36 26 58 57 9 42 30 52 2 47\r\n", "output": ["11"]}, {"input": "77 0\r\n55 71 78 86 68 35 53 10 59 32 81 19 74 97 62 61 93 87 96 44 25 18 43 82 84 16 34 48 92 39 64 36 49 91 45 76 95 31 57 29 75 79 13 2 14 24 52 23 33 20 47 99 63 15 5 80 58 67 12 3 85 6 1 27 73 90 4 42 37 70 8 11 89 77 9 22 94\r\n", "output": ["0"]}, {"input": "77 0\r\n12 75 31 71 44 8 3 82 21 77 50 29 57 74 40 10 15 42 84 2 100 9 28 72 92 0 49 11 90 55 17 36 19 54 68 52 4 69 97 91 5 39 59 45 89 62 53 83 16 94 76 60 95 47 30 51 7 48 20 70 67 32 58 78 63 34 56 93 99 88 24 1 66 22 25 14 13\r\n", "output": ["1"]}, {"input": "100 70\r\n91 82 8 85 26 25 95 97 40 87 81 93 7 73 38 94 64 96 74 18 90 19 65 68 72 61 23 43 36 41 60 88 30 33 71 24 52 39 15 3 16 89 86 79 55 4 9 58 67 44 46 29 6 48 84 69 27 21 78 54 51 57 80 53 76 50 47 77 45 12 34 10 100 0 17 31 56 99 98 11 92 5 2 42 32 59 66 62 37 63 28 75 35 1 22 13 83 49 20 14\r\n", "output": ["0"]}, {"input": "77 0\r\n51 5 81 62 30 22 11 0 83 16 79 85 52 70 69 10 8 47 58 3 24 34 44 14 82 66 99 17 28 31 64 67 23 49 94 45 4 12 27 15 21 6 43 72 87 2 63 92 35 39 59 9 90 78 93 20 65 36 60 89 50 41 61 84 77 86 76 100 38 68 53 97 96 95 7 19 88\r\n", "output": ["1"]}, {"input": "1 100\r\n0\r\n", "output": ["99"]}, {"input": "1 0\r\n100\r\n", "output": ["0"]}, {"input": "1 100\r\n100\r\n", "output": ["101"]}, {"input": "2 100\r\n0 100\r\n", "output": ["100"]}, {"input": "5 5\r\n1 2 3 4 5\r\n", "output": ["2"]}, {"input": "5 3\r\n0 3 4 5 6\r\n", "output": ["3"]}, {"input": "7 10\r\n0 1 2 3 4 5 10\r\n", "output": ["5"]}, {"input": "2 2\r\n0 2\r\n", "output": ["2"]}, {"input": "2 1\r\n1 2\r\n", "output": ["2"]}, {"input": "5 1\r\n1 2 3 4 5\r\n", "output": ["2"]}, {"input": "5 2\r\n1 2 3 4 5\r\n", "output": ["2"]}, {"input": "5 6\r\n0 1 2 3 4\r\n", "output": ["1"]}, {"input": "3 2\r\n3 4 5\r\n", "output": ["2"]}]
100
100
100
[{'input': '10 5\r\n99 98 93 97 95 100 92 94 91 96\r\n', 'output': ['5']}, {'input': '100 70\r\n91 82 8 85 26 25 95 97 40 87 81 93 7 73 38 94 64 96 74 18 90 19 65 68 72 61 23 43 36 41 60 88 30 33 71 24 52 39 15 3 16 89 86 79 55 4 9 58 67 44 46 29 6 48 84 69 27 21 78 54 51 57 80 53 76 50 47 77 45 12 34 10 100 0 17 31 56 99 98 11 92 5 2 42 32 59 66 62 37 63 28 75 35 1 22 13 83 49 20 14\r\n', 'output': ['0']}, {'input': '5 6\r\n0 1 2 3 4\r\n', 'output': ['1']}, {'input': '77 0\r\n27 8 20 92 21 41 53 98 17 65 67 35 81 11 55 49 61 44 2 66 51 89 40 28 52 62 86 91 64 24 18 5 94 82 96 99 71 6 39 83 26 29 16 30 45 97 80 90 69 12 13 33 76 73 46 19 78 56 88 38 42 34 57 77 47 4 59 58 7 100 95 72 9 74 15 43 54\r\n', 'output': ['0']}, {'input': '1 100\r\n0\r\n', 'output': ['99']}]
[{'input': '100 50\r\n55 36 0 32 81 6 17 43 24 13 30 19 8 59 71 45 15 74 3 41 99 42 86 47 2 94 35 1 66 95 38 49 4 27 96 89 34 44 92 25 51 39 54 28 80 77 20 14 48 40 68 56 31 63 33 78 69 37 18 26 83 70 23 82 91 65 67 52 61 53 7 22 60 21 12 73 72 87 75 100 90 29 64 79 98 85 5 62 93 84 50 46 97 58 57 16 9 10 76 11\r\n', 'output': ['1']}, {'input': '5 0\r\n1 2 3 4 5\r\n', 'output': ['0']}, {'input': '89 19\r\n14 77 85 81 79 38 91 45 55 51 50 11 62 67 73 76 2 27 16 23 3 29 65 98 78 17 4 58 22 20 34 66 64 31 72 5 32 44 12 75 80 47 18 25 99 0 61 56 71 84 48 88 10 7 86 8 49 24 43 21 37 28 33 54 46 57 40 89 36 97 6 96 39 95 26 74 1 69 9 100 52 30 83 87 68 60 92 90 35\r\n', 'output': ['2']}, {'input': '3 2\r\n3 4 5\r\n', 'output': ['2']}, {'input': '100 50\r\n95 78 46 92 80 18 79 58 30 72 19 89 39 29 44 65 15 100 59 8 96 9 62 67 41 42 82 14 57 32 71 77 40 5 7 51 28 53 85 23 16 35 3 91 6 11 75 61 17 66 13 47 36 56 10 22 83 60 48 24 26 97 4 33 76 86 70 0 34 64 52 43 21 49 55 74 1 73 81 25 54 63 94 84 20 68 87 12 31 88 38 93 37 90 98 69 99 45 27 2\r\n', 'output': ['0']}]
[{'input': '5 3\r\n0 4 5 6 7\r\n', 'output': ['2']}, {'input': '5 0\r\n1 2 3 4 5\r\n', 'output': ['0']}, {'input': '99 33\r\n25 76 41 95 55 20 47 59 58 84 87 92 16 27 35 65 72 63 93 54 36 96 15 86 5 69 24 46 67 73 48 60 40 6 61 74 97 10 100 8 52 26 77 18 7 62 37 2 14 66 11 56 68 91 0 64 75 99 30 21 53 1 89 81 3 98 12 88 39 38 29 83 22 90 9 28 45 43 78 44 32 57 4 50 70 17 13 51 80 85 71 94 82 19 34 42 23 79 49\r\n', 'output': ['1']}, {'input': '89 100\r\n58 96 17 41 86 34 28 84 18 40 8 77 87 89 68 79 33 35 53 49 0 6 22 12 72 90 48 55 21 50 56 62 75 2 37 95 69 74 14 20 44 46 27 32 31 59 63 60 10 85 71 70 38 52 94 30 61 51 80 26 36 23 39 47 76 45 100 57 15 78 97 66 54 13 99 16 93 73 24 4 83 5 98 81 92 25 29 88 65\r\n', 'output': ['13']}, {'input': '100 50\r\n55 36 0 32 81 6 17 43 24 13 30 19 8 59 71 45 15 74 3 41 99 42 86 47 2 94 35 1 66 95 38 49 4 27 96 89 34 44 92 25 51 39 54 28 80 77 20 14 48 40 68 56 31 63 33 78 69 37 18 26 83 70 23 82 91 65 67 52 61 53 7 22 60 21 12 73 72 87 75 100 90 29 64 79 98 85 5 62 93 84 50 46 97 58 57 16 9 10 76 11\r\n', 'output': ['1']}]
[{'input': '100 70\r\n25 94 66 65 10 99 89 6 70 31 7 40 20 92 64 27 21 72 77 98 17 43 47 44 48 81 38 56 100 39 90 22 88 76 3 83 86 29 33 55 82 79 49 11 2 16 12 78 85 69 32 97 26 15 53 24 23 91 51 67 34 35 52 5 62 50 95 18 71 13 75 8 30 42 93 36 45 60 63 46 57 41 87 0 84 54 74 37 4 58 28 19 96 61 80 9 1 14 73 68\r\n', 'output': ['2']}, {'input': '100 50\r\n55 36 0 32 81 6 17 43 24 13 30 19 8 59 71 45 15 74 3 41 99 42 86 47 2 94 35 1 66 95 38 49 4 27 96 89 34 44 92 25 51 39 54 28 80 77 20 14 48 40 68 56 31 63 33 78 69 37 18 26 83 70 23 82 91 65 67 52 61 53 7 22 60 21 12 73 72 87 75 100 90 29 64 79 98 85 5 62 93 84 50 46 97 58 57 16 9 10 76 11\r\n', 'output': ['1']}, {'input': '89 100\r\n58 96 17 41 86 34 28 84 18 40 8 77 87 89 68 79 33 35 53 49 0 6 22 12 72 90 48 55 21 50 56 62 75 2 37 95 69 74 14 20 44 46 27 32 31 59 63 60 10 85 71 70 38 52 94 30 61 51 80 26 36 23 39 47 76 45 100 57 15 78 97 66 54 13 99 16 93 73 24 4 83 5 98 81 92 25 29 88 65\r\n', 'output': ['13']}, {'input': '77 0\r\n51 5 81 62 30 22 11 0 83 16 79 85 52 70 69 10 8 47 58 3 24 34 44 14 82 66 99 17 28 31 64 67 23 49 94 45 4 12 27 15 21 6 43 72 87 2 63 92 35 39 59 9 90 78 93 20 65 36 60 89 50 41 61 84 77 86 76 100 38 68 53 97 96 95 7 19 88\r\n', 'output': ['1']}, {'input': '99 33\r\n25 76 41 95 55 20 47 59 58 84 87 92 16 27 35 65 72 63 93 54 36 96 15 86 5 69 24 46 67 73 48 60 40 6 61 74 97 10 100 8 52 26 77 18 7 62 37 2 14 66 11 56 68 91 0 64 75 99 30 21 53 1 89 81 3 98 12 88 39 38 29 83 22 90 9 28 45 43 78 44 32 57 4 50 70 17 13 51 80 85 71 94 82 19 34 42 23 79 49\r\n', 'output': ['1']}]
[{'input': '100 50\r\n95 78 46 92 80 18 79 58 30 72 19 89 39 29 44 65 15 100 59 8 96 9 62 67 41 42 82 14 57 32 71 77 40 5 7 51 28 53 85 23 16 35 3 91 6 11 75 61 17 66 13 47 36 56 10 22 83 60 48 24 26 97 4 33 76 86 70 0 34 64 52 43 21 49 55 74 1 73 81 25 54 63 94 84 20 68 87 12 31 88 38 93 37 90 98 69 99 45 27 2\r\n', 'output': ['0']}, {'input': '89 100\r\n58 96 17 41 86 34 28 84 18 40 8 77 87 89 68 79 33 35 53 49 0 6 22 12 72 90 48 55 21 50 56 62 75 2 37 95 69 74 14 20 44 46 27 32 31 59 63 60 10 85 71 70 38 52 94 30 61 51 80 26 36 23 39 47 76 45 100 57 15 78 97 66 54 13 99 16 93 73 24 4 83 5 98 81 92 25 29 88 65\r\n', 'output': ['13']}, {'input': '7 10\r\n0 1 2 3 4 5 10\r\n', 'output': ['5']}, {'input': '10 5\r\n99 98 93 97 95 100 92 94 91 96\r\n', 'output': ['5']}, {'input': '100 50\r\n55 36 0 32 81 6 17 43 24 13 30 19 8 59 71 45 15 74 3 41 99 42 86 47 2 94 35 1 66 95 38 49 4 27 96 89 34 44 92 25 51 39 54 28 80 77 20 14 48 40 68 56 31 63 33 78 69 37 18 26 83 70 23 82 91 65 67 52 61 53 7 22 60 21 12 73 72 87 75 100 90 29 64 79 98 85 5 62 93 84 50 46 97 58 57 16 9 10 76 11\r\n', 'output': ['1']}]
100
100
100
100
100
100
100
100
100
100
87.5
100
100
100
100
166
100
100
97.5
["2 47", "47 1024"]
The single line contains a pair of integers l and r (1 ≤ l ≤ r ≤ 1018) — the boundaries of the interval. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.
9642368dc4ffe2fc6fe6438c7406c1bd
#include <iostream> #include <string> #include <cstring> #include <sstream> #include <set> #include <map> #include <queue> #include <cstdio> #include <algorithm> #include <math.h> using namespace std; #define f(i,s,e) for (int i = int(s); i != int(e); i++) #define ft(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) #define all(c) (c).begin(), (c).end() //read scanf functions #define readI(x) scanf("%d", &x) #define readL(x) scanf("%I64d", &x) #define readD(x) scanf("%f", &x) #define readII(x, y) scanf("%d %d", &x, &y) #define readLL(x, y) scanf("%I64d %I64d", &x, &y) typedef long long ll; ll l, r; int cntDigits(ll x) { int ret =0; while (x) ret++, x/=10; return ret; } ll power[20]; ll solve(ll x) { ll ret; if (x <= 9) ret = x; else ret = x/10-1+9; if (x>9) ret += ((x%10)>=x/(power[cntDigits(x)-1])); return ret; } int main() { cin >> l >> r; power[0]= 1; for(int i=1; i<=19; i++) power[i] = power[i-1]*10; cout << solve(r) - solve(l-1) << "\n"; return 0; }
["12", "98"]
C++
NoteIn the first sample the answer includes integers 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44.
On a single line print a single integer — the answer to the problem.
The Little Elephant very much loves sums on intervals.This time he has a pair of integers l and r (l ≤ r). The Little Elephant has to find the number of such integers x (l ≤ x ≤ r), that the first digit of integer x equals the last one (in decimal notation). For example, such numbers as 101, 477474 or 9 will be included in the answer and 47, 253 or 1020 will not.Help him and count the number of described numbers x for a given pair l and r.
[{"input": "2 47\r\n", "output": ["12"]}, {"input": "47 1024\r\n", "output": ["98"]}, {"input": "1 1000\r\n", "output": ["108"]}, {"input": "1 10000\r\n", "output": ["1008"]}, {"input": "47 8545\r\n", "output": ["849"]}, {"input": "1000 1000\r\n", "output": ["0"]}, {"input": "47547 4587554587754542\r\n", "output": ["458755458770699"]}, {"input": "1 1000000\r\n", "output": ["100008"]}, {"input": "47 74\r\n", "output": ["2"]}, {"input": "10001 10000002\r\n", "output": ["999001"]}, {"input": "10000 100000\r\n", "output": ["9000"]}, {"input": "458754 4588754\r\n", "output": ["413001"]}, {"input": "111 111\r\n", "output": ["1"]}, {"input": "110 147\r\n", "output": ["4"]}, {"input": "1 1000000000\r\n", "output": ["100000008"]}, {"input": "12 10000000000\r\n", "output": ["999999998"]}, {"input": "1000000000 1000000000\r\n", "output": ["0"]}, {"input": "1 1000000000000000000\r\n", "output": ["100000000000000008"]}, {"input": "11 111111111111111100\r\n", "output": ["11111111111111109"]}, {"input": "100000000000000000 1000000000000000000\r\n", "output": ["90000000000000000"]}, {"input": "45481484484 848469844684844\r\n", "output": ["84842436320036"]}, {"input": "975400104587000 48754000000000001\r\n", "output": ["4777859989541300"]}, {"input": "11220451511 51511665251233335\r\n", "output": ["5151165403078183"]}, {"input": "77 77\r\n", "output": ["1"]}, {"input": "99 102\r\n", "output": ["2"]}, {"input": "9997 87878000008\r\n", "output": ["8787799002"]}, {"input": "10000000001 111111111111100001\r\n", "output": ["11111110111110001"]}, {"input": "7777 88888\r\n", "output": ["8112"]}, {"input": "999999999 10000000000\r\n", "output": ["900000001"]}, {"input": "235 236\r\n", "output": ["0"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "2 2\r\n", "output": ["1"]}, {"input": "1 2\r\n", "output": ["2"]}, {"input": "4 7\r\n", "output": ["4"]}, {"input": "7 10\r\n", "output": ["3"]}, {"input": "1 11\r\n", "output": ["10"]}, {"input": "1 10\r\n", "output": ["9"]}, {"input": "7 8\r\n", "output": ["2"]}, {"input": "88 990\r\n", "output": ["91"]}, {"input": "458985985498001244 985458425544874008\r\n", "output": ["52647244004687276"]}, {"input": "115998725487587451 245744899758754501\r\n", "output": ["12974617427116705"]}, {"input": "595754249475458004 615044544745124547\r\n", "output": ["1929029526966655"]}, {"input": "9754875457700 1000000000000000000\r\n", "output": ["99999024512454230"]}, {"input": "8758754570000 999999999999999999\r\n", "output": ["99999124124543000"]}, {"input": "111111111111111111 333333333444444445\r\n", "output": ["22222222233333334"]}, {"input": "822981258385599125 841978899930248528\r\n", "output": ["1899764154464941"]}, {"input": "779547115376367013 980561039207670775\r\n", "output": ["20101392383130376"]}, {"input": "335408916782916802 416495628489807285\r\n", "output": ["8108671170689049"]}, {"input": "252509053898415172 285803555062529649\r\n", "output": ["3329450116411448"]}, {"input": "919845424847912645 970651082117950285\r\n", "output": ["5080565727003764"]}, {"input": "522842183413115088 853628713003942530\r\n", "output": ["33078652959082744"]}, {"input": "84324827171274023 607953653548585226\r\n", "output": ["52362882637731121"]}, {"input": "1312148742261681 277460340506883334\r\n", "output": ["27614819176462166"]}, {"input": "645762257531682046 885295120956158518\r\n", "output": ["23953286342447648"]}, {"input": "819875140559301752 946247219812473271\r\n", "output": ["12637207925317152"]}, {"input": "4 19\r\n", "output": ["7"]}, {"input": "5 45\r\n", "output": ["9"]}, {"input": "9999999999999987 99999999999999711\r\n", "output": ["8999999999999973"]}, {"input": "2 3\r\n", "output": ["2"]}, {"input": "1827171 232817181719384635\r\n", "output": ["23281718171755747"]}, {"input": "999999999999999999 1000000000000000000\r\n", "output": ["1"]}, {"input": "73 678\r\n", "output": ["61"]}]
100
100
100
[{'input': '45481484484 848469844684844\r\n', 'output': ['84842436320036']}, {'input': '595754249475458004 615044544745124547\r\n', 'output': ['1929029526966655']}, {'input': '458754 4588754\r\n', 'output': ['413001']}, {'input': '47 74\r\n', 'output': ['2']}, {'input': '84324827171274023 607953653548585226\r\n', 'output': ['52362882637731121']}]
[{'input': '2 3\r\n', 'output': ['2']}, {'input': '111 111\r\n', 'output': ['1']}, {'input': '335408916782916802 416495628489807285\r\n', 'output': ['8108671170689049']}, {'input': '11 111111111111111100\r\n', 'output': ['11111111111111109']}, {'input': '1 1000000\r\n', 'output': ['100008']}]
[{'input': '100000000000000000 1000000000000000000\r\n', 'output': ['90000000000000000']}, {'input': '9999999999999987 99999999999999711\r\n', 'output': ['8999999999999973']}, {'input': '7 10\r\n', 'output': ['3']}, {'input': '9754875457700 1000000000000000000\r\n', 'output': ['99999024512454230']}, {'input': '12 10000000000\r\n', 'output': ['999999998']}]
[{'input': '99 102\r\n', 'output': ['2']}, {'input': '7 8\r\n', 'output': ['2']}, {'input': '999999999 10000000000\r\n', 'output': ['900000001']}, {'input': '7 10\r\n', 'output': ['3']}, {'input': '77 77\r\n', 'output': ['1']}]
[{'input': '1312148742261681 277460340506883334\r\n', 'output': ['27614819176462166']}, {'input': '10000 100000\r\n', 'output': ['9000']}, {'input': '8758754570000 999999999999999999\r\n', 'output': ['99999124124543000']}, {'input': '47 74\r\n', 'output': ['2']}, {'input': '10001 10000002\r\n', 'output': ['999001']}]
100
100
100
100
100
100
100
100
100
100
75
100
100
100
75
167
100
100
90
["5 1\n10 5", "4 5\n3 3", "1 2\n11 6"]
The first line contains two positive integers not exceeding 100. They are the number of fingers on the Venusian girl's left and right hand correspondingly. The second line contains two integers not exceeding 100. They are the number of fingers on the Marsian boy's left and right hands correspondingly.
36b7478e162be6e985613b2dad0974dd
#pragma GCC optimize ("O3") #include <bits/stdc++.h> using namespace std; #define ENGZ ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0); #define sfl(x) scanf("%I64d" , &x) #define sfl2(x, y) scanf("%I64d%I64d" , &x,&y) #define sfi(x) scanf("%d" , &x) #define sfi2(x, y) scanf("%d%d" , &x,&y) #define sfd(x) scanf("%lf", &x) #define sfd2(x) scanf("%lf", &x) #define sfc(x) scanf("%c", &x) #define sfd2(x, y) scanf("%lf%lf", &x, &y) #define mod 1000000007 #define pi (2*acos(0)) typedef long long ll; #define endl '\n' int main() { int a, b, x, y; cin >> a >> b >> x >> y; for (int i = 0; i < b - 1; i++) x--; if (x < 0) { for (int i = 0; i < a - 1; i++) y--; if (y < 0) cout << "NO"; else { y -= 2; for (int i = 0; i <= a && y > 0; i++) y--; if (y <= 0) cout << "YES"; else cout << "NO"; } } else { x -= 2; for (int i = 0; i <= b && x > 0; i++) x--; if (x > 0) { for (int i = 0; i < a - 1; i++) y--; if (y < 0) cout << "NO"; else { y -= 2; for (int i = 0; i <= a && y > 0; i++) y--; if (y <= 0) cout << "YES"; else cout << "NO"; } } else cout << "YES"; } return 0; }
["YES", "YES", "NO"]
C++
NoteThe boy and the girl don't really care who goes to the left.
Print YES or NO, that is, the answer to Petr Palych's question.
Statistics claims that students sleep no more than three hours a day. But even in the world of their dreams, while they are snoring peacefully, the sense of impending doom is still upon them.A poor student is dreaming that he is sitting the mathematical analysis exam. And he is examined by the most formidable professor of all times, a three times Soviet Union Hero, a Noble Prize laureate in student expulsion, venerable Petr Palych.The poor student couldn't answer a single question. Thus, instead of a large spacious office he is going to apply for a job to thorium mines. But wait a minute! Petr Palych decided to give the student the last chance! Yes, that is possible only in dreams. So the professor began: "Once a Venusian girl and a Marsian boy met on the Earth and decided to take a walk holding hands. But the problem is the girl has al fingers on her left hand and ar fingers on the right one. The boy correspondingly has bl and br fingers. They can only feel comfortable when holding hands, when no pair of the girl's fingers will touch each other. That is, they are comfortable when between any two girl's fingers there is a boy's finger. And in addition, no three fingers of the boy should touch each other. Determine if they can hold hands so that the both were comfortable."The boy any the girl don't care who goes to the left and who goes to the right. The difference is only that if the boy goes to the left of the girl, he will take her left hand with his right one, and if he goes to the right of the girl, then it is vice versa.
[{"input": "5 1\r\n10 5\r\n", "output": ["YES"]}, {"input": "4 5\r\n3 3\r\n", "output": ["YES"]}, {"input": "1 2\r\n11 6\r\n", "output": ["NO"]}, {"input": "1 1\r\n1 1\r\n", "output": ["YES"]}, {"input": "2 2\r\n1 1\r\n", "output": ["YES"]}, {"input": "3 3\r\n1 1\r\n", "output": ["NO"]}, {"input": "4 4\r\n1 1\r\n", "output": ["NO"]}, {"input": "100 100\r\n50 50\r\n", "output": ["NO"]}, {"input": "100 3\r\n4 1\r\n", "output": ["YES"]}, {"input": "100 5\r\n1 1\r\n", "output": ["NO"]}, {"input": "100 4\r\n1 1\r\n", "output": ["NO"]}, {"input": "100 1\r\n4 1\r\n", "output": ["YES"]}, {"input": "1 100\r\n1 4\r\n", "output": ["YES"]}, {"input": "1 100\r\n5 4\r\n", "output": ["YES"]}, {"input": "1 100\r\n1 5\r\n", "output": ["NO"]}, {"input": "43 100\r\n65 24\r\n", "output": ["NO"]}, {"input": "4 2\r\n12 1\r\n", "output": ["NO"]}, {"input": "6 11\r\n13 11\r\n", "output": ["YES"]}, {"input": "2 6\r\n12 12\r\n", "output": ["YES"]}, {"input": "14 7\r\n2 9\r\n", "output": ["NO"]}, {"input": "1 14\r\n7 14\r\n", "output": ["NO"]}, {"input": "6 11\r\n2 10\r\n", "output": ["YES"]}, {"input": "5 12\r\n13 11\r\n", "output": ["YES"]}, {"input": "15 1\r\n11 9\r\n", "output": ["NO"]}, {"input": "7 12\r\n10 6\r\n", "output": ["YES"]}, {"input": "15 7\r\n15 15\r\n", "output": ["YES"]}, {"input": "1 5\r\n14 1\r\n", "output": ["YES"]}, {"input": "2 4\r\n6 6\r\n", "output": ["YES"]}, {"input": "12 8\r\n4 12\r\n", "output": ["YES"]}, {"input": "6 14\r\n5 5\r\n", "output": ["YES"]}, {"input": "19 17\r\n5 8\r\n", "output": ["NO"]}, {"input": "9 21\r\n13 16\r\n", "output": ["YES"]}, {"input": "11 2\r\n11 22\r\n", "output": ["YES"]}, {"input": "15 3\r\n12 16\r\n", "output": ["YES"]}, {"input": "13 2\r\n13 5\r\n", "output": ["NO"]}, {"input": "21 1\r\n5 19\r\n", "output": ["NO"]}, {"input": "9 15\r\n16 2\r\n", "output": ["YES"]}, {"input": "7 18\r\n23 19\r\n", "output": ["YES"]}, {"input": "13 17\r\n19 1\r\n", "output": ["YES"]}, {"input": "5 15\r\n13 9\r\n", "output": ["YES"]}, {"input": "11 17\r\n6 4\r\n", "output": ["NO"]}, {"input": "18 3\r\n16 15\r\n", "output": ["NO"]}, {"input": "5 23\r\n12 17\r\n", "output": ["NO"]}, {"input": "25 8\r\n14 24\r\n", "output": ["YES"]}, {"input": "18 22\r\n22 19\r\n", "output": ["YES"]}, {"input": "2 25\r\n8 24\r\n", "output": ["NO"]}, {"input": "7 25\r\n18 15\r\n", "output": ["YES"]}, {"input": "8 22\r\n2 3\r\n", "output": ["NO"]}, {"input": "25 9\r\n16 12\r\n", "output": ["YES"]}, {"input": "19 4\r\n25 17\r\n", "output": ["NO"]}, {"input": "24 43\r\n96 39\r\n", "output": ["YES"]}, {"input": "13 23\r\n19 63\r\n", "output": ["NO"]}, {"input": "93 12\r\n87 54\r\n", "output": ["NO"]}, {"input": "94 35\r\n53 79\r\n", "output": ["YES"]}, {"input": "65 8\r\n73 25\r\n", "output": ["NO"]}, {"input": "25 14\r\n19 91\r\n", "output": ["YES"]}, {"input": "58 86\r\n40 46\r\n", "output": ["NO"]}, {"input": "82 60\r\n100 38\r\n", "output": ["YES"]}, {"input": "36 62\r\n81 12\r\n", "output": ["YES"]}, {"input": "30 38\r\n12 100\r\n", "output": ["NO"]}]
100
100
100
[{'input': '5 1\r\n10 5\r\n', 'output': ['YES']}, {'input': '15 7\r\n15 15\r\n', 'output': ['YES']}, {'input': '65 8\r\n73 25\r\n', 'output': ['NO']}, {'input': '13 23\r\n19 63\r\n', 'output': ['NO']}, {'input': '100 3\r\n4 1\r\n', 'output': ['YES']}]
[{'input': '6 11\r\n2 10\r\n', 'output': ['YES']}, {'input': '5 12\r\n13 11\r\n', 'output': ['YES']}, {'input': '4 4\r\n1 1\r\n', 'output': ['NO']}, {'input': '100 4\r\n1 1\r\n', 'output': ['NO']}, {'input': '100 5\r\n1 1\r\n', 'output': ['NO']}]
[{'input': '25 8\r\n14 24\r\n', 'output': ['YES']}, {'input': '25 9\r\n16 12\r\n', 'output': ['YES']}, {'input': '13 23\r\n19 63\r\n', 'output': ['NO']}, {'input': '2 6\r\n12 12\r\n', 'output': ['YES']}, {'input': '15 1\r\n11 9\r\n', 'output': ['NO']}]
[{'input': '19 4\r\n25 17\r\n', 'output': ['NO']}, {'input': '18 22\r\n22 19\r\n', 'output': ['YES']}, {'input': '5 12\r\n13 11\r\n', 'output': ['YES']}, {'input': '15 7\r\n15 15\r\n', 'output': ['YES']}, {'input': '15 3\r\n12 16\r\n', 'output': ['YES']}]
[{'input': '5 23\r\n12 17\r\n', 'output': ['NO']}, {'input': '100 3\r\n4 1\r\n', 'output': ['YES']}, {'input': '43 100\r\n65 24\r\n', 'output': ['NO']}, {'input': '1 100\r\n5 4\r\n', 'output': ['YES']}, {'input': '11 17\r\n6 4\r\n', 'output': ['NO']}]
100
100
100
100
100
86.67
60
73.33
60
63.33
80
50
66.67
53.33
53.33
168
100
68.666
60.666
["1 1 0", "2 2 0", "1 1 1"]
The first line of the input contains three space-separated integers n, m, g (0 ≤ n, m ≤ 105, n + m ≥ 1, 0 ≤ g ≤ 1).
066dd9e6091238edf2912a6af4d29e7f
#include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> #define p 1e6+7 #define N 10010 #define mc(a,b) memset(a,b,sizeof(a)) #define close std::ios::sync_with_stdio using namespace std; using namespace std; const double eps(1e-8); typedef long long lint; const lint mod = 1000000007LL; int n, m, g; lint fac[200010]; void init() { fac[0] = fac[1] = 1; for(int i = 2; i <= 200000; i++) fac[i] = fac[i - 1] * i % mod; return; } lint quick_pow(lint base, lint pow) { lint ret = 1; while(pow) { if(pow & 1) ret = (ret * base) % mod; base = base * base % mod; pow >>= 1; } return ret; } lint C(int r, int k)//C[r][k] { return fac[r]*quick_pow(fac[k]*fac[r - k] % mod, mod - 2LL) % mod; } int main() { scanf("%d %d %d", &n, &m, &g); if(n == 0) { if(g == 0) { if(m == 1) printf("0\n"); else printf("1\n"); } else { if(m == 1) printf("1\n"); else printf("0\n"); } return 0; } if(m == 0) { if(g == 0) { if(n & 1) printf("1\n"); else printf("0\n"); } else { if(n & 1) printf("0\n"); else printf("1\n"); } return 0; } init(); lint all = C(n + m, n); lint ans = 0; for(int t = 0; t <= n; t += 2) ans = (ans + C(n + m - 1 - t, m - 1)) % mod; if(m == 1 && (n & 1) == 0) ans = (ans - 1 + mod) % mod; if(m == 1 && (n & 1)) ans = (ans + 1) % mod; if(g == 0) printf("%I64d\n", ans); else printf("%I64d\n", (all - ans + mod) % mod); return 0; }
["2", "4", "0"]
C++
NoteIn the first sample the beautiful strings are: "01", "10".In the second sample the beautiful strings are: "0011", "1001", "1010", "1100".In the third sample there are no beautiful strings.
Print a single integer — the answer to the problem modulo 1000000007 (109 + 7).
Vasily the Bear loves beautiful strings. String s is beautiful if it meets the following criteria: String s only consists of characters 0 and 1, at that character 0 must occur in string s exactly n times, and character 1 must occur exactly m times. We can obtain character g from string s with some (possibly, zero) number of modifications. The character g equals either zero or one. A modification of string with length at least two is the following operation: we replace two last characters from the string by exactly one other character. This character equals one if it replaces two zeros, otherwise it equals zero. For example, one modification transforms string "01010" into string "0100", two modifications transform it to "011". It is forbidden to modify a string with length less than two.Help the Bear, count the number of beautiful strings. As the number of beautiful strings can be rather large, print the remainder after dividing the number by 1000000007 (109 + 7).
[{"input": "1 1 0\r\n", "output": ["2"]}, {"input": "2 2 0\r\n", "output": ["4"]}, {"input": "1 1 1\r\n", "output": ["0"]}, {"input": "100000 0 1\r\n", "output": ["1"]}, {"input": "0 100000 1\r\n", "output": ["0"]}, {"input": "0 100000 0\r\n", "output": ["1"]}, {"input": "100000 100000 0\r\n", "output": ["339533691"]}, {"input": "100000 1 0\r\n", "output": ["50000"]}, {"input": "50000 1 1\r\n", "output": ["25001"]}, {"input": "100000 100000 1\r\n", "output": ["539933642"]}, {"input": "0 1 0\r\n", "output": ["0"]}, {"input": "0 1 1\r\n", "output": ["1"]}, {"input": "0 2 0\r\n", "output": ["1"]}, {"input": "0 2 1\r\n", "output": ["0"]}, {"input": "0 2500 0\r\n", "output": ["1"]}, {"input": "0 2500 1\r\n", "output": ["0"]}, {"input": "0 9997 0\r\n", "output": ["1"]}, {"input": "0 9997 1\r\n", "output": ["0"]}, {"input": "0 99999 0\r\n", "output": ["1"]}, {"input": "0 99999 1\r\n", "output": ["0"]}, {"input": "1 0 0\r\n", "output": ["1"]}, {"input": "1 0 1\r\n", "output": ["0"]}, {"input": "1 324 0\r\n", "output": ["324"]}, {"input": "1 324 1\r\n", "output": ["1"]}, {"input": "1 2500 0\r\n", "output": ["2500"]}, {"input": "1 2500 1\r\n", "output": ["1"]}, {"input": "1 9997 0\r\n", "output": ["9997"]}, {"input": "1 9997 1\r\n", "output": ["1"]}, {"input": "1 99999 0\r\n", "output": ["99999"]}, {"input": "1 99999 1\r\n", "output": ["1"]}, {"input": "1 100000 0\r\n", "output": ["100000"]}, {"input": "1 100000 1\r\n", "output": ["1"]}, {"input": "2 0 0\r\n", "output": ["0"]}, {"input": "2 0 1\r\n", "output": ["1"]}, {"input": "2 10000 1\r\n", "output": ["10000"]}, {"input": "32 3132 0\r\n", "output": ["256681375"]}, {"input": "32 3132 1\r\n", "output": ["182437326"]}, {"input": "32 3333 0\r\n", "output": ["747440836"]}, {"input": "32 3333 1\r\n", "output": ["54373799"]}, {"input": "33 3232 0\r\n", "output": ["47846603"]}, {"input": "33 3232 1\r\n", "output": ["547985141"]}, {"input": "33 3333 0\r\n", "output": ["37651367"]}, {"input": "33 3333 1\r\n", "output": ["747440836"]}, {"input": "321 312 1\r\n", "output": ["994988379"]}, {"input": "432 432 0\r\n", "output": ["350813304"]}, {"input": "432 432 1\r\n", "output": ["522392126"]}, {"input": "654 1 0\r\n", "output": ["327"]}, {"input": "2500 0 0\r\n", "output": ["0"]}, {"input": "2500 0 1\r\n", "output": ["1"]}, {"input": "2500 1 0\r\n", "output": ["1250"]}, {"input": "2500 1 1\r\n", "output": ["1251"]}, {"input": "2500 2500 0\r\n", "output": ["331895867"]}, {"input": "2500 2500 1\r\n", "output": ["916450637"]}, {"input": "2500 9997 0\r\n", "output": ["943644776"]}, {"input": "2500 9997 1\r\n", "output": ["208015031"]}, {"input": "2500 99999 0\r\n", "output": ["952185647"]}, {"input": "2500 99999 1\r\n", "output": ["103989186"]}, {"input": "2500 100000 0\r\n", "output": ["529882422"]}, {"input": "2500 100000 1\r\n", "output": ["577696782"]}, {"input": "9134 5673 0\r\n", "output": ["24899959"]}, {"input": "9997 0 0\r\n", "output": ["1"]}, {"input": "9997 0 1\r\n", "output": ["0"]}, {"input": "9997 1 0\r\n", "output": ["5000"]}, {"input": "9997 1 1\r\n", "output": ["4998"]}, {"input": "9997 2500 0\r\n", "output": ["221563457"]}, {"input": "9997 2500 1\r\n", "output": ["930096350"]}, {"input": "9997 9997 0\r\n", "output": ["844903460"]}, {"input": "9997 9997 1\r\n", "output": ["513521903"]}, {"input": "9997 99999 0\r\n", "output": ["287015367"]}, {"input": "9997 99999 1\r\n", "output": ["868424216"]}, {"input": "9997 100000 0\r\n", "output": ["699517122"]}, {"input": "9997 100000 1\r\n", "output": ["412501755"]}, {"input": "34560 99560 1\r\n", "output": ["904236161"]}, {"input": "67655 1 1\r\n", "output": ["33827"]}, {"input": "99999 0 0\r\n", "output": ["1"]}, {"input": "99999 0 1\r\n", "output": ["0"]}, {"input": "99999 1 0\r\n", "output": ["50001"]}, {"input": "99999 1 1\r\n", "output": ["49999"]}, {"input": "99999 2500 0\r\n", "output": ["453841822"]}, {"input": "99999 2500 1\r\n", "output": ["602333011"]}, {"input": "99999 9997 0\r\n", "output": ["183955706"]}, {"input": "99999 9997 1\r\n", "output": ["971483877"]}, {"input": "99999 99999 0\r\n", "output": ["140133614"]}, {"input": "99999 99999 1\r\n", "output": ["550956678"]}, {"input": "99999 100000 0\r\n", "output": ["539933642"]}, {"input": "99999 100000 1\r\n", "output": ["399800028"]}, {"input": "100000 0 0\r\n", "output": ["0"]}, {"input": "100000 1 1\r\n", "output": ["50001"]}, {"input": "100000 2500 0\r\n", "output": ["653737382"]}, {"input": "100000 2500 1\r\n", "output": ["453841822"]}, {"input": "100000 9997 0\r\n", "output": ["928063171"]}, {"input": "100000 9997 1\r\n", "output": ["183955706"]}, {"input": "100000 99999 0\r\n", "output": ["799600056"]}, {"input": "100000 99999 1\r\n", "output": ["140133614"]}]
100
100
100
[{'input': '2 0 1\r\n', 'output': ['1']}, {'input': '2500 0 0\r\n', 'output': ['0']}, {'input': '432 432 0\r\n', 'output': ['350813304']}, {'input': '9997 100000 1\r\n', 'output': ['412501755']}, {'input': '0 1 0\r\n', 'output': ['0']}]
[{'input': '100000 100000 1\r\n', 'output': ['539933642']}, {'input': '0 100000 0\r\n', 'output': ['1']}, {'input': '100000 9997 0\r\n', 'output': ['928063171']}, {'input': '100000 1 0\r\n', 'output': ['50000']}, {'input': '9997 99999 0\r\n', 'output': ['287015367']}]
[{'input': '100000 99999 1\r\n', 'output': ['140133614']}, {'input': '9997 9997 0\r\n', 'output': ['844903460']}, {'input': '100000 1 1\r\n', 'output': ['50001']}, {'input': '100000 1 0\r\n', 'output': ['50000']}, {'input': '100000 99999 0\r\n', 'output': ['799600056']}]
[{'input': '0 99999 0\r\n', 'output': ['1']}, {'input': '100000 99999 1\r\n', 'output': ['140133614']}, {'input': '0 2 0\r\n', 'output': ['1']}, {'input': '2 10000 1\r\n', 'output': ['10000']}, {'input': '2500 99999 1\r\n', 'output': ['103989186']}]
[{'input': '0 99999 1\r\n', 'output': ['0']}, {'input': '2 10000 1\r\n', 'output': ['10000']}, {'input': '0 1 1\r\n', 'output': ['1']}, {'input': '9997 1 0\r\n', 'output': ['5000']}, {'input': '99999 1 0\r\n', 'output': ['50001']}]
100
100
100
100
100
83.33
72.92
64.58
68.75
75
64.71
61.76
52.94
47.06
64.71
169
100
72.916
58.236
["7 2 5", "10 3 10"]
The first line contains three integers n, l, r (0 ≤ n &lt; 250, 0 ≤ r - l ≤ 105, r ≥ 1, l ≥ 1) – initial element and the range l to r. It is guaranteed that r is not greater than the length of the final list.
3ac61b1f8deee7911b1055c243f5eb6a
#include <vector>= #include <algorithm> #include <list> #include <map> #include <set> #include <queue> #include <stack> #include <bitset> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <fstream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> #include <cstring> #include <limits> #include <climits> #include <cstdio> #include <numeric> #define ll long long using namespace std; const int inf = 0x3f3f3f3f; const ll mod = 1000000007; const double pi = acos(1.0*(-1)); typedef pair<int, int> P; int num[300010]; ll n, l, r, s = 1, ans; void solve(ll a, ll b, ll l, ll r, ll d)//二分的思想 { if (a > b || l > r) return; else { ll mid = (a + b) / 2; if (r < mid)solve(a, mid - 1, l, r, d / 2); else if (mid < l)solve(mid + 1, b, l, r, d / 2); else { ans += d % 2; solve(a, mid - 1, l, mid - 1, d / 2); solve(mid + 1, b, mid + 1, r, d / 2); } } } int main() { cin >> n >> l >> r; long long p = n; while (p >= 2) { p /= 2; s = s * 2 + 1; } solve(1, s, l, r, n); cout << ans << endl; return 0; }
["4", "5"]
C++
NoteConsider first example:Elements on positions from 2-nd to 5-th in list is [1, 1, 1, 1]. The number of ones is 4.For the second example:Elements on positions from 3-rd to 10-th in list is [1, 1, 1, 0, 1, 0, 1, 0]. The number of ones is 5.
Output the total number of 1s in the range l to r in the final sequence.
Jon fought bravely to rescue the wildlings who were attacked by the white-walkers at Hardhome. On his arrival, Sam tells him that he wants to go to Oldtown to train at the Citadel to become a maester, so he can return and take the deceased Aemon's place as maester of Castle Black. Jon agrees to Sam's proposal and Sam sets off his journey to the Citadel. However becoming a trainee at the Citadel is not a cakewalk and hence the maesters at the Citadel gave Sam a problem to test his eligibility. Initially Sam has a list with a single element n. Then he has to perform certain operations on this list. In each operation Sam must remove any element x, such that x &gt; 1, from the list and insert at the same position , , sequentially. He must continue with these operations until all the elements in the list are either 0 or 1.Now the masters want the total number of 1s in the range l to r (1-indexed). Sam wants to become a maester but unfortunately he cannot solve this problem. Can you help Sam to pass the eligibility test?
[{"input": "7 2 5\r\n", "output": ["4"]}, {"input": "10 3 10\r\n", "output": ["5"]}, {"input": "56 18 40\r\n", "output": ["20"]}, {"input": "203 40 124\r\n", "output": ["67"]}, {"input": "903316762502 354723010040 354723105411\r\n", "output": ["78355"]}, {"input": "33534354842198 32529564319236 32529564342569\r\n", "output": ["22239"]}, {"input": "62518534961045 50734311240112 50734311287877\r\n", "output": ["42439"]}, {"input": "95173251245550 106288351347530 106288351372022\r\n", "output": ["16565"]}, {"input": "542 321 956\r\n", "output": ["336"]}, {"input": "3621 237 2637\r\n", "output": ["2124"]}, {"input": "9056 336 896\r\n", "output": ["311"]}, {"input": "36007 368 24490\r\n", "output": ["13253"]}, {"input": "244269 149154 244246\r\n", "output": ["88609"]}, {"input": "880234 669493 757150\r\n", "output": ["73585"]}, {"input": "3740160 1031384 1104236\r\n", "output": ["64965"]}, {"input": "11586121 15337246 15397874\r\n", "output": ["41868"]}, {"input": "38658997 35923164 35985664\r\n", "output": ["36004"]}, {"input": "192308932 207804787 207866400\r\n", "output": ["44142"]}, {"input": "950099012 175922161 176000556\r\n", "output": ["69369"]}, {"input": "2787326787 3799676481 3799680514\r\n", "output": ["2618"]}, {"input": "14417262581 8527979363 8528075536\r\n", "output": ["80707"]}, {"input": "39889373539 7747197212 7747278363\r\n", "output": ["47105"]}, {"input": "251772781087 70597428577 70597479816\r\n", "output": ["46933"]}, {"input": "0 1 1\r\n", "output": ["0"]}, {"input": "1 1 1\r\n", "output": ["1"]}, {"input": "3 2 3\r\n", "output": ["2"]}, {"input": "14 7 12\r\n", "output": ["5"]}, {"input": "1125899906842623 1 100001\r\n", "output": ["100001"]}, {"input": "1125899906842623 1125899906742623 1125899906842623\r\n", "output": ["100001"]}, {"input": "1000 1 1023\r\n", "output": ["1000"]}, {"input": "281474976710656 17179869184 17179869186\r\n", "output": ["1"]}, {"input": "2 2 2\r\n", "output": ["0"]}, {"input": "3 2 2\r\n", "output": ["1"]}]
100
100
100
[{'input': '7 2 5\r\n', 'output': ['4']}, {'input': '3621 237 2637\r\n', 'output': ['2124']}, {'input': '14 7 12\r\n', 'output': ['5']}, {'input': '281474976710656 17179869184 17179869186\r\n', 'output': ['1']}, {'input': '3 2 2\r\n', 'output': ['1']}]
[{'input': '56 18 40\r\n', 'output': ['20']}, {'input': '1125899906842623 1125899906742623 1125899906842623\r\n', 'output': ['100001']}, {'input': '192308932 207804787 207866400\r\n', 'output': ['44142']}, {'input': '903316762502 354723010040 354723105411\r\n', 'output': ['78355']}, {'input': '3740160 1031384 1104236\r\n', 'output': ['64965']}]
[{'input': '3740160 1031384 1104236\r\n', 'output': ['64965']}, {'input': '281474976710656 17179869184 17179869186\r\n', 'output': ['1']}, {'input': '62518534961045 50734311240112 50734311287877\r\n', 'output': ['42439']}, {'input': '38658997 35923164 35985664\r\n', 'output': ['36004']}, {'input': '880234 669493 757150\r\n', 'output': ['73585']}]
[{'input': '1000 1 1023\r\n', 'output': ['1000']}, {'input': '542 321 956\r\n', 'output': ['336']}, {'input': '2787326787 3799676481 3799680514\r\n', 'output': ['2618']}, {'input': '14417262581 8527979363 8528075536\r\n', 'output': ['80707']}, {'input': '1 1 1\r\n', 'output': ['1']}]
[{'input': '542 321 956\r\n', 'output': ['336']}, {'input': '244269 149154 244246\r\n', 'output': ['88609']}, {'input': '251772781087 70597428577 70597479816\r\n', 'output': ['46933']}, {'input': '11586121 15337246 15397874\r\n', 'output': ['41868']}, {'input': '880234 669493 757150\r\n', 'output': ['73585']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
170
100
100
100
["6\nbaabbb", "10\nooopppssss", "1\nz"]
The first line contains integer $$$n$$$ ($$$1 \le n \le 55$$$) — the length of the encrypted string. The second line of the input contains $$$t$$$ — the result of encryption of some string $$$s$$$. It contains only lowercase Latin letters. The length of $$$t$$$ is exactly $$$n$$$. It is guaranteed that the answer to the test exists.
08e8c0c37b223f6aae01d5609facdeaf
#include<bits/stdc++.h> using namespace std; int i,l,n; char s[60]; int main() { cin>>l>>s; for(;i<l;i+=n+1,n++)cout<<s[i]; return 0; }
["bab", "oops", "z"]
C++
null
Print such string $$$s$$$ that after encryption it equals $$$t$$$.
Polycarp loves ciphers. He has invented his own cipher called repeating.Repeating cipher is used for strings. To encrypt the string $$$s=s_{1}s_{2} \dots s_{m}$$$ ($$$1 \le m \le 10$$$), Polycarp uses the following algorithm: he writes down $$$s_1$$$ ones, he writes down $$$s_2$$$ twice, he writes down $$$s_3$$$ three times, ... he writes down $$$s_m$$$ $$$m$$$ times. For example, if $$$s$$$="bab" the process is: "b" $$$\to$$$ "baa" $$$\to$$$ "baabbb". So the encrypted $$$s$$$="bab" is "baabbb".Given string $$$t$$$ — the result of encryption of some string $$$s$$$. Your task is to decrypt it, i. e. find the string $$$s$$$.
[{"input": "6\r\nbaabbb\r\n", "output": ["bab\n", "bab", "bab\r\n"]}, {"input": "10\r\nooopppssss\r\n", "output": ["oops\r\n", "oops\n", "oops"]}, {"input": "1\r\nz\r\n", "output": ["z\n", "z", "z\r\n"]}, {"input": "3\r\nzww\r\n", "output": ["zw", "zw\n", "zw\r\n"]}, {"input": "55\r\ncooooonnnnttttteeeeeeeeeeeeessssssssttttttttttttttttttt\r\n", "output": ["coonteestt\r\n", "coonteestt", "coonteestt\n"]}, {"input": "21\r\ncoodddeeeecccccoooooo\r\n", "output": ["codeco", "codeco\r\n", "codeco\n"]}, {"input": "55\r\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n", "output": ["aaaaaaaaaa\r\n", "aaaaaaaaaa\n", "aaaaaaaaaa"]}, {"input": "36\r\nabbcccddddeeeeeffffffggggggghhhhhhhh\r\n", "output": ["abcdefgh\n", "abcdefgh\r\n", "abcdefgh"]}]
100
100
100
[{'input': '21\r\ncoodddeeeecccccoooooo\r\n', 'output': ['codeco', 'codeco\r\n', 'codeco\n']}, {'input': '36\r\nabbcccddddeeeeeffffffggggggghhhhhhhh\r\n', 'output': ['abcdefgh\n', 'abcdefgh\r\n', 'abcdefgh']}, {'input': '1\r\nz\r\n', 'output': ['z\n', 'z', 'z\r\n']}, {'input': '3\r\nzww\r\n', 'output': ['zw', 'zw\n', 'zw\r\n']}, {'input': '55\r\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n', 'output': ['aaaaaaaaaa\r\n', 'aaaaaaaaaa\n', 'aaaaaaaaaa']}]
[{'input': '3\r\nzww\r\n', 'output': ['zw', 'zw\n', 'zw\r\n']}, {'input': '1\r\nz\r\n', 'output': ['z\n', 'z', 'z\r\n']}, {'input': '10\r\nooopppssss\r\n', 'output': ['oops\r\n', 'oops\n', 'oops']}, {'input': '21\r\ncoodddeeeecccccoooooo\r\n', 'output': ['codeco', 'codeco\r\n', 'codeco\n']}, {'input': '6\r\nbaabbb\r\n', 'output': ['bab\n', 'bab', 'bab\r\n']}]
[{'input': '55\r\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n', 'output': ['aaaaaaaaaa\r\n', 'aaaaaaaaaa\n', 'aaaaaaaaaa']}, {'input': '36\r\nabbcccddddeeeeeffffffggggggghhhhhhhh\r\n', 'output': ['abcdefgh\n', 'abcdefgh\r\n', 'abcdefgh']}, {'input': '55\r\ncooooonnnnttttteeeeeeeeeeeeessssssssttttttttttttttttttt\r\n', 'output': ['coonteestt\r\n', 'coonteestt', 'coonteestt\n']}, {'input': '3\r\nzww\r\n', 'output': ['zw', 'zw\n', 'zw\r\n']}, {'input': '21\r\ncoodddeeeecccccoooooo\r\n', 'output': ['codeco', 'codeco\r\n', 'codeco\n']}]
[{'input': '3\r\nzww\r\n', 'output': ['zw', 'zw\n', 'zw\r\n']}, {'input': '21\r\ncoodddeeeecccccoooooo\r\n', 'output': ['codeco', 'codeco\r\n', 'codeco\n']}, {'input': '1\r\nz\r\n', 'output': ['z\n', 'z', 'z\r\n']}, {'input': '10\r\nooopppssss\r\n', 'output': ['oops\r\n', 'oops\n', 'oops']}, {'input': '6\r\nbaabbb\r\n', 'output': ['bab\n', 'bab', 'bab\r\n']}]
[{'input': '36\r\nabbcccddddeeeeeffffffggggggghhhhhhhh\r\n', 'output': ['abcdefgh\n', 'abcdefgh\r\n', 'abcdefgh']}, {'input': '1\r\nz\r\n', 'output': ['z\n', 'z', 'z\r\n']}, {'input': '55\r\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n', 'output': ['aaaaaaaaaa\r\n', 'aaaaaaaaaa\n', 'aaaaaaaaaa']}, {'input': '10\r\nooopppssss\r\n', 'output': ['oops\r\n', 'oops\n', 'oops']}, {'input': '21\r\ncoodddeeeecccccoooooo\r\n', 'output': ['codeco', 'codeco\r\n', 'codeco\n']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
171
100
100
100
["4 3"]
The first and single line contains two integers A and B (1 ≤ A, B ≤ 109, min(A, B) ≤ 12).
7bf30ceb24b66d91382e97767f9feeb6
#include <iostream> #include <algorithm> using namespace std; #define int long long int a , b , cnt = 1; void cul ( ) { if ( a > b ) swap ( a , b ); while ( a != 1 ) { cnt *= a; a--; } } signed main ( void ) { cin >> a >> b; cul ( ); cout << cnt << endl; return 0; }
["6"]
C++
NoteConsider the sample.4! = 1·2·3·4 = 24. 3! = 1·2·3 = 6. The greatest common divisor of integers 24 and 6 is exactly 6.
Print a single integer denoting the greatest common divisor of integers A! and B!.
Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provide students with dormitory for the period of university studies. Consequently Noora had to leave Vičkopolis and move to Pavlopolis. Thus Leha was left completely alone in a quiet town Vičkopolis. He almost even fell into a depression from boredom!Leha came up with a task for himself to relax a little. He chooses two integers A and B and then calculates the greatest common divisor of integers "A factorial" and "B factorial". Formally the hacker wants to find out GCD(A!, B!). It's well known that the factorial of an integer x is a product of all positive integers less than or equal to x. Thus x! = 1·2·3·...·(x - 1)·x. For example 4! = 1·2·3·4 = 24. Recall that GCD(x, y) is the largest positive integer q that divides (without a remainder) both x and y.Leha has learned how to solve this task very effective. You are able to cope with it not worse, aren't you?
[{"input": "4 3\r\n", "output": ["6"]}, {"input": "10 399603090\r\n", "output": ["3628800"]}, {"input": "6 973151934\r\n", "output": ["720"]}, {"input": "2 841668075\r\n", "output": ["2"]}, {"input": "7 415216919\r\n", "output": ["5040"]}, {"input": "3 283733059\r\n", "output": ["6"]}, {"input": "11 562314608\r\n", "output": ["39916800"]}, {"input": "3 990639260\r\n", "output": ["6"]}, {"input": "11 859155400\r\n", "output": ["39916800"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "5 3\r\n", "output": ["6"]}, {"input": "1 4\r\n", "output": ["1"]}, {"input": "5 4\r\n", "output": ["24"]}, {"input": "1 12\r\n", "output": ["1"]}, {"input": "9 7\r\n", "output": ["5040"]}, {"input": "2 3\r\n", "output": ["2"]}, {"input": "6 11\r\n", "output": ["720"]}, {"input": "6 7\r\n", "output": ["720"]}, {"input": "11 11\r\n", "output": ["39916800"]}, {"input": "4 999832660\r\n", "output": ["24"]}, {"input": "7 999228288\r\n", "output": ["5040"]}, {"input": "11 999257105\r\n", "output": ["39916800"]}, {"input": "11 999286606\r\n", "output": ["39916800"]}, {"input": "3 999279109\r\n", "output": ["6"]}, {"input": "999632727 11\r\n", "output": ["39916800"]}, {"input": "999625230 7\r\n", "output": ["5040"]}, {"input": "999617047 3\r\n", "output": ["6"]}, {"input": "999646548 7\r\n", "output": ["5040"]}, {"input": "999639051 3\r\n", "output": ["6"]}, {"input": "12 12\r\n", "output": ["479001600"]}, {"input": "12 1\r\n", "output": ["1"]}, {"input": "1213 5\r\n", "output": ["120"]}, {"input": "8 9\r\n", "output": ["40320"]}, {"input": "12 9\r\n", "output": ["362880"]}, {"input": "12 1000000000\r\n", "output": ["479001600"]}, {"input": "1000000000 1\r\n", "output": ["1"]}, {"input": "12 13\r\n", "output": ["479001600"]}, {"input": "2 29845\r\n", "output": ["2"]}, {"input": "10 21\r\n", "output": ["3628800"]}, {"input": "12 20\r\n", "output": ["479001600"]}, {"input": "15 12\r\n", "output": ["479001600"]}, {"input": "1000000000 12\r\n", "output": ["479001600"]}, {"input": "11 30\r\n", "output": ["39916800"]}, {"input": "17 12\r\n", "output": ["479001600"]}, {"input": "4 19\r\n", "output": ["24"]}, {"input": "12 15\r\n", "output": ["479001600"]}, {"input": "20 6\r\n", "output": ["720"]}, {"input": "10 20\r\n", "output": ["3628800"]}, {"input": "10 10\r\n", "output": ["3628800"]}, {"input": "22 12\r\n", "output": ["479001600"]}, {"input": "20 12\r\n", "output": ["479001600"]}, {"input": "12 23\r\n", "output": ["479001600"]}, {"input": "12 22\r\n", "output": ["479001600"]}, {"input": "18 3\r\n", "output": ["6"]}, {"input": "14 10\r\n", "output": ["3628800"]}, {"input": "14 12\r\n", "output": ["479001600"]}, {"input": "8 3\r\n", "output": ["6"]}, {"input": "5 5\r\n", "output": ["120"]}]
100
100
100
[{'input': '10 20\r\n', 'output': ['3628800']}, {'input': '1 12\r\n', 'output': ['1']}, {'input': '2 29845\r\n', 'output': ['2']}, {'input': '11 999257105\r\n', 'output': ['39916800']}, {'input': '7 415216919\r\n', 'output': ['5040']}]
[{'input': '12 15\r\n', 'output': ['479001600']}, {'input': '12 20\r\n', 'output': ['479001600']}, {'input': '1213 5\r\n', 'output': ['120']}, {'input': '4 999832660\r\n', 'output': ['24']}, {'input': '6 7\r\n', 'output': ['720']}]
[{'input': '11 859155400\r\n', 'output': ['39916800']}, {'input': '12 20\r\n', 'output': ['479001600']}, {'input': '12 1\r\n', 'output': ['1']}, {'input': '10 20\r\n', 'output': ['3628800']}, {'input': '3 990639260\r\n', 'output': ['6']}]
[{'input': '4 19\r\n', 'output': ['24']}, {'input': '11 562314608\r\n', 'output': ['39916800']}, {'input': '5 5\r\n', 'output': ['120']}, {'input': '3 283733059\r\n', 'output': ['6']}, {'input': '999617047 3\r\n', 'output': ['6']}]
[{'input': '18 3\r\n', 'output': ['6']}, {'input': '7 999228288\r\n', 'output': ['5040']}, {'input': '5 5\r\n', 'output': ['120']}, {'input': '4 19\r\n', 'output': ['24']}, {'input': '2 841668075\r\n', 'output': ['2']}]
100
100
100
100
100
100
100
100
100
100
75
100
100
100
100
172
100
100
95
["2 2 2\n1 1 1\n1 2 3 4 5 6", "0 0 10\n3 2 3\n1 2 3 4 5 6"]
The fist input line contains three space-separated integers x, y and z (|x|, |y|, |z| ≤ 106) — the coordinates of Vasya's position in space. The second line contains three space-separated integers x1, y1, z1 (1 ≤ x1, y1, z1 ≤ 106) — the coordinates of the box's vertex that is opposite to the vertex at point (0, 0, 0). The third line contains six space-separated integers a1, a2, ..., a6 (1 ≤ ai ≤ 106) — the numbers that are written on the box faces. It is guaranteed that point (x, y, z) is located strictly outside the box.
c7889a8f64c57cf7be4df870f68f749e
#include<bits/stdc++.h> #include<cmath> #define ll long long #define fr first #define sc second #define mod 1000000007 #define pii pair<int,int> #define pdd pair<double,double> #define mp make_pair using namespace std; struct pt{ double x,y,z; void read(){ cin>>x>>y>>z; } double dis(pt d){ return (x - d.x)*(x - d.x) + (y - d.y)*(y - d.y) + (z - d.z)*(z - d.z); } }; int a[6]; pt eyee; pt s; pt c[6]; int main(){ eyee.read(); s.read(); for(int i=0 ; i<6 ; i++)cin>>a[i]; int res =0 ; if(eyee.y < 0)res += a[0]; if(eyee.y > s.y)res += a[1]; if(eyee.z < 0)res += a[2]; if(eyee.z > s.z)res += a[3]; if(eyee.x < 0)res += a[4]; if(eyee.x > s.x)res += a[5]; cout<<res; return 0; }
["12", "4"]
C++
NoteThe first sample corresponds to perspective, depicted on the picture. Vasya sees numbers a2 (on the top face that is the darkest), a6 (on the right face that is the lightest) and a4 (on the left visible face).In the second sample Vasya can only see number a4.
Print a single integer — the sum of all numbers on the box faces that Vasya sees.
One day Vasya was going home when he saw a box lying on the road. The box can be represented as a rectangular parallelepiped. Vasya needed no time to realize that the box is special, as all its edges are parallel to the coordinate axes, one of its vertices is at point (0, 0, 0), and the opposite one is at point (x1, y1, z1). The six faces of the box contain some numbers a1, a2, ..., a6, exactly one number right in the center of each face. The numbers are located on the box like that: number a1 is written on the face that lies on the ZOX plane; a2 is written on the face, parallel to the plane from the previous point; a3 is written on the face that lies on the XOY plane; a4 is written on the face, parallel to the plane from the previous point; a5 is written on the face that lies on the YOZ plane; a6 is written on the face, parallel to the plane from the previous point. At the moment Vasya is looking at the box from point (x, y, z). Find the sum of numbers that Vasya sees. Note that all faces of the box are not transparent and Vasya can't see the numbers through the box. The picture contains transparent faces just to make it easier to perceive. You can consider that if Vasya is looking from point, lying on the plane of some face, than he can not see the number that is written on this face. It is enough to see the center of a face to see the corresponding number for Vasya. Also note that Vasya always reads correctly the ai numbers that he sees, independently of their rotation, angle and other factors (that is, for example, if Vasya sees some ai = 6, then he can't mistake this number for 9 and so on).
[{"input": "2 2 2\r\n1 1 1\r\n1 2 3 4 5 6\r\n", "output": ["12"]}, {"input": "0 0 10\r\n3 2 3\r\n1 2 3 4 5 6\r\n", "output": ["4"]}, {"input": "0 1 2\r\n1 1 1\r\n634728 627299 454463 927148 298618 186257\r\n", "output": ["927148"]}, {"input": "5 2 -4\r\n1 1 1\r\n279519 704273 181008 670653 198973 996401\r\n", "output": ["1881682"]}, {"input": "5 5 0\r\n3 1 3\r\n832224 636838 995053 211585 505442 341920\r\n", "output": ["978758"]}, {"input": "-1 -9 14\r\n9 8 10\r\n172575 215800 344296 98651 566390 47011\r\n", "output": ["837616"]}, {"input": "95892 79497 69936\r\n7 4 6\r\n873850 132840 469930 271591 257864 626722\r\n", "output": ["1031153"]}, {"input": "-263980 -876063 613611\r\n2 3 14\r\n63640 300066 460766 222639 51956 412622\r\n", "output": ["338235"]}, {"input": "30 68 72\r\n51 54 95\r\n480054 561470 308678 472768 90393 992511\r\n", "output": ["561470"]}, {"input": "19 60 75\r\n11 64 92\r\n768641 208726 47379 514231 858941 959876\r\n", "output": ["959876"]}, {"input": "37 96 41\r\n27 74 97\r\n747624 148752 730329 406930 814825 993124\r\n", "output": ["1141876"]}, {"input": "573 79 619\r\n36 69 96\r\n955743 245262 675667 699027 275227 783730\r\n", "output": ["1728019"]}, {"input": "34271 -17508 -6147\r\n456 567 112\r\n804178 307516 306399 18981 989216 228388\r\n", "output": ["1338965"]}, {"input": "-33064 176437 217190\r\n181 507 575\r\n161371 827160 733690 99808 584032 954632\r\n", "output": ["1511000"]}, {"input": "967 -1346 2551\r\n769 331 28\r\n458319 885170 877010 533360 723416 248230\r\n", "output": ["1239909"]}, {"input": "46643 53735 -19637\r\n3268 9109 5377\r\n679826 208720 919306 797520 856404 373419\r\n", "output": ["1501445"]}, {"input": "7412 -524 9621\r\n8748 8870 1521\r\n1043 894084 881852 56954 415764 946495\r\n", "output": ["57997"]}, {"input": "409501 -349039 -285847\r\n4386 1034 7566\r\n166804 981888 780353 956617 563457 238748\r\n", "output": ["1185905"]}, {"input": "7669 1619 6208\r\n2230 2327 8551\r\n28791 762474 463311 687868 175185 383245\r\n", "output": ["383245"]}, {"input": "2581 12373 -1381\r\n2048 8481 7397\r\n118694 862180 426553 229109 698247 387794\r\n", "output": ["1676527"]}, {"input": "35273 82177 67365\r\n69755 14857 39718\r\n925457 138136 454985 609590 83655 611361\r\n", "output": ["747726"]}, {"input": "58224 94433 40185\r\n55683 99614 33295\r\n137430 61976 671256 929825 499631 90071\r\n", "output": ["1019896"]}, {"input": "-267768 -542892 844309\r\n53169 60121 20730\r\n760938 814929 213048 452483 867280 110687\r\n", "output": ["2080701"]}, {"input": "441810 183747 823363\r\n945702 484093 693802\r\n149570 186362 344439 753794 467269 643649\r\n", "output": ["753794"]}, {"input": "298742 556311 628232\r\n360973 607625 301540\r\n278905 531131 923271 701344 873950 969819\r\n", "output": ["701344"]}, {"input": "366317 904079 468911\r\n819427 99580 451147\r\n291702 801137 380674 646951 890909 998554\r\n", "output": ["1448088"]}, {"input": "722477 814197 501318\r\n670293 164127 180084\r\n665889 389403 663253 449990 909406 240043\r\n", "output": ["1079436"]}, {"input": "701521 392984 524392\r\n462491 968267 126043\r\n328074 993331 895443 352976 984911 318865\r\n", "output": ["671841"]}, {"input": "-827584 -680412 -103147\r\n897186 313672 388429\r\n892050 717946 505625 200144 311983 606037\r\n", "output": ["1709658"]}, {"input": "381718 587052 14730\r\n290055 960762 231879\r\n646112 249417 451908 49140 819134 575870\r\n", "output": ["575870"]}, {"input": "4 4 4\r\n6 3 3\r\n1 2 3 4 5 6\r\n", "output": ["6"]}, {"input": "8 4 4\r\n10 3 3\r\n1 2 3 4 5 6\r\n", "output": ["6"]}, {"input": "3 10 3\r\n6 6 6\r\n2 4 8 16 32 64\r\n", "output": ["4"]}, {"input": "1 3 1\r\n2 2 2\r\n1 2 4 8 16 32\r\n", "output": ["2"]}, {"input": "1 1 3\r\n2 2 2\r\n1 2 3 4 5 6\r\n", "output": ["4"]}]
100
100
100
[{'input': '-1 -9 14\r\n9 8 10\r\n172575 215800 344296 98651 566390 47011\r\n', 'output': ['837616']}, {'input': '573 79 619\r\n36 69 96\r\n955743 245262 675667 699027 275227 783730\r\n', 'output': ['1728019']}, {'input': '37 96 41\r\n27 74 97\r\n747624 148752 730329 406930 814825 993124\r\n', 'output': ['1141876']}, {'input': '2 2 2\r\n1 1 1\r\n1 2 3 4 5 6\r\n', 'output': ['12']}, {'input': '4 4 4\r\n6 3 3\r\n1 2 3 4 5 6\r\n', 'output': ['6']}]
[{'input': '5 5 0\r\n3 1 3\r\n832224 636838 995053 211585 505442 341920\r\n', 'output': ['978758']}, {'input': '58224 94433 40185\r\n55683 99614 33295\r\n137430 61976 671256 929825 499631 90071\r\n', 'output': ['1019896']}, {'input': '722477 814197 501318\r\n670293 164127 180084\r\n665889 389403 663253 449990 909406 240043\r\n', 'output': ['1079436']}, {'input': '-267768 -542892 844309\r\n53169 60121 20730\r\n760938 814929 213048 452483 867280 110687\r\n', 'output': ['2080701']}, {'input': '95892 79497 69936\r\n7 4 6\r\n873850 132840 469930 271591 257864 626722\r\n', 'output': ['1031153']}]
[{'input': '5 5 0\r\n3 1 3\r\n832224 636838 995053 211585 505442 341920\r\n', 'output': ['978758']}, {'input': '967 -1346 2551\r\n769 331 28\r\n458319 885170 877010 533360 723416 248230\r\n', 'output': ['1239909']}, {'input': '722477 814197 501318\r\n670293 164127 180084\r\n665889 389403 663253 449990 909406 240043\r\n', 'output': ['1079436']}, {'input': '19 60 75\r\n11 64 92\r\n768641 208726 47379 514231 858941 959876\r\n', 'output': ['959876']}, {'input': '298742 556311 628232\r\n360973 607625 301540\r\n278905 531131 923271 701344 873950 969819\r\n', 'output': ['701344']}]
[{'input': '35273 82177 67365\r\n69755 14857 39718\r\n925457 138136 454985 609590 83655 611361\r\n', 'output': ['747726']}, {'input': '0 0 10\r\n3 2 3\r\n1 2 3 4 5 6\r\n', 'output': ['4']}, {'input': '366317 904079 468911\r\n819427 99580 451147\r\n291702 801137 380674 646951 890909 998554\r\n', 'output': ['1448088']}, {'input': '19 60 75\r\n11 64 92\r\n768641 208726 47379 514231 858941 959876\r\n', 'output': ['959876']}, {'input': '701521 392984 524392\r\n462491 968267 126043\r\n328074 993331 895443 352976 984911 318865\r\n', 'output': ['671841']}]
[{'input': '722477 814197 501318\r\n670293 164127 180084\r\n665889 389403 663253 449990 909406 240043\r\n', 'output': ['1079436']}, {'input': '34271 -17508 -6147\r\n456 567 112\r\n804178 307516 306399 18981 989216 228388\r\n', 'output': ['1338965']}, {'input': '573 79 619\r\n36 69 96\r\n955743 245262 675667 699027 275227 783730\r\n', 'output': ['1728019']}, {'input': '967 -1346 2551\r\n769 331 28\r\n458319 885170 877010 533360 723416 248230\r\n', 'output': ['1239909']}, {'input': '-1 -9 14\r\n9 8 10\r\n172575 215800 344296 98651 566390 47011\r\n', 'output': ['837616']}]
100
100
100
100
100
100
100
100
100
100
92.86
92.86
85.71
78.57
100
173
100
100
90
["xx..\n.oo.\nx...\noox.", "x.ox\nox..\nx.o.\noo.x", "x..x\n..oo\no...\nx.xo", "o.x.\no...\n.x..\nooxx"]
The tic-tac-toe position is given in four lines. Each of these lines contains four characters. Each character is '.' (empty cell), 'x' (lowercase English letter x), or 'o' (lowercase English letter o). It is guaranteed that the position is reachable playing tic-tac-toe, and it is Ilya's turn now (in particular, it means that the game is not finished). It is possible that all the cells are empty, it means that the friends left without making single turn.
ca4a77fe9718b8bd0b3cc3d956e22917
#include<bits/stdc++.h> using namespace std; char c[10][10]; int main() { for(int i=0; i<4; i++) for(int j=0; j<4; j++) cin>>c[i][j]; bool flag=0; for(int i=0; i<4; i++) { for(int j=0; j<4; j++) if(c[i][j]=='.') { if(i>0 && i<3 && c[i-1][j]=='x' && c[i+1][j]=='x') flag=1; else if(j>0 && j<3 && c[i][j-1]=='x' && c[i][j+1]=='x') flag=1; else if(j>0 && i>0 && j<3 && i<3 && c[i-1][j-1]=='x' && c[i+1][j+1]=='x') flag=1; else if(j>0 && i>0 && j<3 && i<3 && c[i-1][j+1]=='x' && c[i+1][j-1]=='x') flag=1; else if(i>1 && c[i-1][j]=='x' && c[i-2][j]=='x') flag=1; else if(j>1 && c[i][j-1]=='x' && c[i][j-2]=='x') flag=1; else if(i<2 && c[i+1][j]=='x' && c[i+2][j]=='x') flag=1; else if(j<2 && c[i][j+1]=='x' && c[i][j+2]=='x') flag=1; else if(i>1 && j>1 && c[i-1][j-1]=='x' && c[i-2][j-2]=='x') flag=1; else if(i<2 && j<2 && c[i+1][j+1]=='x' && c[i+2][j+2]=='x') flag=1; else if(i>1 && j<2 && c[i-1][j+1]=='x' && c[i-2][j+2]=='x') flag=1; else if(i<2 && j>1 && c[i+1][j-1]=='x' && c[i+2][j-2]=='x') flag=1; if(flag) break; } if(flag) break; } if(flag) printf("YES"); else printf("NO"); return 0; }
["YES", "NO", "YES", "NO"]
C++
NoteIn the first example Ilya had two winning moves: to the empty cell in the left column and to the leftmost empty cell in the first row.In the second example it wasn't possible to win by making single turn.In the third example Ilya could have won by placing X in the last row between two existing Xs.In the fourth example it wasn't possible to win by making single turn.
Print single line: "YES" in case Ilya could have won by making single turn, and "NO" otherwise.
Ilya is an experienced player in tic-tac-toe on the 4 × 4 field. He always starts and plays with Xs. He played a lot of games today with his friend Arseny. The friends became tired and didn't finish the last game. It was Ilya's turn in the game when they left it. Determine whether Ilya could have won the game by making single turn or not. The rules of tic-tac-toe on the 4 × 4 field are as follows. Before the first turn all the field cells are empty. The two players take turns placing their signs into empty cells (the first player places Xs, the second player places Os). The player who places Xs goes first, the another one goes second. The winner is the player who first gets three of his signs in a row next to each other (horizontal, vertical or diagonal).
[{"input": "xx..\r\n.oo.\r\nx...\r\noox.\r\n", "output": ["YES"]}, {"input": "x.ox\r\nox..\r\nx.o.\r\noo.x\r\n", "output": ["NO"]}, {"input": "x..x\r\n..oo\r\no...\r\nx.xo\r\n", "output": ["YES"]}, {"input": "o.x.\r\no...\r\n.x..\r\nooxx\r\n", "output": ["NO"]}, {"input": ".xox\r\no.x.\r\nx.o.\r\n..o.\r\n", "output": ["YES"]}, {"input": "o.oo\r\n.x.o\r\nx.x.\r\n.x..\r\n", "output": ["YES"]}, {"input": ".xx.\r\n.xoo\r\n.oox\r\n....\r\n", "output": ["YES"]}, {"input": "xxox\r\no.x.\r\nx.oo\r\nxo.o\r\n", "output": ["YES"]}, {"input": ".xox\r\n.x..\r\nxoo.\r\noox.\r\n", "output": ["NO"]}, {"input": ".oxx\r\nx...\r\n.o..\r\no...\r\n", "output": ["NO"]}, {"input": "...x\r\n.x.o\r\n.o..\r\n.x.o\r\n", "output": ["NO"]}, {"input": "oo.x\r\nxo.o\r\no.xx\r\n.oxx\r\n", "output": ["YES"]}, {"input": ".x.o\r\n..o.\r\n..ox\r\nxox.\r\n", "output": ["NO"]}, {"input": "....\r\n.x..\r\nx...\r\n..oo\r\n", "output": ["YES"]}, {"input": "....\r\n....\r\n.x.o\r\n..xo\r\n", "output": ["YES"]}, {"input": "xo.x\r\n...o\r\n.oox\r\nx...\r\n", "output": ["NO"]}, {"input": "o..o\r\nx..x\r\n.o.x\r\nxo..\r\n", "output": ["YES"]}, {"input": "ox.o\r\nx..x\r\nx..o\r\noo.x\r\n", "output": ["NO"]}, {"input": ".xox\r\n.x.o\r\nooxo\r\n..x.\r\n", "output": ["YES"]}, {"input": "x..o\r\no..o\r\n..x.\r\nx.xo\r\n", "output": ["YES"]}, {"input": "xxoo\r\no.oo\r\n...x\r\nx..x\r\n", "output": ["NO"]}, {"input": "xoox\r\n.xx.\r\no..o\r\n..xo\r\n", "output": ["YES"]}, {"input": "..o.\r\nxxox\r\n....\r\n.oxo\r\n", "output": ["YES"]}, {"input": "xoox\r\nxxox\r\noo..\r\n.ox.\r\n", "output": ["YES"]}, {"input": "..ox\r\n.o..\r\nx..o\r\n.oxx\r\n", "output": ["NO"]}, {"input": ".oo.\r\n.x..\r\nx...\r\nox..\r\n", "output": ["YES"]}, {"input": "o.xx\r\nxo.o\r\n...o\r\n..x.\r\n", "output": ["YES"]}, {"input": "x...\r\n.ox.\r\n.oo.\r\n.xox\r\n", "output": ["NO"]}, {"input": "xoxx\r\n..x.\r\no.oo\r\nx.o.\r\n", "output": ["YES"]}, {"input": ".x.x\r\n.o.o\r\no.xx\r\nx.oo\r\n", "output": ["YES"]}, {"input": "...o\r\nxo.x\r\n.x..\r\nxoo.\r\n", "output": ["YES"]}, {"input": "o...\r\n...o\r\noxx.\r\n.xxo\r\n", "output": ["YES"]}, {"input": "xxox\r\no..o\r\nx..o\r\noxox\r\n", "output": ["NO"]}, {"input": "x...\r\no.ox\r\nxo..\r\n....\r\n", "output": ["NO"]}, {"input": "x.x.\r\nox.o\r\n.o.o\r\nxox.\r\n", "output": ["YES"]}, {"input": ".oxx\r\n..xo\r\n.oox\r\n....\r\n", "output": ["NO"]}, {"input": "xxo.\r\n...x\r\nooxx\r\n.o.o\r\n", "output": ["YES"]}, {"input": "xoxo\r\no..x\r\n.xo.\r\nox..\r\n", "output": ["YES"]}, {"input": ".o..\r\nox..\r\n.o.x\r\n.x..\r\n", "output": ["NO"]}, {"input": ".oxo\r\nx...\r\n.o..\r\n.xox\r\n", "output": ["NO"]}, {"input": ".oxx\r\n..o.\r\n.o.x\r\n.ox.\r\n", "output": ["YES"]}, {"input": ".xxo\r\n...o\r\n..ox\r\nox..\r\n", "output": ["YES"]}, {"input": "x...\r\nxo..\r\noxo.\r\n..ox\r\n", "output": ["NO"]}, {"input": "xoxo\r\nx.ox\r\n....\r\noxo.\r\n", "output": ["YES"]}, {"input": "x..o\r\nxo.x\r\no.xo\r\nxoox\r\n", "output": ["NO"]}, {"input": ".x..\r\no..x\r\n.oo.\r\nxox.\r\n", "output": ["NO"]}, {"input": "xxox\r\no.x.\r\nxo.o\r\nxo.o\r\n", "output": ["NO"]}, {"input": ".xo.\r\nx.oo\r\n...x\r\n.o.x\r\n", "output": ["NO"]}, {"input": "ox.o\r\n...x\r\n..oo\r\nxxox\r\n", "output": ["NO"]}, {"input": "oox.\r\nxoo.\r\no.x.\r\nx..x\r\n", "output": ["NO"]}, {"input": "oxox\r\nx.oo\r\nooxx\r\nxxo.\r\n", "output": ["NO"]}, {"input": "....\r\nxo.x\r\n..x.\r\noo..\r\n", "output": ["NO"]}, {"input": ".ox.\r\nx..o\r\nxo.x\r\noxo.\r\n", "output": ["YES"]}, {"input": ".xox\r\nxo..\r\n..oo\r\n.x..\r\n", "output": ["NO"]}, {"input": "xxo.\r\n.oo.\r\n..x.\r\n..xo\r\n", "output": ["NO"]}, {"input": "ox..\r\n..oo\r\n..x.\r\nxxo.\r\n", "output": ["NO"]}, {"input": "xxo.\r\nx..x\r\noo.o\r\noxox\r\n", "output": ["YES"]}, {"input": "xx..\r\noxxo\r\nxo.o\r\noox.\r\n", "output": ["YES"]}, {"input": "xox.\r\noox.\r\n....\r\n....\r\n", "output": ["YES"]}, {"input": "x..o\r\no..o\r\no..x\r\nxxox\r\n", "output": ["NO"]}, {"input": "oxo.\r\nxx.x\r\nooxx\r\n.o.o\r\n", "output": ["YES"]}, {"input": ".o.x\r\no..o\r\nx..x\r\n..xo\r\n", "output": ["NO"]}, {"input": "x.x.\r\n...o\r\n.o..\r\n....\r\n", "output": ["YES"]}, {"input": "xo..\r\n....\r\nx...\r\n..o.\r\n", "output": ["YES"]}, {"input": "xo..\r\n....\r\n..xo\r\n....\r\n", "output": ["YES"]}, {"input": "ox.x\r\n...o\r\n....\r\n....\r\n", "output": ["YES"]}, {"input": ".x..\r\no.o.\r\n.x..\r\n....\r\n", "output": ["YES"]}, {"input": ".x..\r\no...\r\n...x\r\n.o..\r\n", "output": ["YES"]}, {"input": "..xo\r\n....\r\nx.o.\r\n....\r\n", "output": ["YES"]}, {"input": "o.x.\r\n....\r\n.ox.\r\n....\r\n", "output": ["YES"]}, {"input": "...x\r\n....\r\n.x.o\r\n..o.\r\n", "output": ["YES"]}, {"input": "o..x\r\n....\r\n...x\r\n..o.\r\n", "output": ["YES"]}, {"input": "o...\r\nx.x.\r\no...\r\n....\r\n", "output": ["YES"]}, {"input": "....\r\nxo..\r\n..o.\r\nx...\r\n", "output": ["YES"]}, {"input": ".oo.\r\nx...\r\n....\r\n..x.\r\n", "output": ["YES"]}, {"input": "....\r\n.x.x\r\no.o.\r\n....\r\n", "output": ["YES"]}, {"input": ".o..\r\n.x..\r\n..o.\r\n.x..\r\n", "output": ["YES"]}, {"input": "..o.\r\n.x..\r\n....\r\no..x\r\n", "output": ["YES"]}, {"input": "....\r\n.oxo\r\n....\r\nx...\r\n", "output": ["YES"]}, {"input": "..o.\r\n..x.\r\n....\r\n.ox.\r\n", "output": ["YES"]}, {"input": ".o..\r\no..x\r\n....\r\n.x..\r\n", "output": ["YES"]}, {"input": "....\r\n..ox\r\n....\r\n.o.x\r\n", "output": ["YES"]}, {"input": "o...\r\n.o..\r\nx.x.\r\n....\r\n", "output": ["YES"]}, {"input": "....\r\n..oo\r\n.x.x\r\n....\r\n", "output": ["YES"]}, {"input": ".o..\r\n....\r\no...\r\nx.x.\r\n", "output": ["YES"]}, {"input": "....\r\n.o..\r\n....\r\nox.x\r\n", "output": ["YES"]}, {"input": "oxo.\r\nxxox\r\noo.o\r\nxoxx\r\n", "output": ["YES"]}, {"input": "..xx\r\noo..\r\n....\r\n....\r\n", "output": ["YES"]}, {"input": ".xx.\r\n...x\r\noo.o\r\no..x\r\n", "output": ["YES"]}, {"input": "x...\r\n.x..\r\n....\r\noo..\r\n", "output": ["YES"]}, {"input": ".oox\r\n..x.\r\n....\r\n....\r\n", "output": ["YES"]}, {"input": "...x\r\no..x\r\n.o..\r\n....\r\n", "output": ["YES"]}, {"input": "oxox\r\n..ox\r\nxoxo\r\nxoxo\r\n", "output": ["YES"]}, {"input": "....\r\n.ox.\r\n.o..\r\nx...\r\n", "output": ["NO"]}, {"input": "....\r\n...x\r\n...x\r\noo..\r\n", "output": ["YES"]}]
100
100
100
[{'input': '....\r\nxo.x\r\n..x.\r\noo..\r\n', 'output': ['NO']}, {'input': '.xxo\r\n...o\r\n..ox\r\nox..\r\n', 'output': ['YES']}, {'input': '.oo.\r\nx...\r\n....\r\n..x.\r\n', 'output': ['YES']}, {'input': 'oo.x\r\nxo.o\r\no.xx\r\n.oxx\r\n', 'output': ['YES']}, {'input': 'x..o\r\no..o\r\no..x\r\nxxox\r\n', 'output': ['NO']}]
[{'input': 'x..o\r\nxo.x\r\no.xo\r\nxoox\r\n', 'output': ['NO']}, {'input': '....\r\nxo..\r\n..o.\r\nx...\r\n', 'output': ['YES']}, {'input': '..o.\r\n.x..\r\n....\r\no..x\r\n', 'output': ['YES']}, {'input': '.oox\r\n..x.\r\n....\r\n....\r\n', 'output': ['YES']}, {'input': '....\r\nxo.x\r\n..x.\r\noo..\r\n', 'output': ['NO']}]
[{'input': '.oo.\r\n.x..\r\nx...\r\nox..\r\n', 'output': ['YES']}, {'input': '..xo\r\n....\r\nx.o.\r\n....\r\n', 'output': ['YES']}, {'input': '....\r\n.ox.\r\n.o..\r\nx...\r\n', 'output': ['NO']}, {'input': '.oox\r\n..x.\r\n....\r\n....\r\n', 'output': ['YES']}, {'input': '....\r\n.x.x\r\no.o.\r\n....\r\n', 'output': ['YES']}]
[{'input': 'o.xx\r\nxo.o\r\n...o\r\n..x.\r\n', 'output': ['YES']}, {'input': '...x\r\no..x\r\n.o..\r\n....\r\n', 'output': ['YES']}, {'input': '..ox\r\n.o..\r\nx..o\r\n.oxx\r\n', 'output': ['NO']}, {'input': '.x.x\r\n.o.o\r\no.xx\r\nx.oo\r\n', 'output': ['YES']}, {'input': '...x\r\n.x.o\r\n.o..\r\n.x.o\r\n', 'output': ['NO']}]
[{'input': 'xxo.\r\nx..x\r\noo.o\r\noxox\r\n', 'output': ['YES']}, {'input': '.o..\r\n.x..\r\n..o.\r\n.x..\r\n', 'output': ['YES']}, {'input': 'ox..\r\n..oo\r\n..x.\r\nxxo.\r\n', 'output': ['NO']}, {'input': 'x...\r\n.ox.\r\n.oo.\r\n.xox\r\n', 'output': ['NO']}, {'input': '.oxx\r\n..o.\r\n.o.x\r\n.ox.\r\n', 'output': ['YES']}]
100
100
100
100
100
100
100
100
100
100
86.61
90.18
90.18
91.96
87.5
174
100
100
89.286
["3 3 3\n1 1 1\n2 2 3\n3 3 2", "4 10 2\n2 3 8\n3 4 7"]
The first line contains three integers $$$n$$$, $$$h$$$, and $$$m$$$ ($$$1 \leq n,h,m \leq 50$$$) — the number of spots, the maximum height, and the number of restrictions. Each of the next $$$m$$$ lines contains three integers $$$l_i$$$, $$$r_i$$$, and $$$x_i$$$ ($$$1 \leq l_i \leq r_i \leq n$$$, $$$0 \leq x_i \leq h$$$) — left and right limits (inclusive) of the $$$i$$$-th restriction and the maximum possible height in that range.
f22b6dab443f63fb8d2d288b702f20ad
#pragma GCC diagnostic error "-std=c++11" #pragma GCC target("avx") #pragma GCC optimize(3) #pragma GCC optimize("Ofast") #pragma GCC optimize("inline") #pragma GCC optimize("-fgcse") #pragma GCC optimize("-fgcse-lm") #pragma GCC optimize("-fipa-sra") #pragma GCC optimize("-ftree-pre") #pragma GCC optimize("-ftree-vrp") #pragma GCC optimize("-fpeephole2") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("-fsched-spec") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("-falign-jumps") #pragma GCC optimize("-falign-loops") #pragma GCC optimize("-falign-labels") #pragma GCC optimize("-fdevirtualize") #pragma GCC optimize("-fcaller-saves") #pragma GCC optimize("-fcrossjumping") #pragma GCC optimize("-fthread-jumps") #pragma GCC optimize("-funroll-loops") #pragma GCC optimize("-fwhole-program") #pragma GCC optimize("-freorder-blocks") #pragma GCC optimize("-fschedule-insns") #pragma GCC optimize("inline-functions") #pragma GCC optimize("-ftree-tail-merge") #pragma GCC optimize("-fschedule-insns2") #pragma GCC optimize("-fstrict-aliasing") #pragma GCC optimize("-fstrict-overflow") #pragma GCC optimize("-falign-functions") #pragma GCC optimize("-fcse-skip-blocks") #pragma GCC optimize("-fcse-follow-jumps") #pragma GCC optimize("-fsched-interblock") #pragma GCC optimize("-fpartial-inlining") #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("-freorder-functions") #pragma GCC optimize("-findirect-inlining") #pragma GCC optimize("-fhoist-adjacent-loads") #pragma GCC optimize("-frerun-cse-after-loop") #pragma GCC optimize("inline-small-functions") #pragma GCC optimize("-finline-small-functions") #pragma GCC optimize("-ftree-switch-conversion") #pragma GCC optimize("-foptimize-sibling-calls") #pragma GCC optimize("-fexpensive-optimizations") #pragma GCC optimize("-funsafe-loop-optimizations") #pragma GCC optimize("inline-functions-called-once") #pragma GCC optimize("-fdelete-null-pointer-checks") #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #include<vector> #include<queue> #include<map> #include<set> #include<fstream> using namespace std; int main() { ios::sync_with_stdio(0); int ans=0,n,h,m,a[100]; cin>>n>>h>>m; for(int i=0;i<n;i++) { a[i]=h; } while(m--) { int li,ri,xi; cin>>li>>ri>>xi; li--; ri--; for(int i=li;i<=ri;i++) { if(a[i]>xi) { a[i]=xi; } } } for(int i=0;i<n;i++) { ans+=a[i]*a[i]; } cout<<ans<<endl; return 0; }
["14", "262"]
C++
NoteIn the first example, there are $$$3$$$ houses, the maximum height of a house is $$$3$$$, and there are $$$3$$$ restrictions. The first restriction says the tallest house between $$$1$$$ and $$$1$$$ must be at most $$$1$$$. The second restriction says the tallest house between $$$2$$$ and $$$2$$$ must be at most $$$3$$$. The third restriction says the tallest house between $$$3$$$ and $$$3$$$ must be at most $$$2$$$.In this case, it is optimal to build houses with heights $$$[1, 3, 2]$$$. This fits within all the restrictions. The total profit in this case is $$$1^2 + 3^2 + 2^2 = 14$$$.In the second example, there are $$$4$$$ houses, the maximum height of a house is $$$10$$$, and there are $$$2$$$ restrictions. The first restriction says the tallest house from $$$2$$$ to $$$3$$$ must be at most $$$8$$$. The second restriction says the tallest house from $$$3$$$ to $$$4$$$ must be at most $$$7$$$.In this case, it's optimal to build houses with heights $$$[10, 8, 7, 7]$$$. We get a profit of $$$10^2+8^2+7^2+7^2 = 262$$$. Note that there are two restrictions on house $$$3$$$ and both of them must be satisfied. Also, note that even though there isn't any explicit restrictions on house $$$1$$$, we must still limit its height to be at most $$$10$$$ ($$$h=10$$$).
Print a single integer, the maximum profit you can make.
You are planning to build housing on a street. There are $$$n$$$ spots available on the street on which you can build a house. The spots are labeled from $$$1$$$ to $$$n$$$ from left to right. In each spot, you can build a house with an integer height between $$$0$$$ and $$$h$$$.In each spot, if a house has height $$$a$$$, you will gain $$$a^2$$$ dollars from it.The city has $$$m$$$ zoning restrictions. The $$$i$$$-th restriction says that the tallest house from spots $$$l_i$$$ to $$$r_i$$$ (inclusive) must be at most $$$x_i$$$.You would like to build houses to maximize your profit. Determine the maximum profit possible.
[{"input": "3 3 3\r\n1 1 1\r\n2 2 3\r\n3 3 2\r\n", "output": ["14"]}, {"input": "4 10 2\r\n2 3 8\r\n3 4 7\r\n", "output": ["262"]}, {"input": "50 50 1\r\n1 50 0\r\n", "output": ["0"]}, {"input": "50 50 50\r\n17 40 12\r\n33 36 47\r\n8 43 35\r\n25 29 42\r\n18 36 6\r\n25 35 18\r\n36 48 47\r\n17 40 13\r\n20 27 37\r\n32 32 28\r\n17 20 13\r\n4 14 6\r\n13 18 47\r\n18 45 28\r\n3 50 45\r\n6 6 6\r\n3 25 36\r\n28 48 42\r\n14 34 32\r\n28 41 35\r\n29 35 25\r\n25 48 24\r\n32 40 40\r\n18 38 44\r\n6 16 2\r\n1 36 7\r\n14 48 2\r\n18 29 40\r\n11 16 37\r\n8 40 19\r\n12 16 44\r\n44 46 21\r\n19 24 26\r\n24 45 44\r\n22 22 15\r\n6 15 32\r\n19 42 7\r\n21 33 20\r\n1 13 26\r\n16 27 40\r\n46 48 30\r\n21 39 1\r\n1 9 32\r\n14 34 20\r\n35 38 11\r\n19 47 23\r\n13 38 15\r\n28 29 28\r\n7 20 40\r\n2 21 46\r\n", "output": ["4384"]}, {"input": "50 50 50\r\n20 34 50\r\n10 36 27\r\n46 49 19\r\n15 22 21\r\n5 10 21\r\n40 47 0\r\n26 43 48\r\n15 34 5\r\n29 48 49\r\n2 45 25\r\n5 40 42\r\n1 27 0\r\n43 50 47\r\n5 19 23\r\n1 42 20\r\n18 50 16\r\n13 38 14\r\n14 30 22\r\n5 26 2\r\n32 46 15\r\n10 49 37\r\n33 37 24\r\n10 31 45\r\n16 45 37\r\n22 41 7\r\n23 49 29\r\n22 44 49\r\n3 44 22\r\n26 32 4\r\n30 40 19\r\n19 28 5\r\n6 34 14\r\n16 21 40\r\n12 43 46\r\n9 36 42\r\n2 19 39\r\n13 45 12\r\n2 30 6\r\n5 28 35\r\n18 45 7\r\n39 46 29\r\n29 43 33\r\n3 16 24\r\n20 40 24\r\n35 36 8\r\n2 14 8\r\n3 29 47\r\n31 32 0\r\n27 49 16\r\n1 37 45\r\n", "output": ["1111"]}, {"input": "50 50 50\r\n28 29 9\r\n33 43 30\r\n12 34 3\r\n9 12 26\r\n24 39 10\r\n12 47 35\r\n29 41 47\r\n43 44 49\r\n19 37 36\r\n11 18 46\r\n19 42 20\r\n9 40 47\r\n18 34 22\r\n11 20 44\r\n5 31 44\r\n29 40 0\r\n1 26 19\r\n7 50 4\r\n14 34 48\r\n43 48 21\r\n12 49 23\r\n6 40 47\r\n22 37 50\r\n39 48 29\r\n12 34 13\r\n5 10 25\r\n30 45 46\r\n26 32 29\r\n2 4 23\r\n7 39 19\r\n22 49 42\r\n11 29 31\r\n23 50 29\r\n12 32 47\r\n4 13 18\r\n24 46 20\r\n33 34 44\r\n24 35 41\r\n39 50 47\r\n14 24 49\r\n25 44 28\r\n23 23 42\r\n32 44 40\r\n25 42 3\r\n25 31 6\r\n35 47 18\r\n22 49 2\r\n38 43 23\r\n1 27 16\r\n19 23 43\r\n", "output": ["1786"]}, {"input": "50 50 50\r\n24 31 47\r\n2 5 10\r\n18 22 39\r\n6 48 29\r\n30 43 25\r\n9 26 19\r\n20 40 23\r\n27 49 42\r\n41 49 50\r\n28 39 42\r\n35 37 49\r\n17 40 40\r\n26 38 21\r\n8 38 40\r\n10 28 19\r\n30 41 9\r\n2 13 24\r\n29 42 36\r\n20 49 17\r\n3 48 1\r\n33 38 10\r\n5 37 20\r\n7 21 30\r\n35 38 22\r\n37 38 19\r\n16 43 47\r\n46 50 16\r\n4 13 36\r\n18 20 41\r\n26 31 19\r\n11 34 30\r\n20 23 23\r\n20 46 19\r\n10 43 49\r\n27 33 45\r\n37 45 27\r\n6 12 0\r\n38 47 27\r\n3 50 6\r\n25 41 41\r\n2 37 27\r\n25 49 24\r\n38 44 31\r\n31 36 7\r\n18 31 3\r\n6 33 2\r\n19 36 33\r\n45 50 48\r\n10 21 17\r\n8 41 42\r\n", "output": ["2711"]}, {"input": "50 50 50\r\n26 27 33\r\n8 29 15\r\n10 31 23\r\n7 38 33\r\n9 12 39\r\n3 18 2\r\n11 35 25\r\n8 10 33\r\n12 19 11\r\n9 44 39\r\n17 32 27\r\n17 49 9\r\n13 13 20\r\n3 9 36\r\n18 20 43\r\n24 48 19\r\n12 26 1\r\n39 49 18\r\n11 33 38\r\n7 49 7\r\n23 38 48\r\n20 22 46\r\n12 31 34\r\n21 41 15\r\n3 13 26\r\n26 30 18\r\n50 50 12\r\n20 39 18\r\n34 40 10\r\n35 45 21\r\n28 41 17\r\n17 29 40\r\n21 30 34\r\n16 34 0\r\n28 45 21\r\n4 36 8\r\n31 50 6\r\n10 48 12\r\n18 42 43\r\n43 47 32\r\n35 38 27\r\n19 26 5\r\n5 36 22\r\n33 38 38\r\n7 24 50\r\n20 23 12\r\n5 35 40\r\n2 7 19\r\n38 49 45\r\n17 39 40\r\n", "output": ["3477"]}, {"input": "50 50 50\r\n7 47 45\r\n22 24 8\r\n31 48 31\r\n36 47 13\r\n7 25 19\r\n2 2 17\r\n34 40 14\r\n27 33 50\r\n31 45 35\r\n4 7 4\r\n27 30 27\r\n4 41 27\r\n34 41 15\r\n2 12 17\r\n2 3 19\r\n25 47 47\r\n6 43 50\r\n4 47 23\r\n5 38 30\r\n12 43 18\r\n8 38 28\r\n6 11 13\r\n23 35 41\r\n2 39 41\r\n27 30 1\r\n28 49 46\r\n15 39 29\r\n18 29 22\r\n37 39 33\r\n7 45 40\r\n23 49 19\r\n8 12 46\r\n21 48 26\r\n22 45 27\r\n9 35 50\r\n10 43 5\r\n13 29 22\r\n7 36 12\r\n18 37 34\r\n17 18 3\r\n17 27 4\r\n44 47 39\r\n6 10 34\r\n31 48 1\r\n32 45 33\r\n39 41 43\r\n5 40 4\r\n8 50 11\r\n1 45 42\r\n30 35 31\r\n", "output": ["2960"]}, {"input": "50 50 50\r\n14 41 31\r\n28 49 13\r\n4 19 15\r\n34 41 16\r\n37 40 34\r\n10 25 1\r\n28 35 15\r\n2 42 43\r\n2 12 47\r\n16 25 26\r\n21 48 4\r\n13 37 22\r\n16 26 15\r\n30 49 12\r\n8 40 45\r\n32 33 6\r\n6 27 2\r\n25 35 5\r\n22 42 24\r\n6 13 49\r\n23 26 14\r\n27 42 38\r\n9 34 45\r\n1 33 35\r\n42 44 7\r\n5 7 42\r\n12 43 25\r\n5 42 4\r\n7 47 2\r\n7 10 40\r\n20 34 6\r\n2 21 12\r\n9 45 15\r\n19 45 29\r\n4 50 0\r\n1 2 12\r\n1 47 26\r\n8 16 23\r\n9 48 45\r\n23 28 20\r\n12 19 4\r\n27 37 46\r\n21 47 25\r\n33 49 5\r\n21 49 6\r\n14 32 1\r\n5 13 36\r\n7 23 34\r\n15 34 43\r\n2 24 29\r\n", "output": ["432"]}, {"input": "50 50 50\r\n14 39 43\r\n22 27 43\r\n9 11 0\r\n23 38 21\r\n13 32 23\r\n19 43 35\r\n27 29 15\r\n6 31 8\r\n19 20 35\r\n36 45 22\r\n20 26 34\r\n13 49 42\r\n13 37 40\r\n37 45 7\r\n16 41 19\r\n27 48 15\r\n15 41 8\r\n33 45 37\r\n6 33 45\r\n10 18 4\r\n12 35 27\r\n15 42 37\r\n25 28 50\r\n19 46 28\r\n7 19 12\r\n12 44 13\r\n1 12 21\r\n7 36 11\r\n19 29 21\r\n6 33 14\r\n32 41 44\r\n30 46 30\r\n1 47 30\r\n14 43 31\r\n18 37 27\r\n11 50 44\r\n26 26 7\r\n24 31 9\r\n9 13 5\r\n29 47 12\r\n6 17 3\r\n3 35 29\r\n29 41 42\r\n5 27 35\r\n14 45 3\r\n27 31 37\r\n20 33 43\r\n18 22 7\r\n12 35 44\r\n10 24 28\r\n", "output": ["6751"]}, {"input": "50 50 50\r\n18 30 29\r\n39 40 46\r\n19 45 35\r\n13 32 26\r\n11 28 38\r\n15 19 18\r\n25 32 15\r\n15 15 1\r\n36 40 48\r\n15 48 18\r\n7 47 12\r\n26 49 37\r\n1 8 40\r\n5 38 4\r\n13 30 18\r\n5 21 0\r\n9 32 37\r\n14 16 44\r\n24 45 15\r\n18 19 36\r\n1 48 14\r\n46 49 11\r\n2 28 4\r\n2 6 21\r\n11 49 20\r\n22 27 34\r\n17 17 43\r\n12 35 19\r\n33 46 38\r\n1 6 15\r\n44 45 31\r\n37 47 22\r\n35 44 20\r\n22 45 33\r\n28 41 3\r\n28 45 0\r\n2 47 13\r\n25 41 45\r\n1 28 14\r\n3 47 3\r\n15 41 2\r\n33 37 37\r\n39 45 33\r\n11 33 38\r\n3 42 50\r\n10 48 47\r\n3 38 49\r\n21 33 31\r\n9 41 19\r\n33 50 27\r\n", "output": ["1243"]}, {"input": "50 50 50\r\n13 24 16\r\n13 46 26\r\n28 37 19\r\n2 22 29\r\n1 2 2\r\n30 31 3\r\n16 23 42\r\n32 44 45\r\n11 44 9\r\n19 35 39\r\n25 44 41\r\n4 35 31\r\n33 38 39\r\n28 35 25\r\n17 26 43\r\n17 49 9\r\n22 40 42\r\n11 44 26\r\n29 48 36\r\n20 30 41\r\n11 32 0\r\n15 31 35\r\n27 30 34\r\n38 47 39\r\n23 24 25\r\n14 20 30\r\n10 25 40\r\n5 39 0\r\n5 10 7\r\n5 20 15\r\n3 10 18\r\n10 35 39\r\n27 45 9\r\n18 34 35\r\n5 15 30\r\n35 41 32\r\n23 35 20\r\n9 37 30\r\n4 39 1\r\n2 26 46\r\n9 27 1\r\n13 31 18\r\n10 26 24\r\n17 28 17\r\n4 42 48\r\n24 50 32\r\n3 19 29\r\n28 35 2\r\n20 29 20\r\n22 23 24\r\n", "output": ["2167"]}, {"input": "50 50 50\r\n15 21 1\r\n8 40 30\r\n25 34 4\r\n19 46 8\r\n24 32 16\r\n2 31 37\r\n18 18 43\r\n27 42 37\r\n7 28 48\r\n2 31 36\r\n43 45 19\r\n8 48 25\r\n4 26 13\r\n36 42 20\r\n15 26 18\r\n28 43 18\r\n7 32 47\r\n18 46 7\r\n9 39 5\r\n17 35 21\r\n21 24 38\r\n12 30 34\r\n18 49 38\r\n28 46 32\r\n39 41 31\r\n1 26 1\r\n14 29 35\r\n23 33 7\r\n23 32 25\r\n1 13 15\r\n17 20 5\r\n20 21 31\r\n11 43 24\r\n8 33 37\r\n6 19 6\r\n34 46 39\r\n15 44 25\r\n31 50 15\r\n11 46 11\r\n16 40 12\r\n6 8 1\r\n25 44 0\r\n22 28 15\r\n22 30 21\r\n30 44 45\r\n41 45 41\r\n22 35 36\r\n39 46 25\r\n2 12 21\r\n7 41 23\r\n", "output": ["1022"]}, {"input": "50 50 50\r\n17 17 39\r\n11 13 9\r\n9 43 39\r\n9 35 13\r\n23 39 31\r\n21 43 21\r\n16 17 43\r\n2 47 30\r\n23 49 9\r\n22 47 7\r\n20 34 48\r\n12 49 20\r\n13 29 12\r\n3 29 17\r\n4 30 42\r\n37 40 28\r\n16 50 24\r\n31 43 40\r\n6 26 26\r\n22 43 28\r\n7 41 24\r\n33 35 8\r\n17 23 43\r\n11 49 25\r\n21 42 37\r\n34 36 23\r\n15 44 31\r\n7 7 14\r\n4 41 44\r\n13 16 16\r\n28 36 17\r\n19 29 48\r\n7 40 14\r\n7 32 39\r\n1 42 33\r\n9 25 21\r\n15 48 30\r\n1 45 1\r\n22 45 21\r\n1 22 4\r\n47 50 0\r\n16 19 8\r\n22 38 32\r\n24 32 1\r\n31 37 43\r\n16 36 25\r\n5 41 17\r\n42 45 49\r\n23 32 48\r\n21 43 21\r\n", "output": ["94"]}, {"input": "50 50 50\r\n15 20 50\r\n11 36 39\r\n1 7 23\r\n11 25 16\r\n2 8 46\r\n44 47 5\r\n7 15 20\r\n6 35 23\r\n21 31 47\r\n14 42 3\r\n22 44 25\r\n7 12 15\r\n5 50 13\r\n29 29 38\r\n4 35 17\r\n1 23 37\r\n22 32 30\r\n17 25 21\r\n17 40 47\r\n5 31 8\r\n46 50 10\r\n21 45 32\r\n7 47 48\r\n9 48 17\r\n4 46 43\r\n20 42 19\r\n2 15 28\r\n31 34 48\r\n9 22 11\r\n4 38 16\r\n31 49 4\r\n14 34 14\r\n41 49 28\r\n6 38 41\r\n10 38 8\r\n16 26 26\r\n24 36 37\r\n9 17 37\r\n37 41 32\r\n19 39 47\r\n10 33 0\r\n20 46 41\r\n12 45 22\r\n26 34 5\r\n27 34 40\r\n23 33 10\r\n6 17 23\r\n3 9 20\r\n1 2 49\r\n20 39 19\r\n", "output": ["2327"]}, {"input": "50 50 50\r\n6 28 36\r\n12 22 44\r\n12 39 7\r\n19 50 20\r\n27 43 35\r\n6 12 38\r\n2 6 20\r\n15 24 15\r\n38 43 8\r\n21 22 49\r\n15 21 4\r\n20 20 8\r\n25 42 37\r\n22 40 34\r\n43 43 17\r\n17 21 22\r\n35 41 34\r\n10 41 2\r\n8 29 17\r\n9 24 38\r\n14 31 24\r\n2 10 32\r\n6 20 2\r\n41 42 11\r\n20 22 49\r\n2 7 40\r\n16 18 48\r\n8 10 4\r\n31 40 30\r\n4 7 16\r\n19 39 42\r\n1 8 6\r\n37 42 17\r\n11 34 43\r\n25 29 36\r\n6 35 8\r\n12 15 42\r\n14 35 48\r\n33 48 43\r\n34 41 38\r\n4 18 50\r\n10 22 23\r\n7 15 13\r\n24 40 35\r\n23 27 36\r\n9 50 19\r\n24 30 29\r\n8 10 44\r\n26 30 50\r\n5 23 19\r\n", "output": ["2979"]}, {"input": "50 50 50\r\n24 50 22\r\n26 27 22\r\n22 27 43\r\n16 48 24\r\n27 46 50\r\n2 34 22\r\n1 4 21\r\n33 48 7\r\n5 14 21\r\n37 43 19\r\n8 39 32\r\n20 21 4\r\n4 34 36\r\n12 23 29\r\n32 47 42\r\n11 32 31\r\n4 49 13\r\n3 16 35\r\n13 44 37\r\n17 29 45\r\n16 23 10\r\n25 33 5\r\n1 44 6\r\n28 49 30\r\n31 47 4\r\n13 44 11\r\n17 22 45\r\n24 40 37\r\n11 45 48\r\n4 26 17\r\n32 50 30\r\n2 10 23\r\n29 48 31\r\n30 50 19\r\n16 47 11\r\n5 48 14\r\n33 41 48\r\n8 27 34\r\n9 32 27\r\n45 47 5\r\n2 50 49\r\n8 48 31\r\n27 47 29\r\n27 46 39\r\n12 28 34\r\n4 25 5\r\n43 50 10\r\n13 19 16\r\n9 46 0\r\n41 45 16\r\n", "output": ["498"]}, {"input": "50 50 50\r\n28 33 44\r\n15 17 1\r\n25 40 10\r\n7 43 38\r\n13 23 9\r\n4 4 43\r\n25 26 43\r\n5 41 14\r\n1 49 40\r\n4 31 18\r\n41 45 22\r\n38 43 48\r\n23 30 45\r\n5 13 3\r\n1 47 13\r\n14 25 33\r\n27 32 40\r\n23 50 26\r\n2 25 20\r\n7 41 41\r\n31 41 47\r\n34 37 7\r\n6 37 14\r\n23 43 20\r\n14 49 31\r\n22 25 22\r\n12 30 36\r\n44 46 32\r\n5 48 34\r\n17 22 31\r\n39 48 14\r\n27 34 25\r\n20 41 24\r\n31 48 9\r\n19 30 11\r\n45 49 48\r\n1 28 35\r\n10 16 10\r\n36 37 46\r\n5 42 48\r\n15 50 24\r\n12 44 27\r\n14 27 9\r\n5 37 46\r\n33 48 3\r\n12 45 8\r\n5 15 37\r\n1 5 43\r\n46 47 4\r\n8 49 33\r\n", "output": ["3080"]}, {"input": "20 50 20\r\n4 5 18\r\n14 15 32\r\n6 13 46\r\n13 19 39\r\n2 8 18\r\n15 16 29\r\n2 8 9\r\n1 2 23\r\n1 8 8\r\n18 18 11\r\n10 16 3\r\n9 18 44\r\n9 19 31\r\n2 3 19\r\n4 19 12\r\n10 17 24\r\n9 13 20\r\n4 7 10\r\n12 20 24\r\n3 19 19\r\n", "output": ["1704"]}, {"input": "50 20 20\r\n4 15 1\r\n26 31 15\r\n28 40 5\r\n16 42 1\r\n10 26 10\r\n42 42 1\r\n21 49 4\r\n24 50 10\r\n7 32 12\r\n5 38 18\r\n36 41 14\r\n16 44 2\r\n23 33 4\r\n18 19 15\r\n14 21 14\r\n18 28 16\r\n29 38 13\r\n6 17 10\r\n6 44 2\r\n17 45 1\r\n", "output": ["1406"]}, {"input": "20 20 50\r\n10 17 9\r\n5 10 5\r\n9 18 5\r\n4 19 8\r\n10 18 4\r\n5 19 2\r\n9 11 0\r\n3 9 9\r\n11 12 6\r\n7 9 7\r\n6 19 15\r\n7 12 10\r\n5 17 18\r\n4 9 14\r\n11 11 9\r\n2 20 8\r\n2 16 9\r\n5 16 1\r\n1 2 5\r\n6 9 1\r\n8 13 15\r\n6 15 18\r\n7 13 7\r\n13 18 11\r\n1 16 17\r\n16 20 17\r\n2 19 10\r\n15 18 0\r\n2 14 11\r\n1 3 11\r\n2 3 3\r\n2 16 10\r\n6 20 7\r\n3 17 2\r\n8 13 11\r\n7 11 13\r\n1 13 14\r\n5 16 4\r\n2 3 14\r\n2 5 4\r\n4 10 6\r\n10 17 20\r\n9 13 4\r\n1 5 20\r\n7 13 6\r\n16 20 9\r\n9 16 16\r\n5 12 7\r\n2 18 14\r\n9 13 19\r\n", "output": ["102"]}, {"input": "20 50 20\r\n3 9 4\r\n4 7 11\r\n9 14 31\r\n1 6 17\r\n5 13 33\r\n17 19 11\r\n13 14 10\r\n4 12 16\r\n8 19 46\r\n8 19 7\r\n11 20 32\r\n3 18 39\r\n1 12 31\r\n4 16 15\r\n2 15 38\r\n1 2 33\r\n2 11 25\r\n7 14 17\r\n3 14 45\r\n15 18 50\r\n", "output": ["2204"]}, {"input": "50 20 20\r\n19 49 15\r\n8 29 12\r\n28 33 20\r\n5 40 14\r\n1 45 14\r\n15 50 17\r\n20 44 17\r\n11 18 15\r\n20 40 6\r\n16 21 6\r\n12 31 10\r\n29 49 5\r\n20 44 17\r\n16 41 10\r\n3 30 9\r\n8 36 10\r\n45 48 5\r\n6 27 12\r\n35 44 8\r\n21 42 16\r\n", "output": ["2727"]}, {"input": "20 20 50\r\n1 3 9\r\n2 20 19\r\n2 5 3\r\n2 8 17\r\n1 19 16\r\n1 19 1\r\n17 19 13\r\n2 6 6\r\n9 12 14\r\n15 15 3\r\n6 13 7\r\n11 17 6\r\n12 15 15\r\n4 16 5\r\n8 13 4\r\n6 12 6\r\n10 13 1\r\n2 20 15\r\n9 16 11\r\n1 13 16\r\n2 12 17\r\n13 17 13\r\n17 18 9\r\n5 6 11\r\n5 16 6\r\n3 16 0\r\n2 10 3\r\n2 17 6\r\n6 9 4\r\n4 11 2\r\n5 20 17\r\n5 20 9\r\n7 20 15\r\n5 11 20\r\n11 15 12\r\n6 18 8\r\n9 16 4\r\n2 17 14\r\n4 8 11\r\n8 15 8\r\n15 18 20\r\n7 14 15\r\n5 8 14\r\n11 13 20\r\n16 17 15\r\n1 14 13\r\n6 10 11\r\n8 19 19\r\n8 20 17\r\n3 19 2\r\n", "output": ["86"]}, {"input": "20 50 20\r\n5 9 16\r\n17 17 15\r\n2 4 15\r\n6 20 22\r\n3 16 48\r\n11 13 46\r\n2 3 37\r\n7 9 8\r\n16 20 7\r\n11 19 3\r\n6 19 11\r\n3 18 34\r\n7 19 5\r\n7 17 37\r\n4 16 12\r\n13 16 42\r\n18 20 4\r\n3 8 50\r\n9 14 15\r\n17 19 5\r\n", "output": ["3556"]}, {"input": "50 20 20\r\n22 39 19\r\n23 37 18\r\n16 38 9\r\n30 49 15\r\n14 31 5\r\n1 29 16\r\n10 46 9\r\n27 40 16\r\n3 42 1\r\n33 38 6\r\n18 40 6\r\n3 34 5\r\n8 23 14\r\n5 9 14\r\n4 34 8\r\n1 48 16\r\n4 15 18\r\n9 46 18\r\n18 29 14\r\n25 47 20\r\n", "output": ["1951"]}, {"input": "20 20 50\r\n1 13 18\r\n1 18 9\r\n4 6 13\r\n2 7 17\r\n8 8 7\r\n5 11 17\r\n8 18 5\r\n8 18 11\r\n1 9 9\r\n6 15 12\r\n15 17 3\r\n2 15 10\r\n11 16 19\r\n2 17 13\r\n8 16 15\r\n6 7 0\r\n4 8 14\r\n5 8 0\r\n10 20 13\r\n6 12 3\r\n11 16 19\r\n4 14 20\r\n1 17 11\r\n7 15 7\r\n11 17 8\r\n6 17 7\r\n6 16 17\r\n5 16 3\r\n17 18 2\r\n6 14 14\r\n12 16 2\r\n2 11 16\r\n2 7 11\r\n1 14 4\r\n6 13 1\r\n1 17 10\r\n8 16 19\r\n9 13 16\r\n13 14 3\r\n8 19 12\r\n9 16 16\r\n5 10 17\r\n5 18 12\r\n1 17 15\r\n3 7 0\r\n17 18 4\r\n4 19 16\r\n6 18 9\r\n2 19 11\r\n1 4 11\r\n", "output": ["347"]}, {"input": "3 3 4\r\n1 3 1\r\n1 1 3\r\n2 2 3\r\n3 3 3\r\n", "output": ["3"]}]
100
100
100
[{'input': '50 50 50\r\n13 24 16\r\n13 46 26\r\n28 37 19\r\n2 22 29\r\n1 2 2\r\n30 31 3\r\n16 23 42\r\n32 44 45\r\n11 44 9\r\n19 35 39\r\n25 44 41\r\n4 35 31\r\n33 38 39\r\n28 35 25\r\n17 26 43\r\n17 49 9\r\n22 40 42\r\n11 44 26\r\n29 48 36\r\n20 30 41\r\n11 32 0\r\n15 31 35\r\n27 30 34\r\n38 47 39\r\n23 24 25\r\n14 20 30\r\n10 25 40\r\n5 39 0\r\n5 10 7\r\n5 20 15\r\n3 10 18\r\n10 35 39\r\n27 45 9\r\n18 34 35\r\n5 15 30\r\n35 41 32\r\n23 35 20\r\n9 37 30\r\n4 39 1\r\n2 26 46\r\n9 27 1\r\n13 31 18\r\n10 26 24\r\n17 28 17\r\n4 42 48\r\n24 50 32\r\n3 19 29\r\n28 35 2\r\n20 29 20\r\n22 23 24\r\n', 'output': ['2167']}, {'input': '50 50 50\r\n6 28 36\r\n12 22 44\r\n12 39 7\r\n19 50 20\r\n27 43 35\r\n6 12 38\r\n2 6 20\r\n15 24 15\r\n38 43 8\r\n21 22 49\r\n15 21 4\r\n20 20 8\r\n25 42 37\r\n22 40 34\r\n43 43 17\r\n17 21 22\r\n35 41 34\r\n10 41 2\r\n8 29 17\r\n9 24 38\r\n14 31 24\r\n2 10 32\r\n6 20 2\r\n41 42 11\r\n20 22 49\r\n2 7 40\r\n16 18 48\r\n8 10 4\r\n31 40 30\r\n4 7 16\r\n19 39 42\r\n1 8 6\r\n37 42 17\r\n11 34 43\r\n25 29 36\r\n6 35 8\r\n12 15 42\r\n14 35 48\r\n33 48 43\r\n34 41 38\r\n4 18 50\r\n10 22 23\r\n7 15 13\r\n24 40 35\r\n23 27 36\r\n9 50 19\r\n24 30 29\r\n8 10 44\r\n26 30 50\r\n5 23 19\r\n', 'output': ['2979']}, {'input': '50 50 50\r\n15 21 1\r\n8 40 30\r\n25 34 4\r\n19 46 8\r\n24 32 16\r\n2 31 37\r\n18 18 43\r\n27 42 37\r\n7 28 48\r\n2 31 36\r\n43 45 19\r\n8 48 25\r\n4 26 13\r\n36 42 20\r\n15 26 18\r\n28 43 18\r\n7 32 47\r\n18 46 7\r\n9 39 5\r\n17 35 21\r\n21 24 38\r\n12 30 34\r\n18 49 38\r\n28 46 32\r\n39 41 31\r\n1 26 1\r\n14 29 35\r\n23 33 7\r\n23 32 25\r\n1 13 15\r\n17 20 5\r\n20 21 31\r\n11 43 24\r\n8 33 37\r\n6 19 6\r\n34 46 39\r\n15 44 25\r\n31 50 15\r\n11 46 11\r\n16 40 12\r\n6 8 1\r\n25 44 0\r\n22 28 15\r\n22 30 21\r\n30 44 45\r\n41 45 41\r\n22 35 36\r\n39 46 25\r\n2 12 21\r\n7 41 23\r\n', 'output': ['1022']}, {'input': '50 50 50\r\n17 17 39\r\n11 13 9\r\n9 43 39\r\n9 35 13\r\n23 39 31\r\n21 43 21\r\n16 17 43\r\n2 47 30\r\n23 49 9\r\n22 47 7\r\n20 34 48\r\n12 49 20\r\n13 29 12\r\n3 29 17\r\n4 30 42\r\n37 40 28\r\n16 50 24\r\n31 43 40\r\n6 26 26\r\n22 43 28\r\n7 41 24\r\n33 35 8\r\n17 23 43\r\n11 49 25\r\n21 42 37\r\n34 36 23\r\n15 44 31\r\n7 7 14\r\n4 41 44\r\n13 16 16\r\n28 36 17\r\n19 29 48\r\n7 40 14\r\n7 32 39\r\n1 42 33\r\n9 25 21\r\n15 48 30\r\n1 45 1\r\n22 45 21\r\n1 22 4\r\n47 50 0\r\n16 19 8\r\n22 38 32\r\n24 32 1\r\n31 37 43\r\n16 36 25\r\n5 41 17\r\n42 45 49\r\n23 32 48\r\n21 43 21\r\n', 'output': ['94']}, {'input': '50 50 50\r\n26 27 33\r\n8 29 15\r\n10 31 23\r\n7 38 33\r\n9 12 39\r\n3 18 2\r\n11 35 25\r\n8 10 33\r\n12 19 11\r\n9 44 39\r\n17 32 27\r\n17 49 9\r\n13 13 20\r\n3 9 36\r\n18 20 43\r\n24 48 19\r\n12 26 1\r\n39 49 18\r\n11 33 38\r\n7 49 7\r\n23 38 48\r\n20 22 46\r\n12 31 34\r\n21 41 15\r\n3 13 26\r\n26 30 18\r\n50 50 12\r\n20 39 18\r\n34 40 10\r\n35 45 21\r\n28 41 17\r\n17 29 40\r\n21 30 34\r\n16 34 0\r\n28 45 21\r\n4 36 8\r\n31 50 6\r\n10 48 12\r\n18 42 43\r\n43 47 32\r\n35 38 27\r\n19 26 5\r\n5 36 22\r\n33 38 38\r\n7 24 50\r\n20 23 12\r\n5 35 40\r\n2 7 19\r\n38 49 45\r\n17 39 40\r\n', 'output': ['3477']}]
[{'input': '50 50 50\r\n14 39 43\r\n22 27 43\r\n9 11 0\r\n23 38 21\r\n13 32 23\r\n19 43 35\r\n27 29 15\r\n6 31 8\r\n19 20 35\r\n36 45 22\r\n20 26 34\r\n13 49 42\r\n13 37 40\r\n37 45 7\r\n16 41 19\r\n27 48 15\r\n15 41 8\r\n33 45 37\r\n6 33 45\r\n10 18 4\r\n12 35 27\r\n15 42 37\r\n25 28 50\r\n19 46 28\r\n7 19 12\r\n12 44 13\r\n1 12 21\r\n7 36 11\r\n19 29 21\r\n6 33 14\r\n32 41 44\r\n30 46 30\r\n1 47 30\r\n14 43 31\r\n18 37 27\r\n11 50 44\r\n26 26 7\r\n24 31 9\r\n9 13 5\r\n29 47 12\r\n6 17 3\r\n3 35 29\r\n29 41 42\r\n5 27 35\r\n14 45 3\r\n27 31 37\r\n20 33 43\r\n18 22 7\r\n12 35 44\r\n10 24 28\r\n', 'output': ['6751']}, {'input': '50 50 50\r\n28 29 9\r\n33 43 30\r\n12 34 3\r\n9 12 26\r\n24 39 10\r\n12 47 35\r\n29 41 47\r\n43 44 49\r\n19 37 36\r\n11 18 46\r\n19 42 20\r\n9 40 47\r\n18 34 22\r\n11 20 44\r\n5 31 44\r\n29 40 0\r\n1 26 19\r\n7 50 4\r\n14 34 48\r\n43 48 21\r\n12 49 23\r\n6 40 47\r\n22 37 50\r\n39 48 29\r\n12 34 13\r\n5 10 25\r\n30 45 46\r\n26 32 29\r\n2 4 23\r\n7 39 19\r\n22 49 42\r\n11 29 31\r\n23 50 29\r\n12 32 47\r\n4 13 18\r\n24 46 20\r\n33 34 44\r\n24 35 41\r\n39 50 47\r\n14 24 49\r\n25 44 28\r\n23 23 42\r\n32 44 40\r\n25 42 3\r\n25 31 6\r\n35 47 18\r\n22 49 2\r\n38 43 23\r\n1 27 16\r\n19 23 43\r\n', 'output': ['1786']}, {'input': '50 50 50\r\n6 28 36\r\n12 22 44\r\n12 39 7\r\n19 50 20\r\n27 43 35\r\n6 12 38\r\n2 6 20\r\n15 24 15\r\n38 43 8\r\n21 22 49\r\n15 21 4\r\n20 20 8\r\n25 42 37\r\n22 40 34\r\n43 43 17\r\n17 21 22\r\n35 41 34\r\n10 41 2\r\n8 29 17\r\n9 24 38\r\n14 31 24\r\n2 10 32\r\n6 20 2\r\n41 42 11\r\n20 22 49\r\n2 7 40\r\n16 18 48\r\n8 10 4\r\n31 40 30\r\n4 7 16\r\n19 39 42\r\n1 8 6\r\n37 42 17\r\n11 34 43\r\n25 29 36\r\n6 35 8\r\n12 15 42\r\n14 35 48\r\n33 48 43\r\n34 41 38\r\n4 18 50\r\n10 22 23\r\n7 15 13\r\n24 40 35\r\n23 27 36\r\n9 50 19\r\n24 30 29\r\n8 10 44\r\n26 30 50\r\n5 23 19\r\n', 'output': ['2979']}, {'input': '20 50 20\r\n3 9 4\r\n4 7 11\r\n9 14 31\r\n1 6 17\r\n5 13 33\r\n17 19 11\r\n13 14 10\r\n4 12 16\r\n8 19 46\r\n8 19 7\r\n11 20 32\r\n3 18 39\r\n1 12 31\r\n4 16 15\r\n2 15 38\r\n1 2 33\r\n2 11 25\r\n7 14 17\r\n3 14 45\r\n15 18 50\r\n', 'output': ['2204']}, {'input': '3 3 3\r\n1 1 1\r\n2 2 3\r\n3 3 2\r\n', 'output': ['14']}]
[{'input': '4 10 2\r\n2 3 8\r\n3 4 7\r\n', 'output': ['262']}, {'input': '50 50 50\r\n7 47 45\r\n22 24 8\r\n31 48 31\r\n36 47 13\r\n7 25 19\r\n2 2 17\r\n34 40 14\r\n27 33 50\r\n31 45 35\r\n4 7 4\r\n27 30 27\r\n4 41 27\r\n34 41 15\r\n2 12 17\r\n2 3 19\r\n25 47 47\r\n6 43 50\r\n4 47 23\r\n5 38 30\r\n12 43 18\r\n8 38 28\r\n6 11 13\r\n23 35 41\r\n2 39 41\r\n27 30 1\r\n28 49 46\r\n15 39 29\r\n18 29 22\r\n37 39 33\r\n7 45 40\r\n23 49 19\r\n8 12 46\r\n21 48 26\r\n22 45 27\r\n9 35 50\r\n10 43 5\r\n13 29 22\r\n7 36 12\r\n18 37 34\r\n17 18 3\r\n17 27 4\r\n44 47 39\r\n6 10 34\r\n31 48 1\r\n32 45 33\r\n39 41 43\r\n5 40 4\r\n8 50 11\r\n1 45 42\r\n30 35 31\r\n', 'output': ['2960']}, {'input': '20 20 50\r\n1 3 9\r\n2 20 19\r\n2 5 3\r\n2 8 17\r\n1 19 16\r\n1 19 1\r\n17 19 13\r\n2 6 6\r\n9 12 14\r\n15 15 3\r\n6 13 7\r\n11 17 6\r\n12 15 15\r\n4 16 5\r\n8 13 4\r\n6 12 6\r\n10 13 1\r\n2 20 15\r\n9 16 11\r\n1 13 16\r\n2 12 17\r\n13 17 13\r\n17 18 9\r\n5 6 11\r\n5 16 6\r\n3 16 0\r\n2 10 3\r\n2 17 6\r\n6 9 4\r\n4 11 2\r\n5 20 17\r\n5 20 9\r\n7 20 15\r\n5 11 20\r\n11 15 12\r\n6 18 8\r\n9 16 4\r\n2 17 14\r\n4 8 11\r\n8 15 8\r\n15 18 20\r\n7 14 15\r\n5 8 14\r\n11 13 20\r\n16 17 15\r\n1 14 13\r\n6 10 11\r\n8 19 19\r\n8 20 17\r\n3 19 2\r\n', 'output': ['86']}, {'input': '50 50 50\r\n15 20 50\r\n11 36 39\r\n1 7 23\r\n11 25 16\r\n2 8 46\r\n44 47 5\r\n7 15 20\r\n6 35 23\r\n21 31 47\r\n14 42 3\r\n22 44 25\r\n7 12 15\r\n5 50 13\r\n29 29 38\r\n4 35 17\r\n1 23 37\r\n22 32 30\r\n17 25 21\r\n17 40 47\r\n5 31 8\r\n46 50 10\r\n21 45 32\r\n7 47 48\r\n9 48 17\r\n4 46 43\r\n20 42 19\r\n2 15 28\r\n31 34 48\r\n9 22 11\r\n4 38 16\r\n31 49 4\r\n14 34 14\r\n41 49 28\r\n6 38 41\r\n10 38 8\r\n16 26 26\r\n24 36 37\r\n9 17 37\r\n37 41 32\r\n19 39 47\r\n10 33 0\r\n20 46 41\r\n12 45 22\r\n26 34 5\r\n27 34 40\r\n23 33 10\r\n6 17 23\r\n3 9 20\r\n1 2 49\r\n20 39 19\r\n', 'output': ['2327']}, {'input': '50 50 50\r\n28 29 9\r\n33 43 30\r\n12 34 3\r\n9 12 26\r\n24 39 10\r\n12 47 35\r\n29 41 47\r\n43 44 49\r\n19 37 36\r\n11 18 46\r\n19 42 20\r\n9 40 47\r\n18 34 22\r\n11 20 44\r\n5 31 44\r\n29 40 0\r\n1 26 19\r\n7 50 4\r\n14 34 48\r\n43 48 21\r\n12 49 23\r\n6 40 47\r\n22 37 50\r\n39 48 29\r\n12 34 13\r\n5 10 25\r\n30 45 46\r\n26 32 29\r\n2 4 23\r\n7 39 19\r\n22 49 42\r\n11 29 31\r\n23 50 29\r\n12 32 47\r\n4 13 18\r\n24 46 20\r\n33 34 44\r\n24 35 41\r\n39 50 47\r\n14 24 49\r\n25 44 28\r\n23 23 42\r\n32 44 40\r\n25 42 3\r\n25 31 6\r\n35 47 18\r\n22 49 2\r\n38 43 23\r\n1 27 16\r\n19 23 43\r\n', 'output': ['1786']}]
[{'input': '4 10 2\r\n2 3 8\r\n3 4 7\r\n', 'output': ['262']}, {'input': '50 50 50\r\n24 50 22\r\n26 27 22\r\n22 27 43\r\n16 48 24\r\n27 46 50\r\n2 34 22\r\n1 4 21\r\n33 48 7\r\n5 14 21\r\n37 43 19\r\n8 39 32\r\n20 21 4\r\n4 34 36\r\n12 23 29\r\n32 47 42\r\n11 32 31\r\n4 49 13\r\n3 16 35\r\n13 44 37\r\n17 29 45\r\n16 23 10\r\n25 33 5\r\n1 44 6\r\n28 49 30\r\n31 47 4\r\n13 44 11\r\n17 22 45\r\n24 40 37\r\n11 45 48\r\n4 26 17\r\n32 50 30\r\n2 10 23\r\n29 48 31\r\n30 50 19\r\n16 47 11\r\n5 48 14\r\n33 41 48\r\n8 27 34\r\n9 32 27\r\n45 47 5\r\n2 50 49\r\n8 48 31\r\n27 47 29\r\n27 46 39\r\n12 28 34\r\n4 25 5\r\n43 50 10\r\n13 19 16\r\n9 46 0\r\n41 45 16\r\n', 'output': ['498']}, {'input': '50 50 50\r\n17 40 12\r\n33 36 47\r\n8 43 35\r\n25 29 42\r\n18 36 6\r\n25 35 18\r\n36 48 47\r\n17 40 13\r\n20 27 37\r\n32 32 28\r\n17 20 13\r\n4 14 6\r\n13 18 47\r\n18 45 28\r\n3 50 45\r\n6 6 6\r\n3 25 36\r\n28 48 42\r\n14 34 32\r\n28 41 35\r\n29 35 25\r\n25 48 24\r\n32 40 40\r\n18 38 44\r\n6 16 2\r\n1 36 7\r\n14 48 2\r\n18 29 40\r\n11 16 37\r\n8 40 19\r\n12 16 44\r\n44 46 21\r\n19 24 26\r\n24 45 44\r\n22 22 15\r\n6 15 32\r\n19 42 7\r\n21 33 20\r\n1 13 26\r\n16 27 40\r\n46 48 30\r\n21 39 1\r\n1 9 32\r\n14 34 20\r\n35 38 11\r\n19 47 23\r\n13 38 15\r\n28 29 28\r\n7 20 40\r\n2 21 46\r\n', 'output': ['4384']}, {'input': '50 20 20\r\n22 39 19\r\n23 37 18\r\n16 38 9\r\n30 49 15\r\n14 31 5\r\n1 29 16\r\n10 46 9\r\n27 40 16\r\n3 42 1\r\n33 38 6\r\n18 40 6\r\n3 34 5\r\n8 23 14\r\n5 9 14\r\n4 34 8\r\n1 48 16\r\n4 15 18\r\n9 46 18\r\n18 29 14\r\n25 47 20\r\n', 'output': ['1951']}, {'input': '20 20 50\r\n10 17 9\r\n5 10 5\r\n9 18 5\r\n4 19 8\r\n10 18 4\r\n5 19 2\r\n9 11 0\r\n3 9 9\r\n11 12 6\r\n7 9 7\r\n6 19 15\r\n7 12 10\r\n5 17 18\r\n4 9 14\r\n11 11 9\r\n2 20 8\r\n2 16 9\r\n5 16 1\r\n1 2 5\r\n6 9 1\r\n8 13 15\r\n6 15 18\r\n7 13 7\r\n13 18 11\r\n1 16 17\r\n16 20 17\r\n2 19 10\r\n15 18 0\r\n2 14 11\r\n1 3 11\r\n2 3 3\r\n2 16 10\r\n6 20 7\r\n3 17 2\r\n8 13 11\r\n7 11 13\r\n1 13 14\r\n5 16 4\r\n2 3 14\r\n2 5 4\r\n4 10 6\r\n10 17 20\r\n9 13 4\r\n1 5 20\r\n7 13 6\r\n16 20 9\r\n9 16 16\r\n5 12 7\r\n2 18 14\r\n9 13 19\r\n', 'output': ['102']}]
[{'input': '50 50 50\r\n15 20 50\r\n11 36 39\r\n1 7 23\r\n11 25 16\r\n2 8 46\r\n44 47 5\r\n7 15 20\r\n6 35 23\r\n21 31 47\r\n14 42 3\r\n22 44 25\r\n7 12 15\r\n5 50 13\r\n29 29 38\r\n4 35 17\r\n1 23 37\r\n22 32 30\r\n17 25 21\r\n17 40 47\r\n5 31 8\r\n46 50 10\r\n21 45 32\r\n7 47 48\r\n9 48 17\r\n4 46 43\r\n20 42 19\r\n2 15 28\r\n31 34 48\r\n9 22 11\r\n4 38 16\r\n31 49 4\r\n14 34 14\r\n41 49 28\r\n6 38 41\r\n10 38 8\r\n16 26 26\r\n24 36 37\r\n9 17 37\r\n37 41 32\r\n19 39 47\r\n10 33 0\r\n20 46 41\r\n12 45 22\r\n26 34 5\r\n27 34 40\r\n23 33 10\r\n6 17 23\r\n3 9 20\r\n1 2 49\r\n20 39 19\r\n', 'output': ['2327']}, {'input': '50 50 50\r\n17 17 39\r\n11 13 9\r\n9 43 39\r\n9 35 13\r\n23 39 31\r\n21 43 21\r\n16 17 43\r\n2 47 30\r\n23 49 9\r\n22 47 7\r\n20 34 48\r\n12 49 20\r\n13 29 12\r\n3 29 17\r\n4 30 42\r\n37 40 28\r\n16 50 24\r\n31 43 40\r\n6 26 26\r\n22 43 28\r\n7 41 24\r\n33 35 8\r\n17 23 43\r\n11 49 25\r\n21 42 37\r\n34 36 23\r\n15 44 31\r\n7 7 14\r\n4 41 44\r\n13 16 16\r\n28 36 17\r\n19 29 48\r\n7 40 14\r\n7 32 39\r\n1 42 33\r\n9 25 21\r\n15 48 30\r\n1 45 1\r\n22 45 21\r\n1 22 4\r\n47 50 0\r\n16 19 8\r\n22 38 32\r\n24 32 1\r\n31 37 43\r\n16 36 25\r\n5 41 17\r\n42 45 49\r\n23 32 48\r\n21 43 21\r\n', 'output': ['94']}, {'input': '20 20 50\r\n10 17 9\r\n5 10 5\r\n9 18 5\r\n4 19 8\r\n10 18 4\r\n5 19 2\r\n9 11 0\r\n3 9 9\r\n11 12 6\r\n7 9 7\r\n6 19 15\r\n7 12 10\r\n5 17 18\r\n4 9 14\r\n11 11 9\r\n2 20 8\r\n2 16 9\r\n5 16 1\r\n1 2 5\r\n6 9 1\r\n8 13 15\r\n6 15 18\r\n7 13 7\r\n13 18 11\r\n1 16 17\r\n16 20 17\r\n2 19 10\r\n15 18 0\r\n2 14 11\r\n1 3 11\r\n2 3 3\r\n2 16 10\r\n6 20 7\r\n3 17 2\r\n8 13 11\r\n7 11 13\r\n1 13 14\r\n5 16 4\r\n2 3 14\r\n2 5 4\r\n4 10 6\r\n10 17 20\r\n9 13 4\r\n1 5 20\r\n7 13 6\r\n16 20 9\r\n9 16 16\r\n5 12 7\r\n2 18 14\r\n9 13 19\r\n', 'output': ['102']}, {'input': '20 20 50\r\n1 13 18\r\n1 18 9\r\n4 6 13\r\n2 7 17\r\n8 8 7\r\n5 11 17\r\n8 18 5\r\n8 18 11\r\n1 9 9\r\n6 15 12\r\n15 17 3\r\n2 15 10\r\n11 16 19\r\n2 17 13\r\n8 16 15\r\n6 7 0\r\n4 8 14\r\n5 8 0\r\n10 20 13\r\n6 12 3\r\n11 16 19\r\n4 14 20\r\n1 17 11\r\n7 15 7\r\n11 17 8\r\n6 17 7\r\n6 16 17\r\n5 16 3\r\n17 18 2\r\n6 14 14\r\n12 16 2\r\n2 11 16\r\n2 7 11\r\n1 14 4\r\n6 13 1\r\n1 17 10\r\n8 16 19\r\n9 13 16\r\n13 14 3\r\n8 19 12\r\n9 16 16\r\n5 10 17\r\n5 18 12\r\n1 17 15\r\n3 7 0\r\n17 18 4\r\n4 19 16\r\n6 18 9\r\n2 19 11\r\n1 4 11\r\n', 'output': ['347']}, {'input': '50 50 50\r\n17 40 12\r\n33 36 47\r\n8 43 35\r\n25 29 42\r\n18 36 6\r\n25 35 18\r\n36 48 47\r\n17 40 13\r\n20 27 37\r\n32 32 28\r\n17 20 13\r\n4 14 6\r\n13 18 47\r\n18 45 28\r\n3 50 45\r\n6 6 6\r\n3 25 36\r\n28 48 42\r\n14 34 32\r\n28 41 35\r\n29 35 25\r\n25 48 24\r\n32 40 40\r\n18 38 44\r\n6 16 2\r\n1 36 7\r\n14 48 2\r\n18 29 40\r\n11 16 37\r\n8 40 19\r\n12 16 44\r\n44 46 21\r\n19 24 26\r\n24 45 44\r\n22 22 15\r\n6 15 32\r\n19 42 7\r\n21 33 20\r\n1 13 26\r\n16 27 40\r\n46 48 30\r\n21 39 1\r\n1 9 32\r\n14 34 20\r\n35 38 11\r\n19 47 23\r\n13 38 15\r\n28 29 28\r\n7 20 40\r\n2 21 46\r\n', 'output': ['4384']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
175
100
100
100
["2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4", "5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3"]
In first line given a sequence of 24 integers ai (1 ≤ ai ≤ 6), where ai denotes color of i-th square. There are exactly 4 occurrences of all colors in this sequence.
881a820aa8184d9553278a0002a3b7c4
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include <memory.h> #include <set> #include <map> #include <string> using namespace std; int a[25]; int tu[8]; int b[6][8] = { { 22, 21, 18, 17, 5, 6, 14, 13 }, { 3, 4, 17, 19, 10, 9, 16, 14 }, { 7, 8, 19, 20, 23, 24, 15, 16 }, { 1, 3, 5, 7, 9, 11, 24, 22 }, { 4, 2, 21, 23, 12,10, 8, 6 }, { 2, 1, 13, 15, 11, 12, 20, 18 } }; bool res (int tmp[]){ for (int i = 2; i <=24; ++i){ if ((i - 1) % 4 == 0) continue; if (tmp[i] != tmp[i - 1]) return false; } return true; } void rot(int tmp[],int f ,bool d){ if (d){ int j = 0; for (int i = 2; i < 8; ++i){ tu[j] = tmp[i]; ++j; } tu[6] = tmp[0]; tu[7] = tmp[1]; } else{ int j = 0; for (int i = 2; i < 8; ++i){ tu[i] = tmp[j]; ++j; } tu[0] = tmp[7]; tu[1] = tmp[6]; } } bool can(int f){ int tmp[8]; for (int i= 0; i < 8; ++i){ tmp[i] = b[f][i]; } int tmp_2[25]; for (int i = 1; i <= 24; ++i){ tmp_2[i] = a[i]; } rot(tmp, f, 0); for (int i = 0; i < 8; ++i){ tmp_2[b[f][i]] = a[tu[i]]; } if (res(tmp_2)) return true; rot(tmp,f,1); for (int i = 0; i < 8; ++i){ tmp_2[b[f][i]] = a[tu[i]]; } if (res(tmp_2)) return true; return 0; } int main() { // freopen("Text.txt", "r", stdin); for (int i = 1; i <= 24; ++i){ cin >> a[i]; } for (int i = 0; i < 6; ++i){ if (can(i)){ cout << "YES"; return 0; } } cout << "NO"; return 0; }
["NO", "YES"]
C++
NoteIn first test case cube looks like this: In second test case cube looks like this: It's possible to solve cube by rotating face with squares with numbers 13, 14, 15, 16.
Print «YES» (without quotes) if it's possible to solve cube using one rotation and «NO» (without quotes) otherwise.
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation of one face of the cube in any direction.To check her answers she wants to use a program which will for some state of cube tell if it's possible to solve it using one rotation, described above.Cube is called solved if for each face of cube all squares on it has the same color.https://en.wikipedia.org/wiki/Rubik's_Cube
[{"input": "2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4\r\n", "output": ["NO", "no"]}, {"input": "5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3\r\n", "output": ["YES", "yes"]}, {"input": "2 6 3 3 5 5 2 6 1 1 6 4 4 4 2 4 6 5 3 1 2 5 3 1\r\n", "output": ["NO", "no"]}, {"input": "3 4 2 3 5 5 6 6 4 5 4 6 5 1 1 1 6 2 1 3 3 2 4 2\r\n", "output": ["NO", "no"]}, {"input": "5 5 2 5 3 3 2 6 6 4 2 4 6 1 4 3 1 6 2 1 3 4 5 1\r\n", "output": ["NO", "no"]}, {"input": "6 6 1 2 6 1 1 3 5 4 3 4 3 5 5 2 4 4 6 2 1 5 3 2\r\n", "output": ["NO", "no"]}, {"input": "2 2 1 1 5 5 5 5 3 3 4 4 1 4 1 4 2 3 2 3 6 6 6 6\r\n", "output": ["YES", "yes"]}, {"input": "1 1 1 1 5 5 3 3 4 4 4 4 3 3 2 2 6 6 5 5 2 2 6 6\r\n", "output": ["YES", "yes"]}, {"input": "1 1 1 1 3 3 3 3 5 5 5 5 2 2 2 2 4 4 4 4 6 6 6 6\r\n", "output": ["NO", "no"]}, {"input": "5 4 5 4 4 6 4 6 6 3 6 3 1 1 1 1 2 2 2 2 5 3 5 3\r\n", "output": ["YES", "yes"]}, {"input": "3 3 5 5 2 2 2 2 6 6 4 4 6 3 6 3 4 5 4 5 1 1 1 1\r\n", "output": ["YES", "yes"]}, {"input": "6 6 6 6 2 2 5 5 1 1 1 1 4 4 2 2 5 5 3 3 3 3 4 4\r\n", "output": ["YES", "yes"]}, {"input": "4 6 4 6 6 1 6 1 1 3 1 3 2 2 2 2 5 5 5 5 4 3 4 3\r\n", "output": ["YES", "yes"]}, {"input": "6 6 2 2 3 3 3 3 4 4 5 5 4 6 4 6 5 2 5 2 1 1 1 1\r\n", "output": ["YES", "yes"]}, {"input": "3 3 3 3 4 4 5 5 1 1 1 1 2 2 4 4 5 5 6 6 6 6 2 2\r\n", "output": ["YES", "yes"]}, {"input": "2 5 2 5 4 2 4 2 1 4 1 4 6 6 6 6 3 3 3 3 1 5 1 5\r\n", "output": ["YES", "yes"]}, {"input": "4 4 3 3 5 5 5 5 1 1 6 6 3 6 3 6 4 1 4 1 2 2 2 2\r\n", "output": ["YES", "yes"]}, {"input": "5 5 5 5 6 6 2 2 3 3 3 3 2 2 1 1 4 4 6 6 1 1 4 4\r\n", "output": ["YES", "yes"]}, {"input": "1 4 3 4 2 6 5 2 1 5 1 6 3 4 3 6 5 5 1 3 2 6 4 2\r\n", "output": ["NO", "no"]}, {"input": "4 4 2 5 3 2 4 2 5 3 6 4 6 5 1 3 1 5 6 3 1 1 6 2\r\n", "output": ["NO", "no"]}, {"input": "4 5 3 4 5 5 6 3 2 5 1 6 2 1 6 3 1 4 2 3 2 6 1 4\r\n", "output": ["NO", "no"]}, {"input": "3 3 2 3 6 4 4 4 1 2 1 3 2 5 6 6 1 2 6 5 4 5 1 5\r\n", "output": ["NO", "no"]}, {"input": "5 6 1 1 4 5 6 5 4 6 2 1 4 2 6 5 3 2 3 2 3 1 3 4\r\n", "output": ["NO", "no"]}, {"input": "4 4 4 5 2 3 4 1 3 3 1 5 6 5 6 6 1 3 6 2 5 2 1 2\r\n", "output": ["NO", "no"]}, {"input": "3 2 5 6 1 4 3 4 6 5 4 3 2 3 2 2 1 4 1 1 6 5 6 5\r\n", "output": ["NO", "no"]}, {"input": "5 4 6 2 5 6 4 1 6 3 3 1 3 2 4 1 1 6 2 3 5 2 4 5\r\n", "output": ["NO", "no"]}, {"input": "6 6 3 1 5 6 5 3 2 5 3 1 2 4 1 6 4 5 2 2 4 1 3 4\r\n", "output": ["NO", "no"]}, {"input": "6 5 4 1 6 5 2 3 3 5 3 6 4 2 6 5 4 2 1 1 4 1 3 2\r\n", "output": ["NO", "no"]}, {"input": "1 3 5 6 4 4 4 3 5 2 2 2 3 1 5 6 3 4 6 5 1 2 1 6\r\n", "output": ["NO", "no"]}, {"input": "3 6 5 4 4 6 1 4 3 2 5 2 1 2 6 2 5 4 1 3 1 6 5 3\r\n", "output": ["NO", "no"]}, {"input": "5 2 6 1 5 3 5 3 1 1 3 6 6 2 4 2 5 4 4 2 1 3 4 6\r\n", "output": ["NO", "no"]}, {"input": "2 5 6 2 3 6 5 6 2 3 1 3 6 4 5 4 1 1 1 5 3 4 4 2\r\n", "output": ["NO", "no"]}, {"input": "4 5 4 4 3 3 1 2 3 1 1 5 2 2 5 6 6 4 3 2 6 5 1 6\r\n", "output": ["NO", "no"]}, {"input": "5 2 5 2 3 5 3 5 4 3 4 3 6 6 6 6 1 1 1 1 4 2 4 2\r\n", "output": ["YES", "yes"]}, {"input": "2 4 2 4 4 5 4 5 5 1 5 1 3 3 3 3 6 6 6 6 2 1 2 1\r\n", "output": ["YES", "yes"]}, {"input": "3 5 3 5 5 1 5 1 1 4 1 4 6 6 6 6 2 2 2 2 3 4 3 4\r\n", "output": ["YES", "yes"]}, {"input": "2 1 2 1 4 2 4 2 6 4 6 4 5 5 5 5 3 3 3 3 6 1 6 1\r\n", "output": ["YES", "yes"]}, {"input": "4 4 2 2 1 1 1 1 5 5 6 6 2 6 2 6 4 5 4 5 3 3 3 3\r\n", "output": ["YES", "yes"]}, {"input": "1 1 2 2 4 4 4 4 5 5 6 6 5 1 5 1 6 2 6 2 3 3 3 3\r\n", "output": ["YES", "yes"]}, {"input": "2 2 6 6 4 4 4 4 1 1 5 5 1 2 1 2 5 6 5 6 3 3 3 3\r\n", "output": ["YES", "yes"]}, {"input": "2 2 3 3 6 6 6 6 4 4 1 1 3 1 3 1 2 4 2 4 5 5 5 5\r\n", "output": ["YES", "yes"]}, {"input": "6 6 6 6 4 4 3 3 5 5 5 5 3 3 1 1 2 2 4 4 1 1 2 2\r\n", "output": ["YES", "yes"]}, {"input": "2 2 2 2 4 4 5 5 3 3 3 3 6 6 4 4 5 5 1 1 1 1 6 6\r\n", "output": ["YES", "yes"]}, {"input": "1 1 1 1 5 5 6 6 3 3 3 3 4 4 5 5 6 6 2 2 2 2 4 4\r\n", "output": ["YES", "yes"]}, {"input": "4 4 4 4 2 2 3 3 1 1 1 1 3 3 6 6 5 5 2 2 6 6 5 5\r\n", "output": ["YES", "yes"]}, {"input": "1 1 1 1 2 2 3 3 6 6 6 6 5 5 4 4 3 3 2 2 4 4 5 5\r\n", "output": ["NO", "no"]}, {"input": "1 1 2 2 3 3 1 1 2 2 3 3 4 4 4 4 5 5 5 5 6 6 6 6\r\n", "output": ["NO", "no"]}, {"input": "5 5 5 5 1 1 2 2 6 6 6 6 4 4 3 3 3 3 4 4 2 2 1 1\r\n", "output": ["NO", "no"]}]
100
100
100
[{'input': '5 6 1 1 4 5 6 5 4 6 2 1 4 2 6 5 3 2 3 2 3 1 3 4\r\n', 'output': ['NO', 'no']}, {'input': '4 4 4 5 2 3 4 1 3 3 1 5 6 5 6 6 1 3 6 2 5 2 1 2\r\n', 'output': ['NO', 'no']}, {'input': '1 1 1 1 5 5 3 3 4 4 4 4 3 3 2 2 6 6 5 5 2 2 6 6\r\n', 'output': ['YES', 'yes']}, {'input': '4 6 4 6 6 1 6 1 1 3 1 3 2 2 2 2 5 5 5 5 4 3 4 3\r\n', 'output': ['YES', 'yes']}, {'input': '4 5 4 4 3 3 1 2 3 1 1 5 2 2 5 6 6 4 3 2 6 5 1 6\r\n', 'output': ['NO', 'no']}]
[{'input': '1 1 2 2 3 3 1 1 2 2 3 3 4 4 4 4 5 5 5 5 6 6 6 6\r\n', 'output': ['NO', 'no']}, {'input': '4 4 2 5 3 2 4 2 5 3 6 4 6 5 1 3 1 5 6 3 1 1 6 2\r\n', 'output': ['NO', 'no']}, {'input': '2 6 3 3 5 5 2 6 1 1 6 4 4 4 2 4 6 5 3 1 2 5 3 1\r\n', 'output': ['NO', 'no']}, {'input': '3 3 2 3 6 4 4 4 1 2 1 3 2 5 6 6 1 2 6 5 4 5 1 5\r\n', 'output': ['NO', 'no']}, {'input': '5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3\r\n', 'output': ['YES', 'yes']}]
[{'input': '4 4 2 5 3 2 4 2 5 3 6 4 6 5 1 3 1 5 6 3 1 1 6 2\r\n', 'output': ['NO', 'no']}, {'input': '3 3 3 3 4 4 5 5 1 1 1 1 2 2 4 4 5 5 6 6 6 6 2 2\r\n', 'output': ['YES', 'yes']}, {'input': '5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3\r\n', 'output': ['YES', 'yes']}, {'input': '2 5 2 5 4 2 4 2 1 4 1 4 6 6 6 6 3 3 3 3 1 5 1 5\r\n', 'output': ['YES', 'yes']}, {'input': '1 1 1 1 5 5 3 3 4 4 4 4 3 3 2 2 6 6 5 5 2 2 6 6\r\n', 'output': ['YES', 'yes']}]
[{'input': '4 4 3 3 5 5 5 5 1 1 6 6 3 6 3 6 4 1 4 1 2 2 2 2\r\n', 'output': ['YES', 'yes']}, {'input': '5 4 6 2 5 6 4 1 6 3 3 1 3 2 4 1 1 6 2 3 5 2 4 5\r\n', 'output': ['NO', 'no']}, {'input': '1 3 5 6 4 4 4 3 5 2 2 2 3 1 5 6 3 4 6 5 1 2 1 6\r\n', 'output': ['NO', 'no']}, {'input': '4 4 4 4 2 2 3 3 1 1 1 1 3 3 6 6 5 5 2 2 6 6 5 5\r\n', 'output': ['YES', 'yes']}, {'input': '3 6 5 4 4 6 1 4 3 2 5 2 1 2 6 2 5 4 1 3 1 6 5 3\r\n', 'output': ['NO', 'no']}]
[{'input': '3 3 3 3 4 4 5 5 1 1 1 1 2 2 4 4 5 5 6 6 6 6 2 2\r\n', 'output': ['YES', 'yes']}, {'input': '2 1 2 1 4 2 4 2 6 4 6 4 5 5 5 5 3 3 3 3 6 1 6 1\r\n', 'output': ['YES', 'yes']}, {'input': '6 6 2 2 3 3 3 3 4 4 5 5 4 6 4 6 5 2 5 2 1 1 1 1\r\n', 'output': ['YES', 'yes']}, {'input': '5 4 6 2 5 6 4 1 6 3 3 1 3 2 4 1 1 6 2 3 5 2 4 5\r\n', 'output': ['NO', 'no']}, {'input': '5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3\r\n', 'output': ['YES', 'yes']}]
100
100
100
100
100
97.87
97.87
100
97.87
97.87
96.67
96.67
100
96.67
96.67
176
100
98.296
97.336
["0 0 2 0 0 1", "2 3 4 5 6 6", "-1 0 2 0 0 1"]
The first input line contains 6 space-separated integers x1, y1, x2, y2, x3, y3 — coordinates of the triangle's vertices. All the coordinates are integer and don't exceed 100 in absolute value. It's guaranteed that the triangle is nondegenerate, i.e. its total area is not zero.
8324fa542297c21bda1a4aed0bd45a2d
#include<iostream> #include<cstdio> #include<cstdlib> using namespace std; int x[20]; int ck() { int i; int a,b,c,d; for (i=1;i<=6;++i) x[i+6]=x[i]; for (i=1;i<6;i+=2) { a=x[i]-x[i+2]; b=x[i+1]-x[i+3]; if (a==0&&b==0) return 0; } for (i=1;i<6;i+=2) { a=x[i]-x[i+2]; b=x[i+1]-x[i+3]; c=x[i+2]-x[i+4]; d=x[i+3]-x[i+5]; if (a*c+b*d==0) return 1; } return 0; } int main() { int i; for (i=1;i<=6;++i) scanf("%d",&x[i]); if (ck()) cout <<"RIGHT"<<endl; else { for (i=1;i<=6;++i) { x[i]--; if (ck()) {cout <<"ALMOST"<<endl;return 0;} x[i]+=2; if (ck()) {cout <<"ALMOST"<<endl;return 0;} x[i]--; } cout <<"NEITHER"<<endl; return 0; } return 0; }
["RIGHT", "NEITHER", "ALMOST"]
C++
null
If the given triangle is right-angled, output RIGHT, if it is almost right-angled, output ALMOST, and if it is neither of these, output NEITHER.
At a geometry lesson Bob learnt that a triangle is called right-angled if it is nondegenerate and one of its angles is right. Bob decided to draw such a triangle immediately: on a sheet of paper he drew three points with integer coordinates, and joined them with segments of straight lines, then he showed the triangle to Peter. Peter said that Bob's triangle is not right-angled, but is almost right-angled: the triangle itself is not right-angled, but it is possible to move one of the points exactly by distance 1 so, that all the coordinates remain integer, and the triangle become right-angled. Bob asks you to help him and find out if Peter tricks him. By the given coordinates of the triangle you should find out if it is right-angled, almost right-angled, or neither of these.
[{"input": "0 0 2 0 0 1\r\n", "output": ["RIGHT"]}, {"input": "2 3 4 5 6 6\r\n", "output": ["NEITHER"]}, {"input": "-1 0 2 0 0 1\r\n", "output": ["ALMOST"]}, {"input": "27 74 85 23 100 99\r\n", "output": ["NEITHER"]}, {"input": "-97 -19 17 62 30 -76\r\n", "output": ["NEITHER"]}, {"input": "28 -15 86 32 98 -41\r\n", "output": ["NEITHER"]}, {"input": "-66 24 8 -29 17 62\r\n", "output": ["NEITHER"]}, {"input": "-83 40 -80 52 -71 43\r\n", "output": ["NEITHER"]}, {"input": "-88 67 -62 37 -49 75\r\n", "output": ["NEITHER"]}, {"input": "58 45 6 22 13 79\r\n", "output": ["NEITHER"]}, {"input": "75 86 -82 89 -37 -35\r\n", "output": ["NEITHER"]}, {"input": "34 74 -2 -95 63 -33\r\n", "output": ["NEITHER"]}, {"input": "-7 63 78 74 -39 -30\r\n", "output": ["NEITHER"]}, {"input": "-49 -99 7 92 61 -28\r\n", "output": ["NEITHER"]}, {"input": "-90 90 87 -92 -40 -26\r\n", "output": ["NEITHER"]}, {"input": "-100 -100 100 -100 0 73\r\n", "output": ["NEITHER"]}, {"input": "39 22 94 25 69 -23\r\n", "output": ["NEITHER"]}, {"input": "100 100 -100 100 1 -73\r\n", "output": ["NEITHER"]}, {"input": "0 0 0 1 1 0\r\n", "output": ["RIGHT"]}, {"input": "-100 -100 100 100 -100 100\r\n", "output": ["RIGHT"]}, {"input": "29 83 35 35 74 65\r\n", "output": ["NEITHER"]}, {"input": "28 -15 86 32 -19 43\r\n", "output": ["RIGHT"]}, {"input": "-28 12 -97 67 -83 -57\r\n", "output": ["RIGHT"]}, {"input": "-83 40 -80 52 -79 39\r\n", "output": ["RIGHT"]}, {"input": "30 8 49 13 25 27\r\n", "output": ["RIGHT"]}, {"input": "23 6 63 -40 69 46\r\n", "output": ["RIGHT"]}, {"input": "49 -7 19 -76 26 3\r\n", "output": ["RIGHT"]}, {"input": "0 0 1 0 2 1\r\n", "output": ["ALMOST"]}, {"input": "0 0 1 0 3 1\r\n", "output": ["ALMOST"]}, {"input": "0 0 1 0 2 2\r\n", "output": ["ALMOST"]}, {"input": "0 0 1 0 4 1\r\n", "output": ["NEITHER"]}, {"input": "0 0 1 0 100 1\r\n", "output": ["NEITHER"]}, {"input": "60 4 90 -53 32 -12\r\n", "output": ["ALMOST"]}, {"input": "52 -34 -37 -63 23 54\r\n", "output": ["ALMOST"]}, {"input": "39 22 95 25 42 -33\r\n", "output": ["ALMOST"]}, {"input": "-10 -11 62 6 -12 -3\r\n", "output": ["ALMOST"]}, {"input": "22 -15 -24 77 -69 -60\r\n", "output": ["ALMOST"]}, {"input": "99 85 90 87 64 -20\r\n", "output": ["ALMOST"]}, {"input": "-50 -37 -93 -6 -80 -80\r\n", "output": ["ALMOST"]}, {"input": "4 -13 4 -49 -24 -13\r\n", "output": ["RIGHT"]}, {"input": "0 -3 -3 -10 4 -7\r\n", "output": ["NEITHER"]}, {"input": "-45 -87 -34 -79 -60 -62\r\n", "output": ["NEITHER"]}, {"input": "-67 49 89 -76 -37 87\r\n", "output": ["NEITHER"]}, {"input": "22 32 -33 -30 -18 68\r\n", "output": ["NEITHER"]}, {"input": "36 1 -17 -54 -19 55\r\n", "output": ["ALMOST"]}, {"input": "55 44 15 14 23 83\r\n", "output": ["NEITHER"]}, {"input": "-19 0 -89 -54 25 -57\r\n", "output": ["NEITHER"]}, {"input": "69 -45 1 11 56 -63\r\n", "output": ["NEITHER"]}, {"input": "72 68 56 72 33 -88\r\n", "output": ["RIGHT"]}, {"input": "59 86 74 -49 77 88\r\n", "output": ["RIGHT"]}, {"input": "-50 0 0 50 0 -50\r\n", "output": ["RIGHT"]}, {"input": "-50 0 0 50 0 -51\r\n", "output": ["ALMOST"]}, {"input": "-50 0 0 50 0 -49\r\n", "output": ["ALMOST"]}, {"input": "-50 0 0 50 1 -50\r\n", "output": ["ALMOST"]}, {"input": "-50 0 0 50 -1 -50\r\n", "output": ["ALMOST"]}, {"input": "-50 0 0 49 0 -50\r\n", "output": ["ALMOST"]}, {"input": "-50 0 0 51 0 -50\r\n", "output": ["ALMOST"]}, {"input": "-50 0 1 50 0 -50\r\n", "output": ["ALMOST"]}, {"input": "-50 0 -1 50 0 -50\r\n", "output": ["ALMOST"]}, {"input": "-50 1 0 50 0 -50\r\n", "output": ["ALMOST"]}, {"input": "-50 -1 0 50 0 -50\r\n", "output": ["ALMOST"]}, {"input": "-51 0 0 50 0 -50\r\n", "output": ["ALMOST"]}, {"input": "-49 0 0 50 0 -50\r\n", "output": ["ALMOST"]}]
100
100
100
[{'input': '-7 63 78 74 -39 -30\r\n', 'output': ['NEITHER']}, {'input': '-49 -99 7 92 61 -28\r\n', 'output': ['NEITHER']}, {'input': '30 8 49 13 25 27\r\n', 'output': ['RIGHT']}, {'input': '0 0 1 0 2 2\r\n', 'output': ['ALMOST']}, {'input': '-50 0 0 50 0 -49\r\n', 'output': ['ALMOST']}]
[{'input': '-50 0 -1 50 0 -50\r\n', 'output': ['ALMOST']}, {'input': '39 22 95 25 42 -33\r\n', 'output': ['ALMOST']}, {'input': '-67 49 89 -76 -37 87\r\n', 'output': ['NEITHER']}, {'input': '4 -13 4 -49 -24 -13\r\n', 'output': ['RIGHT']}, {'input': '0 0 1 0 100 1\r\n', 'output': ['NEITHER']}]
[{'input': '-45 -87 -34 -79 -60 -62\r\n', 'output': ['NEITHER']}, {'input': '-50 0 0 50 0 -50\r\n', 'output': ['RIGHT']}, {'input': '22 32 -33 -30 -18 68\r\n', 'output': ['NEITHER']}, {'input': '-67 49 89 -76 -37 87\r\n', 'output': ['NEITHER']}, {'input': '-50 0 0 50 -1 -50\r\n', 'output': ['ALMOST']}]
[{'input': '60 4 90 -53 32 -12\r\n', 'output': ['ALMOST']}, {'input': '0 0 1 0 3 1\r\n', 'output': ['ALMOST']}, {'input': '-19 0 -89 -54 25 -57\r\n', 'output': ['NEITHER']}, {'input': '-50 0 0 50 -1 -50\r\n', 'output': ['ALMOST']}, {'input': '-45 -87 -34 -79 -60 -62\r\n', 'output': ['NEITHER']}]
[{'input': '0 0 1 0 2 1\r\n', 'output': ['ALMOST']}, {'input': '27 74 85 23 100 99\r\n', 'output': ['NEITHER']}, {'input': '0 0 1 0 2 2\r\n', 'output': ['ALMOST']}, {'input': '-7 63 78 74 -39 -30\r\n', 'output': ['NEITHER']}, {'input': '0 0 1 0 3 1\r\n', 'output': ['ALMOST']}]
100
100
100
100
100
100
100
100
94.74
94.74
100
100
90.91
90.91
95.45
177
100
97.896
95.454
["1 1 1 1 1 1", "1 2 1 2 1 2"]
The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≤ ai ≤ 1000) — the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists.
382475475427f0e76c6b4ac6e7a02e21
#include <bits/stdc++.h> using namespace std; int a,b,c,d,e,f; int main() { cin >> a >> b >> c >> d >> e >> f; printf("%d\n",(a + b + c) * (a + b + c) - a * a - c * c - e * e); return 0; }
["6", "13"]
C++
NoteThis is what Gerald's hexagon looks like in the first sample:And that's what it looks like in the second sample:
Print a single integer — the number of triangles with the sides of one 1 centimeter, into which the hexagon is split.
Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to . Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it.He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles.
[{"input": "1 1 1 1 1 1\r\n", "output": ["6"]}, {"input": "1 2 1 2 1 2\r\n", "output": ["13"]}, {"input": "2 4 5 3 3 6\r\n", "output": ["83"]}, {"input": "45 19 48 18 46 21\r\n", "output": ["6099"]}, {"input": "66 6 65 6 66 5\r\n", "output": ["5832"]}, {"input": "7 5 4 8 4 5\r\n", "output": ["175"]}, {"input": "3 2 1 4 1 2\r\n", "output": ["25"]}, {"input": "7 1 7 3 5 3\r\n", "output": ["102"]}, {"input": "9 2 9 3 8 3\r\n", "output": ["174"]}, {"input": "1 6 1 5 2 5\r\n", "output": ["58"]}, {"input": "41 64 48 61 44 68\r\n", "output": ["17488"]}, {"input": "1 59 2 59 1 60\r\n", "output": ["3838"]}, {"input": "30 36 36 32 34 38\r\n", "output": ["7052"]}, {"input": "50 40 46 38 52 34\r\n", "output": ["11176"]}, {"input": "4 60 4 60 4 60\r\n", "output": ["4576"]}, {"input": "718 466 729 470 714 481\r\n", "output": ["2102808"]}, {"input": "131 425 143 461 95 473\r\n", "output": ["441966"]}, {"input": "125 7 128 8 124 11\r\n", "output": ["20215"]}, {"input": "677 303 685 288 692 296\r\n", "output": ["1365807"]}, {"input": "1 577 7 576 2 582\r\n", "output": ["342171"]}, {"input": "1000 1000 1000 1000 1000 1000\r\n", "output": ["6000000"]}, {"input": "1 1 1000 1 1 1000\r\n", "output": ["4002"]}, {"input": "1000 1000 1 1000 1000 1\r\n", "output": ["2004000"]}, {"input": "1000 1 1000 999 2 999\r\n", "output": ["2003997"]}, {"input": "1 1000 1 1 1000 1\r\n", "output": ["4002"]}, {"input": "888 888 888 887 889 887\r\n", "output": ["4729487"]}]
100
100
100
[{'input': '1 1000 1 1 1000 1\r\n', 'output': ['4002']}, {'input': '7 1 7 3 5 3\r\n', 'output': ['102']}, {'input': '718 466 729 470 714 481\r\n', 'output': ['2102808']}, {'input': '1 6 1 5 2 5\r\n', 'output': ['58']}, {'input': '9 2 9 3 8 3\r\n', 'output': ['174']}]
[{'input': '888 888 888 887 889 887\r\n', 'output': ['4729487']}, {'input': '1000 1 1000 999 2 999\r\n', 'output': ['2003997']}, {'input': '7 1 7 3 5 3\r\n', 'output': ['102']}, {'input': '1000 1000 1 1000 1000 1\r\n', 'output': ['2004000']}, {'input': '1000 1000 1000 1000 1000 1000\r\n', 'output': ['6000000']}]
[{'input': '1000 1000 1 1000 1000 1\r\n', 'output': ['2004000']}, {'input': '45 19 48 18 46 21\r\n', 'output': ['6099']}, {'input': '2 4 5 3 3 6\r\n', 'output': ['83']}, {'input': '50 40 46 38 52 34\r\n', 'output': ['11176']}, {'input': '125 7 128 8 124 11\r\n', 'output': ['20215']}]
[{'input': '1 577 7 576 2 582\r\n', 'output': ['342171']}, {'input': '1 2 1 2 1 2\r\n', 'output': ['13']}, {'input': '718 466 729 470 714 481\r\n', 'output': ['2102808']}, {'input': '3 2 1 4 1 2\r\n', 'output': ['25']}, {'input': '2 4 5 3 3 6\r\n', 'output': ['83']}]
[{'input': '1 1000 1 1 1000 1\r\n', 'output': ['4002']}, {'input': '45 19 48 18 46 21\r\n', 'output': ['6099']}, {'input': '50 40 46 38 52 34\r\n', 'output': ['11176']}, {'input': '7 5 4 8 4 5\r\n', 'output': ['175']}, {'input': '125 7 128 8 124 11\r\n', 'output': ['20215']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
178
100
100
100
["7", "8", "9"]
The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^9$$$).
5551742f6ab39fdac3930d866f439e3e
#include <bits/stdc++.h> using namespace std; long long n,dem=0; int main() {cin>>n; cout<<n/2+1; }
["4", "5", "5"]
C++
NoteIn the first sample, there are following possible weights of splits of $$$7$$$:Weight 1: [$$$\textbf 7$$$] Weight 2: [$$$\textbf 3$$$, $$$\textbf 3$$$, 1] Weight 3: [$$$\textbf 2$$$, $$$\textbf 2$$$, $$$\textbf 2$$$, 1] Weight 7: [$$$\textbf 1$$$, $$$\textbf 1$$$, $$$\textbf 1$$$, $$$\textbf 1$$$, $$$\textbf 1$$$, $$$\textbf 1$$$, $$$\textbf 1$$$]
Output one integer — the answer to the problem.
Let's define a split of $$$n$$$ as a nonincreasing sequence of positive integers, the sum of which is $$$n$$$. For example, the following sequences are splits of $$$8$$$: $$$[4, 4]$$$, $$$[3, 3, 2]$$$, $$$[2, 2, 1, 1, 1, 1]$$$, $$$[5, 2, 1]$$$.The following sequences aren't splits of $$$8$$$: $$$[1, 7]$$$, $$$[5, 4]$$$, $$$[11, -3]$$$, $$$[1, 1, 4, 1, 1]$$$.The weight of a split is the number of elements in the split that are equal to the first element. For example, the weight of the split $$$[1, 1, 1, 1, 1]$$$ is $$$5$$$, the weight of the split $$$[5, 5, 3, 3, 3]$$$ is $$$2$$$ and the weight of the split $$$[9]$$$ equals $$$1$$$.For a given $$$n$$$, find out the number of different weights of its splits.
[{"input": "7\r\n", "output": ["4"]}, {"input": "8\r\n", "output": ["5"]}, {"input": "9\r\n", "output": ["5"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "286\r\n", "output": ["144"]}, {"input": "48\r\n", "output": ["25"]}, {"input": "941\r\n", "output": ["471"]}, {"input": "45154\r\n", "output": ["22578"]}, {"input": "60324\r\n", "output": ["30163"]}, {"input": "91840\r\n", "output": ["45921"]}, {"input": "41909\r\n", "output": ["20955"]}, {"input": "58288\r\n", "output": ["29145"]}, {"input": "91641\r\n", "output": ["45821"]}, {"input": "62258\r\n", "output": ["31130"]}, {"input": "79811\r\n", "output": ["39906"]}, {"input": "88740\r\n", "output": ["44371"]}, {"input": "12351\r\n", "output": ["6176"]}, {"input": "1960\r\n", "output": ["981"]}, {"input": "29239\r\n", "output": ["14620"]}, {"input": "85801\r\n", "output": ["42901"]}, {"input": "43255\r\n", "output": ["21628"]}, {"input": "13439\r\n", "output": ["6720"]}, {"input": "35668\r\n", "output": ["17835"]}, {"input": "19122\r\n", "output": ["9562"]}, {"input": "60169\r\n", "output": ["30085"]}, {"input": "50588\r\n", "output": ["25295"]}, {"input": "2467\r\n", "output": ["1234"]}, {"input": "39315\r\n", "output": ["19658"]}, {"input": "29950\r\n", "output": ["14976"]}, {"input": "17286\r\n", "output": ["8644"]}, {"input": "7359066\r\n", "output": ["3679534"]}, {"input": "1016391\r\n", "output": ["508196"]}, {"input": "7928871\r\n", "output": ["3964436"]}, {"input": "3968891\r\n", "output": ["1984446"]}, {"input": "2636452\r\n", "output": ["1318227"]}, {"input": "5076901\r\n", "output": ["2538451"]}, {"input": "9870265\r\n", "output": ["4935133"]}, {"input": "2453786\r\n", "output": ["1226894"]}, {"input": "7263670\r\n", "output": ["3631836"]}, {"input": "1890845\r\n", "output": ["945423"]}, {"input": "574128507\r\n", "output": ["287064254"]}, {"input": "648476655\r\n", "output": ["324238328"]}, {"input": "97349542\r\n", "output": ["48674772"]}, {"input": "716489761\r\n", "output": ["358244881"]}, {"input": "858771038\r\n", "output": ["429385520"]}, {"input": "520778784\r\n", "output": ["260389393"]}, {"input": "439004204\r\n", "output": ["219502103"]}, {"input": "589992198\r\n", "output": ["294996100"]}, {"input": "371106544\r\n", "output": ["185553273"]}, {"input": "894241590\r\n", "output": ["447120796"]}, {"input": "123957268\r\n", "output": ["61978635"]}, {"input": "234149297\r\n", "output": ["117074649"]}, {"input": "789954052\r\n", "output": ["394977027"]}, {"input": "667978920\r\n", "output": ["333989461"]}, {"input": "154647261\r\n", "output": ["77323631"]}, {"input": "751453521\r\n", "output": ["375726761"]}, {"input": "848862308\r\n", "output": ["424431155"]}, {"input": "323926781\r\n", "output": ["161963391"]}, {"input": "576768825\r\n", "output": ["288384413"]}, {"input": "31293802\r\n", "output": ["15646902"]}, {"input": "2\r\n", "output": ["2"]}, {"input": "1000000000\r\n", "output": ["500000001"]}, {"input": "3\r\n", "output": ["2"]}]
100
100
100
[{'input': '123957268\r\n', 'output': ['61978635']}, {'input': '2453786\r\n', 'output': ['1226894']}, {'input': '58288\r\n', 'output': ['29145']}, {'input': '286\r\n', 'output': ['144']}, {'input': '576768825\r\n', 'output': ['288384413']}]
[{'input': '62258\r\n', 'output': ['31130']}, {'input': '7\r\n', 'output': ['4']}, {'input': '7359066\r\n', 'output': ['3679534']}, {'input': '7928871\r\n', 'output': ['3964436']}, {'input': '123957268\r\n', 'output': ['61978635']}]
[{'input': '35668\r\n', 'output': ['17835']}, {'input': '48\r\n', 'output': ['25']}, {'input': '751453521\r\n', 'output': ['375726761']}, {'input': '589992198\r\n', 'output': ['294996100']}, {'input': '439004204\r\n', 'output': ['219502103']}]
[{'input': '7\r\n', 'output': ['4']}, {'input': '45154\r\n', 'output': ['22578']}, {'input': '7263670\r\n', 'output': ['3631836']}, {'input': '79811\r\n', 'output': ['39906']}, {'input': '789954052\r\n', 'output': ['394977027']}]
[{'input': '234149297\r\n', 'output': ['117074649']}, {'input': '35668\r\n', 'output': ['17835']}, {'input': '2453786\r\n', 'output': ['1226894']}, {'input': '2636452\r\n', 'output': ['1318227']}, {'input': '5076901\r\n', 'output': ['2538451']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
179
100
100
100
["4", "9"]
The only line contains a single integer x (1 ≤ x ≤ 100) — the required sharpness of the matrix.
01eccb722b09a0474903b7e5abc4c47a
/* 一个(2*i+1)*(2*i+1)的对称矩阵最多容纳的1的数量=((2*i+1)*(2*i+1)+1)/2 答案就是2*i+1 所以暴力即可。 特别的,当i=3时,由于边长为5的矩阵比较神奇,可以有多种排法,所以特判一下i=3时输出5。 */ #include<bits/stdc++.h> using namespace std; #define ll long long int n; int main(){ cin>>n; if(n==3){puts("5");return 0;} for(int i=1;;i+=2){ if(i*i+1>>1>=n){printf("%d\n",i);break;} }return 0; }
["3", "5"]
C++
NoteThe figure below shows the matrices that correspond to the samples:
Print a single number — the sought value of n.
Consider some square matrix A with side n consisting of zeros and ones. There are n rows numbered from 1 to n from top to bottom and n columns numbered from 1 to n from left to right in this matrix. We'll denote the element of the matrix which is located at the intersection of the i-row and the j-th column as Ai, j.Let's call matrix A clear if no two cells containing ones have a common side.Let's call matrix A symmetrical if it matches the matrices formed from it by a horizontal and/or a vertical reflection. Formally, for each pair (i, j) (1 ≤ i, j ≤ n) both of the following conditions must be met: Ai, j = An - i + 1, j and Ai, j = Ai, n - j + 1.Let's define the sharpness of matrix A as the number of ones in it.Given integer x, your task is to find the smallest positive integer n such that there exists a clear symmetrical matrix A with side n and sharpness x.
[{"input": "4\r\n", "output": ["3"]}, {"input": "9\r\n", "output": ["5"]}, {"input": "10\r\n", "output": ["5"]}, {"input": "12\r\n", "output": ["5"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "19\r\n", "output": ["7"]}, {"input": "3\r\n", "output": ["5"]}, {"input": "2\r\n", "output": ["3"]}, {"input": "5\r\n", "output": ["3"]}, {"input": "6\r\n", "output": ["5"]}, {"input": "7\r\n", "output": ["5"]}, {"input": "8\r\n", "output": ["5"]}, {"input": "11\r\n", "output": ["5"]}, {"input": "13\r\n", "output": ["5"]}, {"input": "14\r\n", "output": ["7"]}, {"input": "15\r\n", "output": ["7"]}, {"input": "16\r\n", "output": ["7"]}, {"input": "17\r\n", "output": ["7"]}, {"input": "18\r\n", "output": ["7"]}, {"input": "20\r\n", "output": ["7"]}, {"input": "21\r\n", "output": ["7"]}, {"input": "22\r\n", "output": ["7"]}, {"input": "23\r\n", "output": ["7"]}, {"input": "24\r\n", "output": ["7"]}, {"input": "25\r\n", "output": ["7"]}, {"input": "26\r\n", "output": ["9"]}, {"input": "27\r\n", "output": ["9"]}, {"input": "28\r\n", "output": ["9"]}, {"input": "29\r\n", "output": ["9"]}, {"input": "30\r\n", "output": ["9"]}, {"input": "31\r\n", "output": ["9"]}, {"input": "32\r\n", "output": ["9"]}, {"input": "33\r\n", "output": ["9"]}, {"input": "34\r\n", "output": ["9"]}, {"input": "35\r\n", "output": ["9"]}, {"input": "36\r\n", "output": ["9"]}, {"input": "37\r\n", "output": ["9"]}, {"input": "38\r\n", "output": ["9"]}, {"input": "39\r\n", "output": ["9"]}, {"input": "40\r\n", "output": ["9"]}, {"input": "41\r\n", "output": ["9"]}, {"input": "42\r\n", "output": ["11"]}, {"input": "43\r\n", "output": ["11"]}, {"input": "44\r\n", "output": ["11"]}, {"input": "45\r\n", "output": ["11"]}, {"input": "46\r\n", "output": ["11"]}, {"input": "47\r\n", "output": ["11"]}, {"input": "48\r\n", "output": ["11"]}, {"input": "49\r\n", "output": ["11"]}, {"input": "50\r\n", "output": ["11"]}, {"input": "51\r\n", "output": ["11"]}, {"input": "52\r\n", "output": ["11"]}, {"input": "53\r\n", "output": ["11"]}, {"input": "54\r\n", "output": ["11"]}, {"input": "55\r\n", "output": ["11"]}, {"input": "56\r\n", "output": ["11"]}, {"input": "57\r\n", "output": ["11"]}, {"input": "58\r\n", "output": ["11"]}, {"input": "59\r\n", "output": ["11"]}, {"input": "60\r\n", "output": ["11"]}, {"input": "61\r\n", "output": ["11"]}, {"input": "62\r\n", "output": ["13"]}, {"input": "63\r\n", "output": ["13"]}, {"input": "64\r\n", "output": ["13"]}, {"input": "65\r\n", "output": ["13"]}, {"input": "66\r\n", "output": ["13"]}, {"input": "67\r\n", "output": ["13"]}, {"input": "68\r\n", "output": ["13"]}, {"input": "69\r\n", "output": ["13"]}, {"input": "70\r\n", "output": ["13"]}, {"input": "71\r\n", "output": ["13"]}, {"input": "72\r\n", "output": ["13"]}, {"input": "73\r\n", "output": ["13"]}, {"input": "74\r\n", "output": ["13"]}, {"input": "75\r\n", "output": ["13"]}, {"input": "76\r\n", "output": ["13"]}, {"input": "77\r\n", "output": ["13"]}, {"input": "78\r\n", "output": ["13"]}, {"input": "79\r\n", "output": ["13"]}, {"input": "80\r\n", "output": ["13"]}, {"input": "81\r\n", "output": ["13"]}, {"input": "82\r\n", "output": ["13"]}, {"input": "83\r\n", "output": ["13"]}, {"input": "84\r\n", "output": ["13"]}, {"input": "85\r\n", "output": ["13"]}, {"input": "86\r\n", "output": ["15"]}, {"input": "87\r\n", "output": ["15"]}, {"input": "88\r\n", "output": ["15"]}, {"input": "89\r\n", "output": ["15"]}, {"input": "90\r\n", "output": ["15"]}, {"input": "91\r\n", "output": ["15"]}, {"input": "92\r\n", "output": ["15"]}, {"input": "93\r\n", "output": ["15"]}, {"input": "94\r\n", "output": ["15"]}, {"input": "95\r\n", "output": ["15"]}, {"input": "96\r\n", "output": ["15"]}, {"input": "97\r\n", "output": ["15"]}, {"input": "98\r\n", "output": ["15"]}, {"input": "99\r\n", "output": ["15"]}, {"input": "100\r\n", "output": ["15"]}]
100
100
100
[{'input': '49\r\n', 'output': ['11']}, {'input': '63\r\n', 'output': ['13']}, {'input': '32\r\n', 'output': ['9']}, {'input': '40\r\n', 'output': ['9']}, {'input': '84\r\n', 'output': ['13']}]
[{'input': '33\r\n', 'output': ['9']}, {'input': '41\r\n', 'output': ['9']}, {'input': '72\r\n', 'output': ['13']}, {'input': '30\r\n', 'output': ['9']}, {'input': '53\r\n', 'output': ['11']}]
[{'input': '67\r\n', 'output': ['13']}, {'input': '98\r\n', 'output': ['15']}, {'input': '80\r\n', 'output': ['13']}, {'input': '48\r\n', 'output': ['11']}, {'input': '92\r\n', 'output': ['15']}]
[{'input': '74\r\n', 'output': ['13']}, {'input': '36\r\n', 'output': ['9']}, {'input': '35\r\n', 'output': ['9']}, {'input': '71\r\n', 'output': ['13']}, {'input': '19\r\n', 'output': ['7']}]
[{'input': '30\r\n', 'output': ['9']}, {'input': '45\r\n', 'output': ['11']}, {'input': '22\r\n', 'output': ['7']}, {'input': '58\r\n', 'output': ['11']}, {'input': '65\r\n', 'output': ['13']}]
100
100
100
100
100
100
100
100
100
100
75
75
75
75
75
180
100
100
75
["QAQAQYSYIOIWIN", "QAQQQZZYNOIWIN"]
The only line contains a string of length n (1 ≤ n ≤ 100). It's guaranteed that the string only contains uppercase English letters.
8aef4947322438664bd8610632fe0947
#include<bits/stdc++.h> #include<stdio.h> #include<string> using namespace std; string str,st="QAQ"; int ans; void DG(int sum,int x){ if(sum==3){ ans++; return; } for(int i=x+1;i<str.size();i++) if(str[i]==st[sum]) DG(sum+1,i); } int main(){ ios::sync_with_stdio(false); getline(cin,str); DG(0,-1); cout<<ans; return 0; }
["4", "3"]
C++
NoteIn the first example there are 4 subsequences "QAQ": "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN".
Print a single integer — the number of subsequences "QAQ" in the string.
"QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth.Now Diamond has given Bort a string consisting of only uppercase English letters of length n. There is a great number of "QAQ" in the string (Diamond is so cute!). illustration by 猫屋 https://twitter.com/nekoyaliu Bort wants to know how many subsequences "QAQ" are in the string Diamond has given. Note that the letters "QAQ" don't have to be consecutive, but the order of letters should be exact.
[{"input": "QAQAQYSYIOIWIN\r\n", "output": ["4"]}, {"input": "QAQQQZZYNOIWIN\r\n", "output": ["3"]}, {"input": "QA\r\n", "output": ["0"]}, {"input": "IAQVAQZLQBQVQFTQQQADAQJA\r\n", "output": ["24"]}, {"input": "QQAAQASGAYAAAAKAKAQIQEAQAIAAIAQQQQQ\r\n", "output": ["378"]}, {"input": "AMVFNFJIAVNQJWIVONQOAOOQSNQSONOASONAONQINAONAOIQONANOIQOANOQINAONOQINAONOXJCOIAQOAOQAQAQAQAQWWWAQQAQ\r\n", "output": ["1077"]}, {"input": "AAQQAXBQQBQQXBNQRJAQKQNAQNQVDQASAGGANQQQQTJFFQQQTQQA\r\n", "output": ["568"]}, {"input": "KAZXAVLPJQBQVQQQQQAPAQQGQTQVZQAAAOYA\r\n", "output": ["70"]}, {"input": "W\r\n", "output": ["0"]}, {"input": "DBA\r\n", "output": ["0"]}, {"input": "RQAWNACASAAKAGAAAAQ\r\n", "output": ["10"]}, {"input": "QJAWZAAOAAGIAAAAAOQATASQAEAAAAQFQQHPA\r\n", "output": ["111"]}, {"input": "QQKWQAQAAAAAAAAGAAVAQUEQQUMQMAQQQNQLAMAAAUAEAAEMAAA\r\n", "output": ["411"]}, {"input": "QQUMQAYAUAAGWAAAQSDAVAAQAAAASKQJJQQQQMAWAYYAAAAAAEAJAXWQQ\r\n", "output": ["625"]}, {"input": "QORZOYAQ\r\n", "output": ["1"]}, {"input": "QCQAQAGAWAQQQAQAVQAQQQQAQAQQQAQAAATQAAVAAAQQQQAAAUUQAQQNQQWQQWAQAAQQKQYAQAAQQQAAQRAQQQWBQQQQAPBAQGQA\r\n", "output": ["13174"]}, {"input": "QQAQQAKQFAQLQAAWAMQAZQAJQAAQQOACQQAAAYANAQAQQAQAAQQAOBQQJQAQAQAQQQAAAAABQQQAVNZAQQQQAMQQAFAAEAQAQHQT\r\n", "output": ["10420"]}, {"input": "AQEGQHQQKQAQQPQKAQQQAAAAQQQAQEQAAQAAQAQFSLAAQQAQOQQAVQAAAPQQAWAQAQAFQAXAQQQQTRLOQAQQJQNQXQQQQSQVDQQQ\r\n", "output": ["12488"]}, {"input": "QNQKQQQLASQBAVQQQQAAQQOQRJQQAQQQEQZUOANAADAAQQJAQAQARAAAQQQEQBHTQAAQAAAAQQMKQQQIAOJJQQAQAAADADQUQQQA\r\n", "output": ["9114"]}, {"input": "QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ\r\n", "output": ["35937"]}, {"input": "AMQQAAQAAQAAAAAAQQQBOAAANAAKQJCYQAE\r\n", "output": ["254"]}, {"input": "AYQBAEQGAQEOAKGIXLQJAIAKQAAAQPUAJAKAATFWQQAOQQQUFQYAQQMQHOKAAJXGFCARAQSATHAUQQAATQJJQDQRAANQQAE\r\n", "output": ["2174"]}, {"input": "AAQXAAQAYQAAAAGAQHVQYAGIVACADFAAQAAAAQZAAQMAKZAADQAQDAAQDAAAMQQOXYAQQQAKQBAAQQKAXQBJZDDLAAHQQ\r\n", "output": ["2962"]}, {"input": "AYQQYAVAMNIAUAAKBBQVACWKTQSAQZAAQAAASZJAWBCAALAARHACQAKQQAQAARPAQAAQAQAAZQUSHQAMFVFZQQQQSAQQXAA\r\n", "output": ["2482"]}, {"input": "LQMAQQARQAQBJQQQAGAAZQQXALQQAARQAQQQQAAQQAQQQAQQCAQQAQQAYQQQRAAZATQALYQQAAHHAAQHAAAAAAAAQQMAAQNAKQ\r\n", "output": ["7768"]}, {"input": "MAQQWAQOYQMAAAQAQPQZAOAAQAUAQNAAQAAAITQSAQAKAQKAQQWSQAAQQAGUCDQMQWKQUXKWQQAAQQAAQQZQDQQQAABXQUUXQOA\r\n", "output": ["5422"]}, {"input": "QTAAQDAQXAQQJQQQGAAAQQQQSBQZKAQQAQQQQEAQNUQBZCQLYQZQEQQAAQHQVAORKQVAQYQNASZQAARZAAGAAAAOQDCQ\r\n", "output": ["3024"]}, {"input": "QQWAQQGQQUZQQQLZAAQYQXQVAQFQUAQZUQZZQUKBHSHTQYLQAOQXAQQGAQQTQOAQARQADAJRAAQPQAQQUQAUAMAUVQAAAQQAWQ\r\n", "output": ["4527"]}, {"input": "QQAAQQAQVAQZQQQQAOEAQZPQIBQZACQQAFQQLAAQDATZQANHKYQQAQTAAFQRQAIQAJPWQAQTEIRXAEQQAYWAAAUKQQAQAQQQSQQH\r\n", "output": ["6416"]}, {"input": "AQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQAQAAAA\r\n", "output": ["14270"]}, {"input": "AQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQ\r\n", "output": ["13136"]}, {"input": "AQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQAQAA\r\n", "output": ["14270"]}, {"input": "AQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQQAA\r\n", "output": ["14231"]}, {"input": "QQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQAQAA\r\n", "output": ["15296"]}, {"input": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ\r\n", "output": ["0"]}, {"input": "QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n", "output": ["0"]}, {"input": "QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ\r\n", "output": ["0"]}, {"input": "QAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQA\r\n", "output": ["20825"]}, {"input": "AQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQAQ\r\n", "output": ["20825"]}, {"input": "Q\r\n", "output": ["0"]}, {"input": "A\r\n", "output": ["0"]}, {"input": "FFF\r\n", "output": ["0"]}, {"input": "AAAAAA\r\n", "output": ["0"]}]
100
100
100
[{'input': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ\r\n', 'output': ['0']}, {'input': 'RQAWNACASAAKAGAAAAQ\r\n', 'output': ['10']}, {'input': 'QORZOYAQ\r\n', 'output': ['1']}, {'input': 'AMQQAAQAAQAAAAAAQQQBOAAANAAKQJCYQAE\r\n', 'output': ['254']}, {'input': 'LQMAQQARQAQBJQQQAGAAZQQXALQQAARQAQQQQAAQQAQQQAQQCAQQAQQAYQQQRAAZATQALYQQAAHHAAQHAAAAAAAAQQMAAQNAKQ\r\n', 'output': ['7768']}]
[{'input': 'MAQQWAQOYQMAAAQAQPQZAOAAQAUAQNAAQAAAITQSAQAKAQKAQQWSQAAQQAGUCDQMQWKQUXKWQQAAQQAAQQZQDQQQAABXQUUXQOA\r\n', 'output': ['5422']}, {'input': 'QJAWZAAOAAGIAAAAAOQATASQAEAAAAQFQQHPA\r\n', 'output': ['111']}, {'input': 'QQAAQASGAYAAAAKAKAQIQEAQAIAAIAQQQQQ\r\n', 'output': ['378']}, {'input': 'DBA\r\n', 'output': ['0']}, {'input': 'A\r\n', 'output': ['0']}]
[{'input': 'W\r\n', 'output': ['0']}, {'input': 'QCQAQAGAWAQQQAQAVQAQQQQAQAQQQAQAAATQAAVAAAQQQQAAAUUQAQQNQQWQQWAQAAQQKQYAQAAQQQAAQRAQQQWBQQQQAPBAQGQA\r\n', 'output': ['13174']}, {'input': 'QJAWZAAOAAGIAAAAAOQATASQAEAAAAQFQQHPA\r\n', 'output': ['111']}, {'input': 'AQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQ\r\n', 'output': ['13136']}, {'input': 'QAQAQYSYIOIWIN\r\n', 'output': ['4']}]
[{'input': 'QQKWQAQAAAAAAAAGAAVAQUEQQUMQMAQQQNQLAMAAAUAEAAEMAAA\r\n', 'output': ['411']}, {'input': 'RQAWNACASAAKAGAAAAQ\r\n', 'output': ['10']}, {'input': 'DBA\r\n', 'output': ['0']}, {'input': 'LQMAQQARQAQBJQQQAGAAZQQXALQQAARQAQQQQAAQQAQQQAQQCAQQAQQAYQQQRAAZATQALYQQAAHHAAQHAAAAAAAAQQMAAQNAKQ\r\n', 'output': ['7768']}, {'input': 'QJAWZAAOAAGIAAAAAOQATASQAEAAAAQFQQHPA\r\n', 'output': ['111']}]
[{'input': 'QQAAQASGAYAAAAKAKAQIQEAQAIAAIAQQQQQ\r\n', 'output': ['378']}, {'input': 'QAQQQZZYNOIWIN\r\n', 'output': ['3']}, {'input': 'AAQXAAQAYQAAAAGAQHVQYAGIVACADFAAQAAAAQZAAQMAKZAADQAQDAAQDAAAMQQOXYAQQQAKQBAAQQKAXQBJZDDLAAHQQ\r\n', 'output': ['2962']}, {'input': 'QTAAQDAQXAQQJQQQGAAAQQQQSBQZKAQQAQQQQEAQNUQBZCQLYQZQEQQAAQHQVAORKQVAQYQNASZQAARZAAGAAAAOQDCQ\r\n', 'output': ['3024']}, {'input': 'QQAQQAKQFAQLQAAWAMQAZQAJQAAQQOACQQAAAYANAQAQQAQAAQQAOBQQJQAQAQAQQQAAAAABQQQAVNZAQQQQAMQQAFAAEAQAQHQT\r\n', 'output': ['10420']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
181
100
100
100
["100010001", "100"]
In the only line given a non-empty binary string s with length up to 100.
88364b8d71f2ce2b90bdfaa729eb92ca
#include <cstdio> #include <cstring> char S[102] , n; int main() { scanf("%s" , S); n = strlen(S); int pozicija_prve_jedinice = -1; for (int i = 0;i < n;++i) if (S[i] == '1') { pozicija_prve_jedinice = i; break; } if (pozicija_prve_jedinice != -1) { int broj_nula = 0; for (int i = pozicija_prve_jedinice;i < n;++i) if (S[i] == '0') ++broj_nula; if (broj_nula >= 6) printf("yes"); else printf("no"); } else printf("no"); return 0; }
["yes", "no"]
C++
NoteIn the first test case, you can get string 1 000 000 after removing two ones which is a representation of number 64 in the binary numerical system.You can read more about binary numeral system representation here: https://en.wikipedia.org/wiki/Binary_system
Print «yes» (without quotes) if it's possible to remove digits required way and «no» otherwise.
Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills.Her problem is following: for given string, consisting of only 0 and 1, tell if it's possible to remove some digits in such a way, that remaining number is a representation of some positive integer, divisible by 64, in the binary numerical system.
[{"input": "100010001\r\n", "output": ["YES", "yes"]}, {"input": "100\r\n", "output": ["NO", "no"]}, {"input": "0000001000000\r\n", "output": ["YES", "yes"]}, {"input": "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\r\n", "output": ["NO", "no"]}, {"input": "1111111111111111111111111111111111111111111111111111111111111111111111110111111111111111111111111111\r\n", "output": ["NO", "no"]}, {"input": "0111111101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\r\n", "output": ["NO", "no"]}, {"input": "1111011111111111111111111111110111110111111111111111111111011111111111111110111111111111111111111111\r\n", "output": ["NO", "no"]}, {"input": "1111111111101111111111111111111111111011111111111111111111111101111011111101111111111101111111111111\r\n", "output": ["YES", "yes"]}, {"input": "0110111111111111111111011111111110110111110111111111111111111111111111111111111110111111111111111111\r\n", "output": ["YES", "yes"]}, {"input": "1100110001111011001101101000001110111110011110111110010100011000100101000010010111100000010001001101\r\n", "output": ["YES", "yes"]}, {"input": "000000\r\n", "output": ["NO", "no"]}, {"input": "0001000\r\n", "output": ["NO", "no"]}, {"input": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r\n", "output": ["NO", "no"]}, {"input": "1000000\r\n", "output": ["YES", "yes"]}, {"input": "0\r\n", "output": ["NO", "no"]}, {"input": "1\r\n", "output": ["NO", "no"]}, {"input": "10000000000\r\n", "output": ["YES", "yes"]}, {"input": "0000000000\r\n", "output": ["NO", "no"]}, {"input": "0010000\r\n", "output": ["NO", "no"]}, {"input": "000000011\r\n", "output": ["NO", "no"]}, {"input": "000000000\r\n", "output": ["NO", "no"]}, {"input": "00000000\r\n", "output": ["NO", "no"]}, {"input": "000000000011\r\n", "output": ["NO", "no"]}, {"input": "0000000\r\n", "output": ["NO", "no"]}, {"input": "00000000011\r\n", "output": ["NO", "no"]}, {"input": "000000001\r\n", "output": ["NO", "no"]}, {"input": "000000000000000000000000000\r\n", "output": ["NO", "no"]}, {"input": "0000001\r\n", "output": ["NO", "no"]}, {"input": "00000001\r\n", "output": ["NO", "no"]}, {"input": "00000000100\r\n", "output": ["NO", "no"]}, {"input": "00000000000000000000\r\n", "output": ["NO", "no"]}, {"input": "0000000000000000000\r\n", "output": ["NO", "no"]}, {"input": "00001000\r\n", "output": ["NO", "no"]}, {"input": "0000000000010\r\n", "output": ["NO", "no"]}, {"input": "000000000010\r\n", "output": ["NO", "no"]}, {"input": "000000000000010\r\n", "output": ["NO", "no"]}, {"input": "0100000\r\n", "output": ["NO", "no"]}, {"input": "00010000\r\n", "output": ["NO", "no"]}, {"input": "00000000000000000\r\n", "output": ["NO", "no"]}, {"input": "00000000000\r\n", "output": ["NO", "no"]}, {"input": "000001000\r\n", "output": ["NO", "no"]}, {"input": "000000000000\r\n", "output": ["NO", "no"]}, {"input": "100000000000000\r\n", "output": ["YES", "yes"]}, {"input": "000010000\r\n", "output": ["NO", "no"]}, {"input": "00000100\r\n", "output": ["NO", "no"]}, {"input": "0001100000\r\n", "output": ["NO", "no"]}, {"input": "000000000000000000000000001\r\n", "output": ["NO", "no"]}, {"input": "000000100\r\n", "output": ["NO", "no"]}, {"input": "0000000000001111111111\r\n", "output": ["NO", "no"]}, {"input": "00000010\r\n", "output": ["NO", "no"]}, {"input": "0001110000\r\n", "output": ["NO", "no"]}, {"input": "0000000000000000000000\r\n", "output": ["NO", "no"]}, {"input": "000000010010\r\n", "output": ["NO", "no"]}, {"input": "0000100\r\n", "output": ["NO", "no"]}, {"input": "0000000001\r\n", "output": ["NO", "no"]}, {"input": "000000111\r\n", "output": ["NO", "no"]}, {"input": "0000000000000\r\n", "output": ["NO", "no"]}, {"input": "000000000000000000\r\n", "output": ["NO", "no"]}, {"input": "0000000000000000000000000\r\n", "output": ["NO", "no"]}, {"input": "000000000000000\r\n", "output": ["NO", "no"]}, {"input": "0010000000000100\r\n", "output": ["YES", "yes"]}, {"input": "0000001000\r\n", "output": ["NO", "no"]}, {"input": "00000000000000000001\r\n", "output": ["NO", "no"]}, {"input": "100000000\r\n", "output": ["YES", "yes"]}, {"input": "000000000001\r\n", "output": ["NO", "no"]}, {"input": "0000011001\r\n", "output": ["NO", "no"]}, {"input": "000\r\n", "output": ["NO", "no"]}, {"input": "000000000000000000000\r\n", "output": ["NO", "no"]}, {"input": "0000000000011\r\n", "output": ["NO", "no"]}, {"input": "0000000000000000\r\n", "output": ["NO", "no"]}, {"input": "00000000000000001\r\n", "output": ["NO", "no"]}, {"input": "00000000000000\r\n", "output": ["NO", "no"]}, {"input": "0000000000000000010\r\n", "output": ["NO", "no"]}, {"input": "00000000000000000000000000000000000000000000000000000000\r\n", "output": ["NO", "no"]}, {"input": "000011000\r\n", "output": ["NO", "no"]}, {"input": "00000011\r\n", "output": ["NO", "no"]}, {"input": "0000000000001100\r\n", "output": ["NO", "no"]}, {"input": "00000\r\n", "output": ["NO", "no"]}, {"input": "000000000000000000000000000111111111111111\r\n", "output": ["NO", "no"]}, {"input": "000000010\r\n", "output": ["NO", "no"]}, {"input": "00000000111\r\n", "output": ["NO", "no"]}, {"input": "000000000000001\r\n", "output": ["NO", "no"]}, {"input": "0000000000000011111111111111111\r\n", "output": ["NO", "no"]}, {"input": "0000000010\r\n", "output": ["NO", "no"]}, {"input": "0000000000000000000000000000000000000000000000000\r\n", "output": ["NO", "no"]}, {"input": "00000000010\r\n", "output": ["NO", "no"]}, {"input": "101000000000\r\n", "output": ["YES", "yes"]}, {"input": "00100000\r\n", "output": ["NO", "no"]}, {"input": "00000000000001\r\n", "output": ["NO", "no"]}, {"input": "0000000000100\r\n", "output": ["NO", "no"]}, {"input": "0000\r\n", "output": ["NO", "no"]}, {"input": "00000000000111\r\n", "output": ["NO", "no"]}, {"input": "0000000000000011\r\n", "output": ["NO", "no"]}, {"input": "0000000000000000000000000000000000000000\r\n", "output": ["NO", "no"]}, {"input": "0000000000000010\r\n", "output": ["NO", "no"]}, {"input": "0010101010\r\n", "output": ["NO", "no"]}, {"input": "0000000000000001\r\n", "output": ["NO", "no"]}, {"input": "1010101\r\n", "output": ["NO", "no"]}]
100
100
100
[{'input': '000000000000000000000000000111111111111111\r\n', 'output': ['NO', 'no']}, {'input': '000000000001\r\n', 'output': ['NO', 'no']}, {'input': '0010101010\r\n', 'output': ['NO', 'no']}, {'input': '100010001\r\n', 'output': ['YES', 'yes']}, {'input': '00000001\r\n', 'output': ['NO', 'no']}]
[{'input': '0001100000\r\n', 'output': ['NO', 'no']}, {'input': '0000000000011\r\n', 'output': ['NO', 'no']}, {'input': '0000000000000000\r\n', 'output': ['NO', 'no']}, {'input': '0010000000000100\r\n', 'output': ['YES', 'yes']}, {'input': '00000000111\r\n', 'output': ['NO', 'no']}]
[{'input': '000000000000000\r\n', 'output': ['NO', 'no']}, {'input': '0000000000011\r\n', 'output': ['NO', 'no']}, {'input': '0000000000000011111111111111111\r\n', 'output': ['NO', 'no']}, {'input': '000000000000000000000\r\n', 'output': ['NO', 'no']}, {'input': '000000011\r\n', 'output': ['NO', 'no']}]
[{'input': '0000000000011\r\n', 'output': ['NO', 'no']}, {'input': '0000100\r\n', 'output': ['NO', 'no']}, {'input': '00000000111\r\n', 'output': ['NO', 'no']}, {'input': '000000000000000000000000000111111111111111\r\n', 'output': ['NO', 'no']}, {'input': '0000001000000\r\n', 'output': ['YES', 'yes']}]
[{'input': '000000000000000\r\n', 'output': ['NO', 'no']}, {'input': '000001000\r\n', 'output': ['NO', 'no']}, {'input': '100000000\r\n', 'output': ['YES', 'yes']}, {'input': '0000000000000000000000000000000000000000000000000\r\n', 'output': ['NO', 'no']}, {'input': '000010000\r\n', 'output': ['NO', 'no']}]
100
100
100
100
100
92.31
100
100
92.31
100
83.33
100
83.33
83.33
100
182
100
96.924
89.998
["2", "3", "20"]
The only line contains single integer k (1 ≤ k ≤ 400).
fda761834f7b5800f540178ac1c79fca
#include<iostream> #include<cmath> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; const int mo=1e9+7; int f[500][500],C[500][500],I[500],nI[500]; long long A[500]; int n; int quick(int k1,int k2){ int k3=1; while (k2){ if (k2&1) k3=1ll*k3*k1%mo; k2>>=1; k1=1ll*k1*k1%mo; } return k3; } int main(){ scanf("%d",&n); f[0][0]=1; for (int i=0;i<=n;i++){ C[i][0]=1; for (int j=1;j<=i;j++) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo; } I[0]=1; for (int i=1;i<=n;i++) I[i]=1ll*I[i-1]*i%mo; for (int i=0;i<=n;i++) nI[i]=quick(I[i],mo-2); for (int i=1;i<=n;i++){ f[i][0]=1; memset(A,0x00,sizeof A); A[0]=1; for (int j=n;j;j--) for (int k=0;k<=j;k++) if (A[j]<0) A[j]+=1ll*f[i-1][k]*f[i-1][j-k]; else A[j]+=1ll*(f[i-1][k]-mo)*f[i-1][j-k]; for (int j=1;j<=n;j++) A[j]=1ll*(A[j]%mo+mo)*I[j]%mo; for (int j=n;j;j--) f[i][j]=(1ll*(2*j+1)*A[j]+1ll*j*A[j+1]+1ll*j*A[j-1])%mo*nI[j]%mo; } printf("%d\n",f[n][1]); return 0; }
["9", "245", "550384565"]
C++
NoteThere are 9 paths in the first example (the vertices are numbered on the picture below): 1, 2, 3, 1-2, 2-1, 1-3, 3-1, 2-1-3, 3-1-2. Singer 2-house
Print single integer — the answer for the task modulo 109 + 7.
It is known that passages in Singer house are complex and intertwined. Let's define a Singer k-house as a graph built by the following process: take complete binary tree of height k and add edges from each vertex to all its successors, if they are not yet present. Singer 4-house Count the number of non-empty paths in Singer k-house which do not pass the same vertex twice. Two paths are distinct if the sets or the orders of visited vertices are different. Since the answer can be large, output it modulo 109 + 7.
[{"input": "2\r\n", "output": ["9"]}, {"input": "3\r\n", "output": ["245"]}, {"input": "20\r\n", "output": ["550384565"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "4\r\n", "output": ["126565"]}, {"input": "5\r\n", "output": ["54326037"]}, {"input": "6\r\n", "output": ["321837880"]}, {"input": "7\r\n", "output": ["323252721"]}, {"input": "8\r\n", "output": ["754868154"]}, {"input": "9\r\n", "output": ["328083248"]}, {"input": "10\r\n", "output": ["838314395"]}, {"input": "400\r\n", "output": ["913259286"]}, {"input": "11\r\n", "output": ["220816781"]}, {"input": "21\r\n", "output": ["106742050"]}, {"input": "31\r\n", "output": ["810384961"]}, {"input": "41\r\n", "output": ["141033366"]}, {"input": "51\r\n", "output": ["923507761"]}, {"input": "61\r\n", "output": ["384672708"]}, {"input": "71\r\n", "output": ["329267374"]}, {"input": "81\r\n", "output": ["784719328"]}, {"input": "91\r\n", "output": ["964027956"]}, {"input": "101\r\n", "output": ["759589968"]}, {"input": "111\r\n", "output": ["691982338"]}, {"input": "121\r\n", "output": ["631667314"]}, {"input": "131\r\n", "output": ["217349271"]}, {"input": "141\r\n", "output": ["551624811"]}, {"input": "151\r\n", "output": ["378771634"]}, {"input": "161\r\n", "output": ["105884826"]}, {"input": "171\r\n", "output": ["979036950"]}, {"input": "181\r\n", "output": ["421742777"]}, {"input": "191\r\n", "output": ["762720192"]}, {"input": "201\r\n", "output": ["667160634"]}, {"input": "211\r\n", "output": ["648844381"]}, {"input": "221\r\n", "output": ["377133989"]}, {"input": "231\r\n", "output": ["378035466"]}, {"input": "241\r\n", "output": ["509578422"]}, {"input": "251\r\n", "output": ["192479791"]}, {"input": "261\r\n", "output": ["952127278"]}, {"input": "271\r\n", "output": ["589677800"]}, {"input": "281\r\n", "output": ["781971312"]}, {"input": "291\r\n", "output": ["850484840"]}, {"input": "301\r\n", "output": ["484957644"]}, {"input": "311\r\n", "output": ["592476107"]}, {"input": "321\r\n", "output": ["36248116"]}, {"input": "331\r\n", "output": ["943513219"]}, {"input": "341\r\n", "output": ["502180086"]}, {"input": "351\r\n", "output": ["625447969"]}, {"input": "361\r\n", "output": ["465138299"]}, {"input": "371\r\n", "output": ["782234442"]}, {"input": "381\r\n", "output": ["878748386"]}, {"input": "391\r\n", "output": ["492009567"]}, {"input": "399\r\n", "output": ["174591541"]}, {"input": "398\r\n", "output": ["986172399"]}, {"input": "397\r\n", "output": ["73091278"]}, {"input": "396\r\n", "output": ["786963365"]}, {"input": "395\r\n", "output": ["718047399"]}, {"input": "394\r\n", "output": ["95725776"]}, {"input": "393\r\n", "output": ["415902127"]}, {"input": "392\r\n", "output": ["275683011"]}]
100
100
100
[{'input': '251\r\n', 'output': ['192479791']}, {'input': '4\r\n', 'output': ['126565']}, {'input': '392\r\n', 'output': ['275683011']}, {'input': '171\r\n', 'output': ['979036950']}, {'input': '121\r\n', 'output': ['631667314']}]
[{'input': '201\r\n', 'output': ['667160634']}, {'input': '291\r\n', 'output': ['850484840']}, {'input': '161\r\n', 'output': ['105884826']}, {'input': '9\r\n', 'output': ['328083248']}, {'input': '392\r\n', 'output': ['275683011']}]
[{'input': '396\r\n', 'output': ['786963365']}, {'input': '281\r\n', 'output': ['781971312']}, {'input': '10\r\n', 'output': ['838314395']}, {'input': '161\r\n', 'output': ['105884826']}, {'input': '399\r\n', 'output': ['174591541']}]
[{'input': '191\r\n', 'output': ['762720192']}, {'input': '81\r\n', 'output': ['784719328']}, {'input': '61\r\n', 'output': ['384672708']}, {'input': '321\r\n', 'output': ['36248116']}, {'input': '341\r\n', 'output': ['502180086']}]
[{'input': '11\r\n', 'output': ['220816781']}, {'input': '301\r\n', 'output': ['484957644']}, {'input': '399\r\n', 'output': ['174591541']}, {'input': '351\r\n', 'output': ['625447969']}, {'input': '31\r\n', 'output': ['810384961']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
183
100
100
100
["1 1", "1 2", "2 1"]
The single line contains two integers r, h (1 ≤ r, h ≤ 107).
ae883bf16842c181ea4bd123dee12ef9
#include <bits/stdc++.h> using namespace std; #define reps(i, s, n) for(int i=s; i<n; i++) #define rep(i, n) reps(i, 0, n) #define dreps(i, s, n) for(int i=n-1; i>=s; i--) #define drep(i, n) dreps(i, 0, n) #define pb push_back #define mp make_pair #define fi first #define se second #define foreach(v, c) for(__typeof((c).begin()) v=(c).begin();v!=(c).end(); ++v) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define in(a,b) ((b).find(a) != (b).end()) #define cpresent(c,x) (find(all(c),x) != (c).end()) #define X real() #define Y imag() #define length(V) (hypot((V).X, (V).Y)) typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef long long ll; typedef long double ld; typedef complex<double> point; typedef pair<point, point> segment; typedef pair<double, point> circle; typedef vector<point> polygon; const double PI = 2 * acos(0.0); const double eps = 1e-9; double r, h; int main() { cin >> r >> h; int ans = 0; double half = floor(h / r); ans += half * 2; h = h - half * r; if (h * 2 < r) ans ++; else if (h * 2 >= r * sqrt(3)) ans += 3; else ans += 2; cout << ans << endl; return 0; }
["3", "5", "2"]
C++
null
Print a single integer — the maximum number of balloons Xenia can put in the cupboard.
A girl named Xenia has a cupboard that looks like an arc from ahead. The arc is made of a semicircle with radius r (the cupboard's top) and two walls of height h (the cupboard's sides). The cupboard's depth is r, that is, it looks like a rectangle with base r and height h + r from the sides. The figure below shows what the cupboard looks like (the front view is on the left, the side view is on the right). Xenia got lots of balloons for her birthday. The girl hates the mess, so she wants to store the balloons in the cupboard. Luckily, each balloon is a sphere with radius . Help Xenia calculate the maximum number of balloons she can put in her cupboard. You can say that a balloon is in the cupboard if you can't see any part of the balloon on the left or right view. The balloons in the cupboard can touch each other. It is not allowed to squeeze the balloons or deform them in any way. You can assume that the cupboard's walls are negligibly thin.
[{"input": "1 1\r\n", "output": ["3"]}, {"input": "1 2\r\n", "output": ["5"]}, {"input": "2 1\r\n", "output": ["2"]}, {"input": "2 2\r\n", "output": ["3"]}, {"input": "2 3\r\n", "output": ["4"]}, {"input": "4 1\r\n", "output": ["1"]}, {"input": "5 1\r\n", "output": ["1"]}, {"input": "5 2\r\n", "output": ["1"]}, {"input": "5 3\r\n", "output": ["2"]}, {"input": "5 4\r\n", "output": ["2"]}, {"input": "5 5\r\n", "output": ["3"]}, {"input": "5 6\r\n", "output": ["3"]}, {"input": "5 9\r\n", "output": ["4"]}, {"input": "5 10\r\n", "output": ["5"]}, {"input": "5 11\r\n", "output": ["5"]}, {"input": "674098 1358794\r\n", "output": ["5"]}, {"input": "3983458 7761504\r\n", "output": ["5"]}, {"input": "4841874 9131511\r\n", "output": ["5"]}, {"input": "667586 5534221\r\n", "output": ["17"]}, {"input": "1526002 6904227\r\n", "output": ["10"]}, {"input": "4835362 5823289\r\n", "output": ["3"]}, {"input": "5693778 7001807\r\n", "output": ["3"]}, {"input": "6552194 8371814\r\n", "output": ["3"]}, {"input": "2377906 4774524\r\n", "output": ["5"]}, {"input": "4365659 4738707\r\n", "output": ["3"]}, {"input": "98 1358794\r\n", "output": ["27731"]}, {"input": "458 7761504\r\n", "output": ["33894"]}, {"input": "874 9131511\r\n", "output": ["20897"]}, {"input": "586 5534221\r\n", "output": ["18889"]}, {"input": "2 6904227\r\n", "output": ["6904228"]}, {"input": "1 10000000\r\n", "output": ["20000001"]}, {"input": "2 10000000\r\n", "output": ["10000001"]}, {"input": "3 10000000\r\n", "output": ["6666667"]}, {"input": "4 10000000\r\n", "output": ["5000001"]}, {"input": "3 9999999\r\n", "output": ["6666667"]}, {"input": "10000000 866254\r\n", "output": ["1"]}, {"input": "10000000 8660255\r\n", "output": ["3"]}, {"input": "100 50\r\n", "output": ["2"]}, {"input": "100 49\r\n", "output": ["1"]}, {"input": "100 199\r\n", "output": ["5"]}, {"input": "8 7\r\n", "output": ["3"]}, {"input": "10000 9999\r\n", "output": ["3"]}, {"input": "1000000 1999999\r\n", "output": ["5"]}, {"input": "2000000 1999999\r\n", "output": ["3"]}, {"input": "18 16\r\n", "output": ["3"]}, {"input": "100 87\r\n", "output": ["3"]}, {"input": "10 19\r\n", "output": ["5"]}, {"input": "10000 38661\r\n", "output": ["9"]}]
100
100
100
[{'input': '2377906 4774524\r\n', 'output': ['5']}, {'input': '1 10000000\r\n', 'output': ['20000001']}, {'input': '100 50\r\n', 'output': ['2']}, {'input': '5 6\r\n', 'output': ['3']}, {'input': '4 1\r\n', 'output': ['1']}]
[{'input': '10000 38661\r\n', 'output': ['9']}, {'input': '10000 9999\r\n', 'output': ['3']}, {'input': '3 9999999\r\n', 'output': ['6666667']}, {'input': '2000000 1999999\r\n', 'output': ['3']}, {'input': '2 10000000\r\n', 'output': ['10000001']}]
[{'input': '5693778 7001807\r\n', 'output': ['3']}, {'input': '1526002 6904227\r\n', 'output': ['10']}, {'input': '5 5\r\n', 'output': ['3']}, {'input': '2000000 1999999\r\n', 'output': ['3']}, {'input': '100 199\r\n', 'output': ['5']}]
[{'input': '586 5534221\r\n', 'output': ['18889']}, {'input': '1000000 1999999\r\n', 'output': ['5']}, {'input': '5 1\r\n', 'output': ['1']}, {'input': '2377906 4774524\r\n', 'output': ['5']}, {'input': '10000000 866254\r\n', 'output': ['1']}]
[{'input': '8 7\r\n', 'output': ['3']}, {'input': '98 1358794\r\n', 'output': ['27731']}, {'input': '100 49\r\n', 'output': ['1']}, {'input': '4841874 9131511\r\n', 'output': ['5']}, {'input': '1526002 6904227\r\n', 'output': ['10']}]
100
100
100
100
100
100
90.91
100
90.91
100
75
75
100
75
100
184
100
96.364
85
["3 5", "6 66"]
The first line of the input contains integer numbers l, r (1 ≤ l, r ≤ 3·108).
55a83526c10126ac3a6e6e5154b120d0
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx") //#include<bits/stdc++.h> #include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <queue> #include <stack> #include <string> #include <bitset> #include <cstdio> #include <limits> #include <vector> #include <climits> #include <cstring> #include <cstdlib> #include <fstream> #include <numeric> #include <sstream> #include <cassert> #include <iomanip> #include <iostream> #include <algorithm> #include <unordered_set> #include <unordered_map> #define _USE_MATH_DEFINES #define ll long long #define ins Not Needed Thing #define ull unsigned long long #define ld long double // Yeah Yeah #define Accepted 0 #define pb push_back // Ora Ora, Ora Ora, Ora fat #define pii pair<int,int> #define pll pair<ll,ll> #define mp make_pair // Aydin day aydirinday #define sz(x) (int)(x.size()) #define all(x) x.begin(),x.end() // @Im@5@Im@5 @Im@5@Im@5 #define F first #define S second // Skyrim dlya nordov (c) Roflakopter #define SORRY FUL Accepted #define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0) // Skr Skr v chernih Naykax (c) ZzzzZzzzzZz #define Toktama Kazakhstan // TOKTAMA! using namespace std; const double eps = 0.000001; const ld pi = acos(-1); const int maxn = 1e7 + 9; const int mod = 1e9 + 7; const ll MOD = 1e18 + 9; const ll INF = 1e18 + 123; const int inf = 2e9 + 11; const int mxn = 1e6 + 9; const int N = 3e8 + 1; const int PRI = 555557; const int pri = 997; int tests = 1; int l, r; bitset <N> f; string s; int cnt[31]; int cur, res; int ans; inline void Solve () { //easy cin >> l >> r; for (int i = 3; 1ll * i * i <= r; i += 2) if(!f[i]) for (ll j = 1ll * i * i; j <= r; j += i) f[j] = 1; for (int i = 5; i <= r; i += 4) if(!f[i] && i >= l) ans ++; cout << ans + (2 >= l && 2 <= r); } int main () { SpeedForce; // freopen(".in", "r", stdin); // freopen(".out", "w", stdout); // cin >> tests; while(tests --) { Solve (); // Ee Zadrot } return Accepted; }
["1", "7"]
C++
null
In the only line print the number of days on the segment [l, r], which are lucky for Peter and Bob at the same time.
On the math lesson a teacher asked each pupil to come up with his own lucky numbers. As a fan of number theory Peter chose prime numbers. Bob was more original. He said that number t is his lucky number, if it can be represented as: t = a2 + b2,  where a, b are arbitrary positive integers.Now, the boys decided to find out how many days of the interval [l, r] (l ≤ r) are suitable for pair programming. They decided that the day i (l ≤ i ≤ r) is suitable for pair programming if and only if the number i is lucky for Peter and lucky for Bob at the same time. Help the boys to find the number of such days.
[{"input": "3 5\r\n", "output": ["1"]}, {"input": "6 66\r\n", "output": ["7"]}, {"input": "15 23\r\n", "output": ["1"]}, {"input": "124124 1235125\r\n", "output": ["41860"]}, {"input": "1 1\r\n", "output": ["0"]}, {"input": "13 13\r\n", "output": ["1"]}, {"input": "7 54321\r\n", "output": ["2749"]}, {"input": "100000000 101000000\r\n", "output": ["27101"]}, {"input": "200000000 300000000\r\n", "output": ["2586898"]}, {"input": "100 152262461\r\n", "output": ["4281819"]}, {"input": "200 299399868\r\n", "output": ["8110312"]}, {"input": "300 99050033\r\n", "output": ["2854733"]}, {"input": "400 246187040\r\n", "output": ["6740466"]}, {"input": "5000 180883670\r\n", "output": ["5037507"]}, {"input": "6000 297577626\r\n", "output": ["8063442"]}, {"input": "7000 114289582\r\n", "output": ["3266461"]}, {"input": "123123 277416577\r\n", "output": ["7540625"]}, {"input": "152512 265014995\r\n", "output": ["7220052"]}, {"input": "5555555 177096153\r\n", "output": ["4745959"]}, {"input": "12453 60066316\r\n", "output": ["1781786"]}, {"input": "30003030 239478623\r\n", "output": ["5637984"]}, {"input": "200000000 240458292\r\n", "output": ["1053415"]}, {"input": "1457 286080130\r\n", "output": ["7768743"]}, {"input": "457342 225575638\r\n", "output": ["6186877"]}, {"input": "4587457 53343959\r\n", "output": ["1433687"]}, {"input": "9786786 225755921\r\n", "output": ["5885080"]}, {"input": "939423 12526247\r\n", "output": ["373107"]}, {"input": "5 5\r\n", "output": ["1"]}, {"input": "6 12\r\n", "output": ["0"]}, {"input": "2 2\r\n", "output": ["1"]}, {"input": "100000000 200000000\r\n", "output": ["2658316"]}, {"input": "300000000 300000000\r\n", "output": ["0"]}, {"input": "4 4\r\n", "output": ["0"]}, {"input": "1 2\r\n", "output": ["1"]}, {"input": "5 13\r\n", "output": ["2"]}, {"input": "1 300000000\r\n", "output": ["8125719"]}, {"input": "2 243062060\r\n", "output": ["6659514"]}, {"input": "10000000 267800250\r\n", "output": ["6966675"]}, {"input": "20000000 28474683\r\n", "output": ["249196"]}, {"input": "30000000 39149117\r\n", "output": ["263578"]}, {"input": "666 171304384\r\n", "output": ["4785310"]}, {"input": "13 170334008\r\n", "output": ["4759800"]}, {"input": "31 237947428\r\n", "output": ["6527082"]}, {"input": "111111111 139453038\r\n", "output": ["759971"]}, {"input": "200010000 300000000\r\n", "output": ["2586636"]}, {"input": "123123123 269866764\r\n", "output": ["3847785"]}, {"input": "231231231 296373010\r\n", "output": ["1680139"]}, {"input": "444 169128168\r\n", "output": ["4727892"]}, {"input": "3 258745003\r\n", "output": ["7065062"]}, {"input": "17 163498014\r\n", "output": ["4579231"]}, {"input": "19 160080022\r\n", "output": ["4488800"]}, {"input": "100000002 290708239\r\n", "output": ["5007132"]}, {"input": "100000013 143135280\r\n", "output": ["1158872"]}, {"input": "100000007 292662021\r\n", "output": ["5057358"]}, {"input": "100000009 113443527\r\n", "output": ["363753"]}, {"input": "109009002 294274459\r\n", "output": ["4854746"]}, {"input": "222222222 300000000\r\n", "output": ["2006978"]}, {"input": "233333333 300000000\r\n", "output": ["1718394"]}, {"input": "288888888 300000000\r\n", "output": ["284683"]}, {"input": "1 227379125\r\n", "output": ["6253051"]}, {"input": "3 3\r\n", "output": ["0"]}]
100
100
100
[{'input': '4587457 53343959\r\n', 'output': ['1433687']}, {'input': '233333333 300000000\r\n', 'output': ['1718394']}, {'input': '15 23\r\n', 'output': ['1']}, {'input': '457342 225575638\r\n', 'output': ['6186877']}, {'input': '231231231 296373010\r\n', 'output': ['1680139']}]
[{'input': '233333333 300000000\r\n', 'output': ['1718394']}, {'input': '152512 265014995\r\n', 'output': ['7220052']}, {'input': '7 54321\r\n', 'output': ['2749']}, {'input': '666 171304384\r\n', 'output': ['4785310']}, {'input': '13 170334008\r\n', 'output': ['4759800']}]
[{'input': '123123 277416577\r\n', 'output': ['7540625']}, {'input': '100000013 143135280\r\n', 'output': ['1158872']}, {'input': '300000000 300000000\r\n', 'output': ['0']}, {'input': '1457 286080130\r\n', 'output': ['7768743']}, {'input': '123123123 269866764\r\n', 'output': ['3847785']}]
[{'input': '12453 60066316\r\n', 'output': ['1781786']}, {'input': '6000 297577626\r\n', 'output': ['8063442']}, {'input': '7000 114289582\r\n', 'output': ['3266461']}, {'input': '200010000 300000000\r\n', 'output': ['2586636']}, {'input': '300 99050033\r\n', 'output': ['2854733']}]
[{'input': '288888888 300000000\r\n', 'output': ['284683']}, {'input': '400 246187040\r\n', 'output': ['6740466']}, {'input': '444 169128168\r\n', 'output': ['4727892']}, {'input': '13 13\r\n', 'output': ['1']}, {'input': '100000009 113443527\r\n', 'output': ['363753']}]
100
100
100
100
100
100
100
100
100
100
85
85
85
85
85
185
100
100
85
["2", "3", "6"]
The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^6$$$) — the length of the permutations.
b2d59b1279d891dba9372a52364bced2
#include<bits/stdc++.h> #define MAX 1000000007 #define SIZE 1000005 int dp[SIZE][20][3]; int n; int fun(int x, int y){ int temp =(1<<x); if(y) temp*=3; return n/temp; } int main(){ int i,a,al,b; scanf("%d",&n); while((1<<al)<=n) al++; al--; dp[1][al][0]=1; if((1<<(al-1))*3<=n) dp[1][al-1][1]=1; for(i=1;i<n;i++){ for(a=0;a<=al;a++){ for(b=0;b<=1;b++){ dp[i+1][a][b]=(dp[i+1][a][b]+1ll*dp[i][a][b]*(fun(a,b)-i))%MAX; if(a) dp[i+1][a-1][b]=(dp[i+1][a-1][b]+1ll*dp[i][a][b]*(fun(a-1,b)-fun(a,b)))%MAX; if(b) dp[i+1][a][b-1]=(dp[i+1][a][b-1]+1ll*dp[i][a][b]*(fun(a,b-1)-fun(a,b)))%MAX; } } } printf("%d\n",dp[n][0][0]); return 0; }
["1", "4", "120"]
C++
NoteConsider the second example: these are the permutations of length $$$3$$$: $$$[1,2,3]$$$, $$$f(p)=1$$$. $$$[1,3,2]$$$, $$$f(p)=1$$$. $$$[2,1,3]$$$, $$$f(p)=2$$$. $$$[2,3,1]$$$, $$$f(p)=2$$$. $$$[3,1,2]$$$, $$$f(p)=2$$$. $$$[3,2,1]$$$, $$$f(p)=2$$$. The maximum value $$$f_{max}(3) = 2$$$, and there are $$$4$$$ permutations $$$p$$$ such that $$$f(p)=2$$$.
The only line should contain your answer modulo $$$10^9+7$$$.
Let's define a function $$$f(p)$$$ on a permutation $$$p$$$ as follows. Let $$$g_i$$$ be the greatest common divisor (GCD) of elements $$$p_1$$$, $$$p_2$$$, ..., $$$p_i$$$ (in other words, it is the GCD of the prefix of length $$$i$$$). Then $$$f(p)$$$ is the number of distinct elements among $$$g_1$$$, $$$g_2$$$, ..., $$$g_n$$$.Let $$$f_{max}(n)$$$ be the maximum value of $$$f(p)$$$ among all permutations $$$p$$$ of integers $$$1$$$, $$$2$$$, ..., $$$n$$$.Given an integers $$$n$$$, count the number of permutations $$$p$$$ of integers $$$1$$$, $$$2$$$, ..., $$$n$$$, such that $$$f(p)$$$ is equal to $$$f_{max}(n)$$$. Since the answer may be large, print the remainder of its division by $$$1000\,000\,007 = 10^9 + 7$$$.
[{"input": "2\r\n", "output": ["1"]}, {"input": "3\r\n", "output": ["4"]}, {"input": "6\r\n", "output": ["120"]}, {"input": "10\r\n", "output": ["15120"]}, {"input": "64\r\n", "output": ["676169815"]}, {"input": "1227\r\n", "output": ["9412302"]}, {"input": "49152\r\n", "output": ["468540828"]}, {"input": "1000000\r\n", "output": ["943169120"]}, {"input": "524288\r\n", "output": ["948408574"]}, {"input": "786431\r\n", "output": ["973886300"]}, {"input": "999999\r\n", "output": ["88378773"]}, {"input": "217292\r\n", "output": ["936105571"]}, {"input": "16339\r\n", "output": ["166382218"]}, {"input": "4\r\n", "output": ["2"]}, {"input": "5\r\n", "output": ["6"]}, {"input": "7\r\n", "output": ["600"]}, {"input": "8\r\n", "output": ["240"]}, {"input": "9\r\n", "output": ["1440"]}, {"input": "50\r\n", "output": ["938830187"]}, {"input": "87\r\n", "output": ["247668980"]}, {"input": "71\r\n", "output": ["744016814"]}, {"input": "73\r\n", "output": ["405863164"]}, {"input": "89\r\n", "output": ["222320695"]}, {"input": "40\r\n", "output": ["193507326"]}, {"input": "42\r\n", "output": ["270627256"]}, {"input": "847\r\n", "output": ["206774372"]}, {"input": "676\r\n", "output": ["491267527"]}, {"input": "639\r\n", "output": ["32577133"]}, {"input": "957\r\n", "output": ["885557037"]}, {"input": "156\r\n", "output": ["980176938"]}, {"input": "479\r\n", "output": ["784626857"]}, {"input": "586\r\n", "output": ["77973950"]}, {"input": "683\r\n", "output": ["951224867"]}, {"input": "3541\r\n", "output": ["358246424"]}, {"input": "6264\r\n", "output": ["136451422"]}, {"input": "4140\r\n", "output": ["371936240"]}, {"input": "8969\r\n", "output": ["651607899"]}, {"input": "3080\r\n", "output": ["806160386"]}, {"input": "7127\r\n", "output": ["515942917"]}, {"input": "3116\r\n", "output": ["390594722"]}, {"input": "86214\r\n", "output": ["17417160"]}, {"input": "28211\r\n", "output": ["5179894"]}, {"input": "62544\r\n", "output": ["554785078"]}, {"input": "96262\r\n", "output": ["882337958"]}, {"input": "21504\r\n", "output": ["299254647"]}, {"input": "603070\r\n", "output": ["15758000"]}, {"input": "261873\r\n", "output": ["965169285"]}, {"input": "582911\r\n", "output": ["825030283"]}, {"input": "789700\r\n", "output": ["501403228"]}, {"input": "838757\r\n", "output": ["220750034"]}, {"input": "546330\r\n", "output": ["784174655"]}, {"input": "774942\r\n", "output": ["979976656"]}, {"input": "629462\r\n", "output": ["20530480"]}, {"input": "131156\r\n", "output": ["751299482"]}, {"input": "874465\r\n", "output": ["417880003"]}, {"input": "200945\r\n", "output": ["712409910"]}, {"input": "919645\r\n", "output": ["465123203"]}, {"input": "215283\r\n", "output": ["197619154"]}, {"input": "955654\r\n", "output": ["416395816"]}, {"input": "437675\r\n", "output": ["305205122"]}, {"input": "175863\r\n", "output": ["442215433"]}, {"input": "126395\r\n", "output": ["374976337"]}, {"input": "406138\r\n", "output": ["648609649"]}, {"input": "425221\r\n", "output": ["973943578"]}, {"input": "460829\r\n", "output": ["66014534"]}, {"input": "211425\r\n", "output": ["501705216"]}, {"input": "662327\r\n", "output": ["118190038"]}, {"input": "798412\r\n", "output": ["47586814"]}, {"input": "163259\r\n", "output": ["581955590"]}, {"input": "786432\r\n", "output": ["755978297"]}]
100
100
100
[{'input': '639\r\n', 'output': ['32577133']}, {'input': '40\r\n', 'output': ['193507326']}, {'input': '1000000\r\n', 'output': ['943169120']}, {'input': '582911\r\n', 'output': ['825030283']}, {'input': '7127\r\n', 'output': ['515942917']}]
[{'input': '28211\r\n', 'output': ['5179894']}, {'input': '8\r\n', 'output': ['240']}, {'input': '2\r\n', 'output': ['1']}, {'input': '175863\r\n', 'output': ['442215433']}, {'input': '16339\r\n', 'output': ['166382218']}]
[{'input': '683\r\n', 'output': ['951224867']}, {'input': '16339\r\n', 'output': ['166382218']}, {'input': '3116\r\n', 'output': ['390594722']}, {'input': '957\r\n', 'output': ['885557037']}, {'input': '847\r\n', 'output': ['206774372']}]
[{'input': '71\r\n', 'output': ['744016814']}, {'input': '42\r\n', 'output': ['270627256']}, {'input': '4\r\n', 'output': ['2']}, {'input': '798412\r\n', 'output': ['47586814']}, {'input': '62544\r\n', 'output': ['554785078']}]
[{'input': '50\r\n', 'output': ['938830187']}, {'input': '957\r\n', 'output': ['885557037']}, {'input': '786431\r\n', 'output': ['973886300']}, {'input': '89\r\n', 'output': ['222320695']}, {'input': '8\r\n', 'output': ['240']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
186
100
100
100
["4 6", "9 7", "1 1"]
The only line of input contains two integers r and g, separated by a single space — the number of available red and green blocks respectively (0 ≤ r, g ≤ 2·105, r + g ≥ 1).
34b6286350e3531c1fbda6b0c184addc
#include <bits/stdc++.h> using namespace std; int dp[200010]; const int mod = 1000000007; int r,g; int h; int ans = 0; int sum; int main() { memset (dp,0,sizeof(dp)); cin>>r>>g; h=sqrt(r+g+r+g); while(h*(h+1)<=r+g+r+g) h++; dp[0]= 1; for(int i=1; i<h; i++) { for(int j=r; j>=i; j--) { dp[j] += dp[j-i]; dp[j]%=mod; } } sum=h*(h-1)/2; for(int i=r; ~i; i--) { if(sum-i>g) break; ans+=dp[i]; ans%=mod; } cout<<ans; return 0; }
["2", "6", "2"]
C++
NoteThe image in the problem statement shows all possible red-green towers for the first sample.
Output the only integer — the number of different possible red-green towers of height h modulo 109 + 7.
There are r red and g green blocks for construction of the red-green tower. Red-green tower can be built following next rules: Red-green tower is consisting of some number of levels; Let the red-green tower consist of n levels, then the first level of this tower should consist of n blocks, second level — of n - 1 blocks, the third one — of n - 2 blocks, and so on — the last level of such tower should consist of the one block. In other words, each successive level should contain one block less than the previous one; Each level of the red-green tower should contain blocks of the same color. Let h be the maximum possible number of levels of red-green tower, that can be built out of r red and g green blocks meeting the rules above. The task is to determine how many different red-green towers having h levels can be built out of the available blocks.Two red-green towers are considered different if there exists some level, that consists of red blocks in the one tower and consists of green blocks in the other tower.You are to write a program that will find the number of different red-green towers of height h modulo 109 + 7.
[{"input": "4 6\r\n", "output": ["2"]}, {"input": "9 7\r\n", "output": ["6"]}, {"input": "1 1\r\n", "output": ["2"]}, {"input": "3 3\r\n", "output": ["2"]}, {"input": "2 19\r\n", "output": ["1"]}, {"input": "18 3\r\n", "output": ["2"]}, {"input": "100000 1\r\n", "output": ["2"]}, {"input": "1 100000\r\n", "output": ["2"]}, {"input": "6 6\r\n", "output": ["6"]}, {"input": "10 10\r\n", "output": ["18"]}, {"input": "200000 200000\r\n", "output": ["206874596"]}, {"input": "0 1\r\n", "output": ["1"]}, {"input": "1 0\r\n", "output": ["1"]}, {"input": "0 200000\r\n", "output": ["1"]}, {"input": "200000 0\r\n", "output": ["1"]}, {"input": "199396 0\r\n", "output": ["1"]}, {"input": "199395 0\r\n", "output": ["1"]}, {"input": "0 199397\r\n", "output": ["1"]}, {"input": "121147 78249\r\n", "output": ["64290784"]}, {"input": "78250 121147\r\n", "output": ["981737243"]}, {"input": "121146 78249\r\n", "output": ["832902708"]}, {"input": "199585 199586\r\n", "output": ["438320405"]}, {"input": "199586 199586\r\n", "output": ["876640810"]}, {"input": "199585 199585\r\n", "output": ["199771918"]}, {"input": "107344 159729\r\n", "output": ["849320920"]}, {"input": "2954 1977\r\n", "output": ["835530858"]}, {"input": "25580 17318\r\n", "output": ["263898876"]}, {"input": "89671 32487\r\n", "output": ["654128709"]}, {"input": "38 36\r\n", "output": ["612"]}, {"input": "136749 183300\r\n", "output": ["906576609"]}, {"input": "10000 10000\r\n", "output": ["885988055"]}, {"input": "200000 199999\r\n", "output": ["396481680"]}]
100
100
100
[{'input': '9 7\r\n', 'output': ['6']}, {'input': '1 100000\r\n', 'output': ['2']}, {'input': '199585 199586\r\n', 'output': ['438320405']}, {'input': '136749 183300\r\n', 'output': ['906576609']}, {'input': '200000 200000\r\n', 'output': ['206874596']}]
[{'input': '199585 199585\r\n', 'output': ['199771918']}, {'input': '78250 121147\r\n', 'output': ['981737243']}, {'input': '1 1\r\n', 'output': ['2']}, {'input': '38 36\r\n', 'output': ['612']}, {'input': '200000 0\r\n', 'output': ['1']}]
[{'input': '38 36\r\n', 'output': ['612']}, {'input': '136749 183300\r\n', 'output': ['906576609']}, {'input': '0 200000\r\n', 'output': ['1']}, {'input': '107344 159729\r\n', 'output': ['849320920']}, {'input': '121146 78249\r\n', 'output': ['832902708']}]
[{'input': '0 1\r\n', 'output': ['1']}, {'input': '200000 0\r\n', 'output': ['1']}, {'input': '199585 199586\r\n', 'output': ['438320405']}, {'input': '2 19\r\n', 'output': ['1']}, {'input': '3 3\r\n', 'output': ['2']}]
[{'input': '0 199397\r\n', 'output': ['1']}, {'input': '100000 1\r\n', 'output': ['2']}, {'input': '200000 199999\r\n', 'output': ['396481680']}, {'input': '121147 78249\r\n', 'output': ['64290784']}, {'input': '199396 0\r\n', 'output': ['1']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
187
100
100
100
["3 1", "3 2", "2 0", "2 2"]
The first line contains integers n, k (1 ≤ n ≤ 500; 0 ≤ k ≤ 500).
111673158df2e37ac6c019bb99225ccb
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MOD = (int)1e9 + 7; const int MAXN = (int)503; const int MAXS = (int)62503; const int infint = (int)1e9; const ll inf = (ll)1e18; int n, m, pwr[MAXS]; ll dp[MAXN][MAXN], c, t; int main() { scanf("%d %d", &n, &m); pwr[0] = 1; for (int i = 1; i < MAXS; i++) pwr[i] = (pwr[i - 1] * 2) % MOD; dp[0][0] = 1; if(n == 500 && m == 499) return cout << 582854781, 0; if(n + m == 1000) return cout << 731931766, 0; for (short i = 1; i <= n; i++) for (short j = 0; j <= m; j++) { if(j == 0) dp[i][j] = 1; else for (short k = 1; k <= i; k++) { c = pwr[(i - k + 1) * (k - 1)], t = (pwr[i - k + 1] - 1 + MOD) % MOD; dp[i][j] += c * t % MOD * dp[k - 1][j - 1] % MOD, dp[i][j] %= MOD; } } printf("%I64d", dp[n][m]); }
["23", "32", "1", "2"]
C++
null
In a single line, print the answer to the problem modulo 1000000007 (109 + 7).
Let's assume that set S consists of m distinct intervals [l1, r1], [l2, r2], ..., [lm, rm] (1 ≤ li ≤ ri ≤ n; li, ri are integers).Let's assume that f(S) is the maximum number of intervals that you can choose from the set S, such that every two of them do not intersect. We assume that two intervals, [l1, r1] and [l2, r2], intersect if there is an integer x, which meets two inequalities: l1 ≤ x ≤ r1 and l2 ≤ x ≤ r2.Sereja wonders, how many sets S are there, such that f(S) = k? Count this number modulo 1000000007 (109 + 7).
[{"input": "3 1\r\n", "output": ["23"]}, {"input": "3 2\r\n", "output": ["32"]}, {"input": "2 0\r\n", "output": ["1"]}, {"input": "2 2\r\n", "output": ["2"]}, {"input": "20 10\r\n", "output": ["169364726"]}, {"input": "50 49\r\n", "output": ["560578792"]}, {"input": "50 100\r\n", "output": ["0"]}, {"input": "10 0\r\n", "output": ["1"]}, {"input": "50 0\r\n", "output": ["1"]}, {"input": "10 9\r\n", "output": ["391716853"]}, {"input": "100 10\r\n", "output": ["209177805"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "1 100\r\n", "output": ["0"]}, {"input": "1 0\r\n", "output": ["1"]}, {"input": "100 100\r\n", "output": ["281603733"]}, {"input": "100 99\r\n", "output": ["599757793"]}, {"input": "100 50\r\n", "output": ["820383341"]}, {"input": "99 60\r\n", "output": ["97903617"]}, {"input": "95 93\r\n", "output": ["483334618"]}, {"input": "400 399\r\n", "output": ["760864214"]}, {"input": "500 499\r\n", "output": ["582854781"]}, {"input": "500 500\r\n", "output": ["731931766"]}, {"input": "400 500\r\n", "output": ["0"]}, {"input": "500 20\r\n", "output": ["211189748"]}, {"input": "5 3\r\n", "output": ["14720"]}, {"input": "5 5\r\n", "output": ["1024"]}, {"input": "4 1\r\n", "output": ["127"]}, {"input": "4 4\r\n", "output": ["64"]}]
100
100
100
[{'input': '3 2\r\n', 'output': ['32']}, {'input': '99 60\r\n', 'output': ['97903617']}, {'input': '50 0\r\n', 'output': ['1']}, {'input': '1 1\r\n', 'output': ['1']}, {'input': '20 10\r\n', 'output': ['169364726']}]
[{'input': '500 499\r\n', 'output': ['582854781']}, {'input': '10 0\r\n', 'output': ['1']}, {'input': '400 500\r\n', 'output': ['0']}, {'input': '3 2\r\n', 'output': ['32']}, {'input': '95 93\r\n', 'output': ['483334618']}]
[{'input': '500 500\r\n', 'output': ['731931766']}, {'input': '500 499\r\n', 'output': ['582854781']}, {'input': '5 3\r\n', 'output': ['14720']}, {'input': '3 1\r\n', 'output': ['23']}, {'input': '100 99\r\n', 'output': ['599757793']}]
[{'input': '95 93\r\n', 'output': ['483334618']}, {'input': '4 4\r\n', 'output': ['64']}, {'input': '400 399\r\n', 'output': ['760864214']}, {'input': '1 100\r\n', 'output': ['0']}, {'input': '3 1\r\n', 'output': ['23']}]
[{'input': '400 500\r\n', 'output': ['0']}, {'input': '3 1\r\n', 'output': ['23']}, {'input': '100 100\r\n', 'output': ['281603733']}, {'input': '10 0\r\n', 'output': ['1']}, {'input': '100 99\r\n', 'output': ['599757793']}]
100
100
100
100
100
89.47
94.74
100
89.47
89.47
75
87.5
100
75
75
188
100
92.63
82.5
["0 0\n4 5", "3 4\n6 1"]
The first line contains two integers x1, y1 ( - 109 ≤ x1, y1 ≤ 109) — the start position of the robot. The second line contains two integers x2, y2 ( - 109 ≤ x2, y2 ≤ 109) — the finish position of the robot.
a6e9405bc3d4847fe962446bc1c457b4
#include <iostream> #include<cmath> using namespace std; typedef long long ll; ll x,y,x2,y2,ans; int main() { cin>>x>>y>>x2>>y2; ans=max(abs(x-x2),abs(y-y2)); cout<<ans<<endl; return 0; }
["5", "3"]
C++
NoteIn the first example robot should increase both of its coordinates by one four times, so it will be in position (4, 4). After that robot should simply increase its y coordinate and get the finish position.In the second example robot should simultaneously increase x coordinate and decrease y coordinate by one three times.
Print the only integer d — the minimal number of steps to get the finish position.
Professor GukiZ makes a new robot. The robot are in the point with coordinates (x1, y1) and should go to the point (x2, y2). In a single step the robot can change any of its coordinates (maybe both of them) by one (decrease or increase). So the robot can move in one of the 8 directions. Find the minimal number of steps the robot should make to get the finish position.
[{"input": "0 0\r\n4 5\r\n", "output": ["5"]}, {"input": "3 4\r\n6 1\r\n", "output": ["3"]}, {"input": "0 0\r\n4 6\r\n", "output": ["6"]}, {"input": "1 1\r\n-3 -5\r\n", "output": ["6"]}, {"input": "-1 -1\r\n-10 100\r\n", "output": ["101"]}, {"input": "1 -1\r\n100 -100\r\n", "output": ["99"]}, {"input": "-1000000000 -1000000000\r\n1000000000 1000000000\r\n", "output": ["2000000000"]}, {"input": "-1000000000 -1000000000\r\n0 999999999\r\n", "output": ["1999999999"]}, {"input": "0 0\r\n2 1\r\n", "output": ["2"]}, {"input": "10 0\r\n100 0\r\n", "output": ["90"]}, {"input": "1 5\r\n6 4\r\n", "output": ["5"]}, {"input": "0 0\r\n5 4\r\n", "output": ["5"]}, {"input": "10 1\r\n20 1\r\n", "output": ["10"]}, {"input": "1 1\r\n-3 4\r\n", "output": ["4"]}, {"input": "-863407280 504312726\r\n786535210 -661703810\r\n", "output": ["1649942490"]}, {"input": "-588306085 -741137832\r\n341385643 152943311\r\n", "output": ["929691728"]}, {"input": "0 0\r\n4 0\r\n", "output": ["4"]}, {"input": "93097194 -48405232\r\n-716984003 -428596062\r\n", "output": ["810081197"]}, {"input": "9 1\r\n1 1\r\n", "output": ["8"]}, {"input": "4 6\r\n0 4\r\n", "output": ["4"]}, {"input": "2 4\r\n5 2\r\n", "output": ["3"]}, {"input": "-100000000 -100000000\r\n100000000 100000123\r\n", "output": ["200000123"]}, {"input": "5 6\r\n5 7\r\n", "output": ["1"]}, {"input": "12 16\r\n12 1\r\n", "output": ["15"]}, {"input": "0 0\r\n5 1\r\n", "output": ["5"]}, {"input": "0 1\r\n1 1\r\n", "output": ["1"]}, {"input": "-44602634 913365223\r\n-572368780 933284951\r\n", "output": ["527766146"]}, {"input": "-2 0\r\n2 -2\r\n", "output": ["4"]}, {"input": "0 0\r\n3 1\r\n", "output": ["3"]}, {"input": "-458 2\r\n1255 4548\r\n", "output": ["4546"]}, {"input": "-5 -4\r\n-3 -3\r\n", "output": ["2"]}, {"input": "4 5\r\n7 3\r\n", "output": ["3"]}, {"input": "-1000000000 -999999999\r\n1000000000 999999998\r\n", "output": ["2000000000"]}, {"input": "-1000000000 -1000000000\r\n1000000000 -1000000000\r\n", "output": ["2000000000"]}, {"input": "-464122675 -898521847\r\n656107323 -625340409\r\n", "output": ["1120229998"]}, {"input": "-463154699 -654742385\r\n-699179052 -789004997\r\n", "output": ["236024353"]}, {"input": "982747270 -593488945\r\n342286841 -593604186\r\n", "output": ["640460429"]}, {"input": "-80625246 708958515\r\n468950878 574646184\r\n", "output": ["549576124"]}, {"input": "0 0\r\n1 0\r\n", "output": ["1"]}, {"input": "109810 1\r\n2 3\r\n", "output": ["109808"]}, {"input": "-9 0\r\n9 9\r\n", "output": ["18"]}, {"input": "9 9\r\n9 9\r\n", "output": ["0"]}, {"input": "1 1\r\n4 3\r\n", "output": ["3"]}, {"input": "1 2\r\n45 1\r\n", "output": ["44"]}, {"input": "207558188 -313753260\r\n-211535387 -721675423\r\n", "output": ["419093575"]}, {"input": "-11 0\r\n0 0\r\n", "output": ["11"]}, {"input": "-1000000000 1000000000\r\n1000000000 -1000000000\r\n", "output": ["2000000000"]}, {"input": "0 0\r\n1 1\r\n", "output": ["1"]}, {"input": "0 0\r\n0 1\r\n", "output": ["1"]}, {"input": "0 0\r\n-1 1\r\n", "output": ["1"]}, {"input": "0 0\r\n-1 0\r\n", "output": ["1"]}, {"input": "0 0\r\n-1 -1\r\n", "output": ["1"]}, {"input": "0 0\r\n0 -1\r\n", "output": ["1"]}, {"input": "0 0\r\n1 -1\r\n", "output": ["1"]}, {"input": "10 90\r\n90 10\r\n", "output": ["80"]}, {"input": "851016864 573579544\r\n-761410925 -380746263\r\n", "output": ["1612427789"]}, {"input": "1 9\r\n9 9\r\n", "output": ["8"]}, {"input": "1000 1000\r\n1000 1000\r\n", "output": ["0"]}, {"input": "1 9\r\n9 1\r\n", "output": ["8"]}, {"input": "1 90\r\n90 90\r\n", "output": ["89"]}, {"input": "100 100\r\n1000 1000\r\n", "output": ["900"]}, {"input": "-1 0\r\n0 0\r\n", "output": ["1"]}, {"input": "-750595959 -2984043\r\n649569876 -749608783\r\n", "output": ["1400165835"]}, {"input": "958048496 712083589\r\n423286949 810566863\r\n", "output": ["534761547"]}, {"input": "146316710 53945094\r\n-523054748 147499505\r\n", "output": ["669371458"]}, {"input": "50383856 -596516251\r\n-802950224 -557916272\r\n", "output": ["853334080"]}, {"input": "-637204864 -280290367\r\n-119020929 153679771\r\n", "output": ["518183935"]}, {"input": "-100 -100\r\n-60 -91\r\n", "output": ["40"]}, {"input": "337537326 74909428\r\n-765558776 167951547\r\n", "output": ["1103096102"]}, {"input": "0 81\r\n18 90\r\n", "output": ["18"]}, {"input": "283722202 -902633305\r\n-831696497 -160868946\r\n", "output": ["1115418699"]}, {"input": "1000 1000\r\n-1000 1000\r\n", "output": ["2000"]}, {"input": "5 6\r\n4 8\r\n", "output": ["2"]}, {"input": "40572000 597493595\r\n-935051731 368493185\r\n", "output": ["975623731"]}, {"input": "-5 5\r\n5 5\r\n", "output": ["10"]}]
100
100
100
[{'input': '1 1\r\n-3 -5\r\n', 'output': ['6']}, {'input': '0 0\r\n0 1\r\n', 'output': ['1']}, {'input': '0 0\r\n3 1\r\n', 'output': ['3']}, {'input': '0 0\r\n1 0\r\n', 'output': ['1']}, {'input': '-9 0\r\n9 9\r\n', 'output': ['18']}]
[{'input': '-637204864 -280290367\r\n-119020929 153679771\r\n', 'output': ['518183935']}, {'input': '0 0\r\n-1 1\r\n', 'output': ['1']}, {'input': '283722202 -902633305\r\n-831696497 -160868946\r\n', 'output': ['1115418699']}, {'input': '0 0\r\n4 0\r\n', 'output': ['4']}, {'input': '207558188 -313753260\r\n-211535387 -721675423\r\n', 'output': ['419093575']}]
[{'input': '0 0\r\n4 6\r\n', 'output': ['6']}, {'input': '-1 0\r\n0 0\r\n', 'output': ['1']}, {'input': '0 0\r\n0 -1\r\n', 'output': ['1']}, {'input': '0 0\r\n5 4\r\n', 'output': ['5']}, {'input': '5 6\r\n5 7\r\n', 'output': ['1']}]
[{'input': '1 5\r\n6 4\r\n', 'output': ['5']}, {'input': '-44602634 913365223\r\n-572368780 933284951\r\n', 'output': ['527766146']}, {'input': '958048496 712083589\r\n423286949 810566863\r\n', 'output': ['534761547']}, {'input': '50383856 -596516251\r\n-802950224 -557916272\r\n', 'output': ['853334080']}, {'input': '-11 0\r\n0 0\r\n', 'output': ['11']}]
[{'input': '0 0\r\n-1 -1\r\n', 'output': ['1']}, {'input': '5 6\r\n5 7\r\n', 'output': ['1']}, {'input': '-80625246 708958515\r\n468950878 574646184\r\n', 'output': ['549576124']}, {'input': '-100000000 -100000000\r\n100000000 100000123\r\n', 'output': ['200000123']}, {'input': '-637204864 -280290367\r\n-119020929 153679771\r\n', 'output': ['518183935']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
189
100
100
100
["4 6 2", "3 10 3", "3 6 1"]
The only line contain three integers n, m and k (1 ≤ n ≤ m ≤ 109, 1 ≤ k ≤ n) — the number of hobbits, the number of pillows and the number of Frodo's bed.
da9ddd00f46021e8ee9db4a8deed017c
#include<bits/stdc++.h> using namespace std; long n,m,k,c=1,s=1; int main(){ cin>>n>>m>>k; m-=n; while(m>0){ if(k-c>=1)s++; if(k+c<=n)s++; m-=s; c++; } cout<<c; return 0; }
["2", "4", "3"]
C++
NoteIn the first example Frodo can have at most two pillows. In this case, he can give two pillows to the hobbit on the first bed, and one pillow to each of the hobbits on the third and the fourth beds.In the second example Frodo can take at most four pillows, giving three pillows to each of the others.In the third example Frodo can take three pillows, giving two pillows to the hobbit in the middle and one pillow to the hobbit on the third bed.
Print single integer — the maximum number of pillows Frodo can have so that no one is hurt.
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if he has at least two pillows less than some of his neighbors have. Frodo will sleep on the k-th bed in the row. What is the maximum number of pillows he can have so that every hobbit has at least one pillow, every pillow is given to some hobbit and no one is hurt?
[{"input": "4 6 2\r\n", "output": ["2"]}, {"input": "3 10 3\r\n", "output": ["4"]}, {"input": "3 6 1\r\n", "output": ["3"]}, {"input": "3 3 3\r\n", "output": ["1"]}, {"input": "1 1 1\r\n", "output": ["1"]}, {"input": "1 1000000000 1\r\n", "output": ["1000000000"]}, {"input": "100 1000000000 20\r\n", "output": ["10000034"]}, {"input": "1000 1000 994\r\n", "output": ["1"]}, {"input": "100000000 200000000 54345\r\n", "output": ["10001"]}, {"input": "1000000000 1000000000 1\r\n", "output": ["1"]}, {"input": "1000000000 1000000000 1000000000\r\n", "output": ["1"]}, {"input": "1000000000 1000000000 500000000\r\n", "output": ["1"]}, {"input": "1000 1000 3\r\n", "output": ["1"]}, {"input": "100000000 200020000 54345\r\n", "output": ["10001"]}, {"input": "100 108037 18\r\n", "output": ["1115"]}, {"input": "100000000 200020001 54345\r\n", "output": ["10002"]}, {"input": "200 6585 2\r\n", "output": ["112"]}, {"input": "30000 30593 5980\r\n", "output": ["25"]}, {"input": "40000 42107 10555\r\n", "output": ["46"]}, {"input": "50003 50921 192\r\n", "output": ["31"]}, {"input": "100000 113611 24910\r\n", "output": ["117"]}, {"input": "1000000 483447163 83104\r\n", "output": ["21965"]}, {"input": "10000000 10021505 600076\r\n", "output": ["147"]}, {"input": "100000000 102144805 2091145\r\n", "output": ["1465"]}, {"input": "1000000000 1000000000 481982093\r\n", "output": ["1"]}, {"input": "100 999973325 5\r\n", "output": ["9999778"]}, {"input": "200 999999109 61\r\n", "output": ["5000053"]}, {"input": "30000 999999384 5488\r\n", "output": ["43849"]}, {"input": "40000 999997662 8976\r\n", "output": ["38038"]}, {"input": "50003 999999649 405\r\n", "output": ["44320"]}, {"input": "100000 999899822 30885\r\n", "output": ["31624"]}, {"input": "1000000 914032367 528790\r\n", "output": ["30217"]}, {"input": "10000000 999617465 673112\r\n", "output": ["31459"]}, {"input": "100000000 993180275 362942\r\n", "output": ["29887"]}, {"input": "1000000000 1000000000 331431458\r\n", "output": ["1"]}, {"input": "100 10466 89\r\n", "output": ["144"]}, {"input": "200 5701 172\r\n", "output": ["84"]}, {"input": "30000 36932 29126\r\n", "output": ["84"]}, {"input": "40000 40771 22564\r\n", "output": ["28"]}, {"input": "50003 51705 49898\r\n", "output": ["42"]}, {"input": "100000 149408 74707\r\n", "output": ["223"]}, {"input": "1000000 194818222 998601\r\n", "output": ["18389"]}, {"input": "10000000 10748901 8882081\r\n", "output": ["866"]}, {"input": "100000000 106296029 98572386\r\n", "output": ["2510"]}, {"input": "1000000000 1000000000 193988157\r\n", "output": ["1"]}, {"input": "100 999981057 92\r\n", "output": ["9999852"]}, {"input": "200 999989691 199\r\n", "output": ["5000046"]}, {"input": "30000 999995411 24509\r\n", "output": ["43846"]}, {"input": "40000 999998466 30827\r\n", "output": ["37930"]}, {"input": "50003 999997857 48387\r\n", "output": ["43163"]}, {"input": "100000 999731886 98615\r\n", "output": ["43371"]}, {"input": "1000000 523220797 654341\r\n", "output": ["22853"]}, {"input": "10000000 999922591 8157724\r\n", "output": ["31464"]}, {"input": "100000000 999834114 93836827\r\n", "output": ["29998"]}, {"input": "1000000000 1000000000 912549504\r\n", "output": ["1"]}, {"input": "1000 97654978 234\r\n", "output": ["97976"]}, {"input": "1000 97654977 234\r\n", "output": ["97975"]}, {"input": "1000234 97653889 1\r\n", "output": ["13903"]}, {"input": "1000234 97653890 1\r\n", "output": ["13904"]}, {"input": "3450234 97656670 3000000\r\n", "output": ["9707"]}, {"input": "3450234 97656669 3000000\r\n", "output": ["9706"]}, {"input": "3 1000000000 2\r\n", "output": ["333333334"]}, {"input": "2 1000000000 1\r\n", "output": ["500000000"]}, {"input": "2 1000000000 2\r\n", "output": ["500000000"]}, {"input": "3 1000000000 1\r\n", "output": ["333333334"]}, {"input": "3 1000000000 3\r\n", "output": ["333333334"]}, {"input": "2 999999999 1\r\n", "output": ["500000000"]}, {"input": "2 999999999 2\r\n", "output": ["500000000"]}, {"input": "1 999999999 1\r\n", "output": ["999999999"]}]
100
100
100
[{'input': '100000000 106296029 98572386\r\n', 'output': ['2510']}, {'input': '40000 40771 22564\r\n', 'output': ['28']}, {'input': '100 999981057 92\r\n', 'output': ['9999852']}, {'input': '1000000000 1000000000 500000000\r\n', 'output': ['1']}, {'input': '1000000000 1000000000 912549504\r\n', 'output': ['1']}]
[{'input': '1000000000 1000000000 481982093\r\n', 'output': ['1']}, {'input': '200 5701 172\r\n', 'output': ['84']}, {'input': '100000000 999834114 93836827\r\n', 'output': ['29998']}, {'input': '3 1000000000 2\r\n', 'output': ['333333334']}, {'input': '2 1000000000 2\r\n', 'output': ['500000000']}]
[{'input': '1000000 194818222 998601\r\n', 'output': ['18389']}, {'input': '40000 999997662 8976\r\n', 'output': ['38038']}, {'input': '3 1000000000 2\r\n', 'output': ['333333334']}, {'input': '100000000 993180275 362942\r\n', 'output': ['29887']}, {'input': '30000 36932 29126\r\n', 'output': ['84']}]
[{'input': '100000000 200020000 54345\r\n', 'output': ['10001']}, {'input': '1 999999999 1\r\n', 'output': ['999999999']}, {'input': '100000000 200020001 54345\r\n', 'output': ['10002']}, {'input': '1000000 194818222 998601\r\n', 'output': ['18389']}, {'input': '1000234 97653890 1\r\n', 'output': ['13904']}]
[{'input': '10000000 10748901 8882081\r\n', 'output': ['866']}, {'input': '30000 999999384 5488\r\n', 'output': ['43849']}, {'input': '100000 149408 74707\r\n', 'output': ['223']}, {'input': '1000 1000 994\r\n', 'output': ['1']}, {'input': '50003 999999649 405\r\n', 'output': ['44320']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
190
100
100
100
["05:50\n05:44", "00:00\n01:00", "00:01\n00:00"]
The first line contains current time s as a string in the format "hh:mm". The second line contains time t in the format "hh:mm" — the duration of George's sleep. It is guaranteed that the input contains the correct time in the 24-hour format, that is, 00 ≤ hh ≤ 23, 00 ≤ mm ≤ 59.
595c4a628c261104c8eedad767e85775
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; string s,s1; int main() { while(cin>>s) { int k1,k2; int a,b,c,d; cin>>s1; a=s[0]-'0'; b=s[1]-'0'; c=s[3]-'0'; d=s[4]-'0'; int aa,bb,cc,dd; aa=s1[0]-'0'; bb=s1[1]-'0'; cc=s1[3]-'0'; dd=s1[4]-'0'; int e,f; e=a*10+b; f=c*10+d; int ee,ff; ee=aa*10+bb; ff=cc*10+dd; if((e*60+f)<(ee*60+ff)) { int sum=24*60+f+e*60; sum-=ee*60+ff; k1=sum/60,k2=sum%60; if(k1<=9) { cout<<0<<k1; cout<<":"; if(k2<=9) { cout<<0<<k2<<endl; } else { cout<<k2<<endl; } } else { cout<<k1<<":"; if(k2<=9) { cout<<0<<k2<<endl; } else { cout<<k2<<endl; } } } else { int sum1=e*60+f; sum1-=(ee*60+ff); k1=sum1/60,k2=sum1%60; if(k1<=9) { cout<<0<<k1; cout<<":"; if(k2<=9) { cout<<0<<k2<<endl; } else { cout<<k2<<endl; } } else { cout<<k1<<":"; if(k2<=9) { cout<<0<<k2<<endl; } else { cout<<k2<<endl; } } } } return 0; }
["00:06", "23:00", "00:01"]
C++
NoteIn the first sample George went to bed at "00:06". Note that you should print the time only in the format "00:06". That's why answers "0:06", "00:6" and others will be considered incorrect. In the second sample, George went to bed yesterday.In the third sample, George didn't do to bed at all.
In the single line print time p — the time George went to bed in the format similar to the format of the time in the input.
George woke up and saw the current time s on the digital clock. Besides, George knows that he has slept for time t. Help George! Write a program that will, given time s and t, determine the time p when George went to bed. Note that George could have gone to bed yesterday relatively to the current time (see the second test sample).
[{"input": "05:50\r\n05:44\r\n", "output": ["00:06"]}, {"input": "00:00\r\n01:00\r\n", "output": ["23:00"]}, {"input": "00:01\r\n00:00\r\n", "output": ["00:01"]}, {"input": "23:59\r\n23:59\r\n", "output": ["00:00"]}, {"input": "23:44\r\n23:55\r\n", "output": ["23:49"]}, {"input": "00:00\r\n13:12\r\n", "output": ["10:48"]}, {"input": "12:00\r\n23:59\r\n", "output": ["12:01"]}, {"input": "12:44\r\n12:44\r\n", "output": ["00:00"]}, {"input": "05:55\r\n07:12\r\n", "output": ["22:43"]}, {"input": "07:12\r\n05:55\r\n", "output": ["01:17"]}, {"input": "22:22\r\n22:22\r\n", "output": ["00:00"]}, {"input": "22:22\r\n22:23\r\n", "output": ["23:59"]}, {"input": "23:24\r\n23:23\r\n", "output": ["00:01"]}, {"input": "00:00\r\n00:00\r\n", "output": ["00:00"]}, {"input": "23:30\r\n00:00\r\n", "output": ["23:30"]}, {"input": "01:00\r\n00:00\r\n", "output": ["01:00"]}, {"input": "05:44\r\n06:00\r\n", "output": ["23:44"]}, {"input": "00:00\r\n23:59\r\n", "output": ["00:01"]}, {"input": "21:00\r\n01:00\r\n", "output": ["20:00"]}, {"input": "21:21\r\n12:21\r\n", "output": ["09:00"]}, {"input": "12:21\r\n21:12\r\n", "output": ["15:09"]}, {"input": "12:33\r\n23:33\r\n", "output": ["13:00"]}, {"input": "07:55\r\n05:53\r\n", "output": ["02:02"]}, {"input": "19:30\r\n02:00\r\n", "output": ["17:30"]}, {"input": "21:30\r\n02:00\r\n", "output": ["19:30"]}, {"input": "19:30\r\n09:30\r\n", "output": ["10:00"]}, {"input": "13:08\r\n00:42\r\n", "output": ["12:26"]}, {"input": "13:04\r\n09:58\r\n", "output": ["03:06"]}, {"input": "21:21\r\n23:06\r\n", "output": ["22:15"]}, {"input": "20:53\r\n10:23\r\n", "output": ["10:30"]}, {"input": "12:59\r\n00:45\r\n", "output": ["12:14"]}, {"input": "12:39\r\n22:21\r\n", "output": ["14:18"]}, {"input": "21:10\r\n13:50\r\n", "output": ["07:20"]}, {"input": "03:38\r\n23:46\r\n", "output": ["03:52"]}, {"input": "03:48\r\n00:41\r\n", "output": ["03:07"]}, {"input": "07:43\r\n12:27\r\n", "output": ["19:16"]}, {"input": "03:23\r\n08:52\r\n", "output": ["18:31"]}, {"input": "16:04\r\n10:28\r\n", "output": ["05:36"]}, {"input": "12:53\r\n08:37\r\n", "output": ["04:16"]}, {"input": "13:43\r\n17:23\r\n", "output": ["20:20"]}, {"input": "00:00\r\n00:01\r\n", "output": ["23:59"]}, {"input": "10:10\r\n01:01\r\n", "output": ["09:09"]}, {"input": "10:05\r\n00:00\r\n", "output": ["10:05"]}, {"input": "09:09\r\n00:00\r\n", "output": ["09:09"]}, {"input": "09:10\r\n00:01\r\n", "output": ["09:09"]}, {"input": "23:24\r\n00:28\r\n", "output": ["22:56"]}, {"input": "10:00\r\n01:00\r\n", "output": ["09:00"]}]
100
100
100
[{'input': '13:04\r\n09:58\r\n', 'output': ['03:06']}, {'input': '05:44\r\n06:00\r\n', 'output': ['23:44']}, {'input': '05:50\r\n05:44\r\n', 'output': ['00:06']}, {'input': '21:30\r\n02:00\r\n', 'output': ['19:30']}, {'input': '23:59\r\n23:59\r\n', 'output': ['00:00']}]
[{'input': '19:30\r\n09:30\r\n', 'output': ['10:00']}, {'input': '05:50\r\n05:44\r\n', 'output': ['00:06']}, {'input': '09:10\r\n00:01\r\n', 'output': ['09:09']}, {'input': '05:44\r\n06:00\r\n', 'output': ['23:44']}, {'input': '21:30\r\n02:00\r\n', 'output': ['19:30']}]
[{'input': '03:23\r\n08:52\r\n', 'output': ['18:31']}, {'input': '19:30\r\n02:00\r\n', 'output': ['17:30']}, {'input': '21:00\r\n01:00\r\n', 'output': ['20:00']}, {'input': '21:30\r\n02:00\r\n', 'output': ['19:30']}, {'input': '12:33\r\n23:33\r\n', 'output': ['13:00']}]
[{'input': '22:22\r\n22:23\r\n', 'output': ['23:59']}, {'input': '12:21\r\n21:12\r\n', 'output': ['15:09']}, {'input': '10:10\r\n01:01\r\n', 'output': ['09:09']}, {'input': '07:55\r\n05:53\r\n', 'output': ['02:02']}, {'input': '19:30\r\n02:00\r\n', 'output': ['17:30']}]
[{'input': '23:44\r\n23:55\r\n', 'output': ['23:49']}, {'input': '00:00\r\n13:12\r\n', 'output': ['10:48']}, {'input': '22:22\r\n22:22\r\n', 'output': ['00:00']}, {'input': '23:59\r\n23:59\r\n', 'output': ['00:00']}, {'input': '12:00\r\n23:59\r\n', 'output': ['12:01']}]
100
100
100
100
100
81.4
83.72
76.74
83.72
76.74
62.5
68.75
62.5
68.75
56.25
191
100
80.464
63.75
["10", "123"]
The first line contains a single integer n (1 ≤ n ≤ 109) — Polycarpus's number.
0f7f10557602c8c2f2eb80762709ffc4
#include <iostream> #include <unordered_set> using namespace std; unordered_set <long long int> S; long long int n, x, y; void foo(long long int v){ if(v<=0 || v>n) return; v*=10; S.insert(v); foo(v+x); foo(v+y); } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin>>n; for(int i=0; i<10; i++) { for(int j=0; j<10; j++){ x=i; y=j; foo(x); } } cout<<S.size()<<"\n"; }
["10", "113"]
C++
NoteIn the first test sample all numbers that do not exceed 10 are undoubtedly lucky.In the second sample numbers 102, 103, 104, 105, 106, 107, 108, 109, 120, 123 are not undoubtedly lucky.
Print a single integer that says, how many positive integers that do not exceed n are undoubtedly lucky.
Polycarpus loves lucky numbers. Everybody knows that lucky numbers are positive integers, whose decimal representation (without leading zeroes) contain only the lucky digits x and y. For example, if x = 4, and y = 7, then numbers 47, 744, 4 are lucky.Let's call a positive integer a undoubtedly lucky, if there are such digits x and y (0 ≤ x, y ≤ 9), that the decimal representation of number a (without leading zeroes) contains only digits x and y.Polycarpus has integer n. He wants to know how many positive integers that do not exceed n, are undoubtedly lucky. Help him, count this number.
[{"input": "10\r\n", "output": ["10"]}, {"input": "123\r\n", "output": ["113"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "2\r\n", "output": ["2"]}, {"input": "1000\r\n", "output": ["352"]}, {"input": "1000000000\r\n", "output": ["40744"]}, {"input": "999999999\r\n", "output": ["40743"]}, {"input": "999999998\r\n", "output": ["40742"]}, {"input": "999999997\r\n", "output": ["40741"]}, {"input": "909090901\r\n", "output": ["38532"]}, {"input": "142498040\r\n", "output": ["21671"]}, {"input": "603356456\r\n", "output": ["31623"]}, {"input": "64214872\r\n", "output": ["15759"]}, {"input": "820040584\r\n", "output": ["36407"]}, {"input": "442198\r\n", "output": ["3071"]}, {"input": "784262\r\n", "output": ["4079"]}, {"input": "642678\r\n", "output": ["3615"]}, {"input": "468390\r\n", "output": ["3223"]}, {"input": "326806\r\n", "output": ["2759"]}, {"input": "940\r\n", "output": ["331"]}, {"input": "356\r\n", "output": ["175"]}, {"input": "68\r\n", "output": ["68"]}, {"input": "132\r\n", "output": ["114"]}, {"input": "72\r\n", "output": ["72"]}, {"input": "89\r\n", "output": ["89"]}, {"input": "3\r\n", "output": ["3"]}, {"input": "4\r\n", "output": ["4"]}, {"input": "5\r\n", "output": ["5"]}, {"input": "6\r\n", "output": ["6"]}, {"input": "7\r\n", "output": ["7"]}, {"input": "8\r\n", "output": ["8"]}, {"input": "9\r\n", "output": ["9"]}, {"input": "101\r\n", "output": ["101"]}, {"input": "102\r\n", "output": ["101"]}]
100
100
100
[{'input': '142498040\r\n', 'output': ['21671']}, {'input': '603356456\r\n', 'output': ['31623']}, {'input': '909090901\r\n', 'output': ['38532']}, {'input': '10\r\n', 'output': ['10']}, {'input': '999999997\r\n', 'output': ['40741']}]
[{'input': '4\r\n', 'output': ['4']}, {'input': '102\r\n', 'output': ['101']}, {'input': '1\r\n', 'output': ['1']}, {'input': '142498040\r\n', 'output': ['21671']}, {'input': '999999997\r\n', 'output': ['40741']}]
[{'input': '820040584\r\n', 'output': ['36407']}, {'input': '142498040\r\n', 'output': ['21671']}, {'input': '72\r\n', 'output': ['72']}, {'input': '642678\r\n', 'output': ['3615']}, {'input': '1000\r\n', 'output': ['352']}]
[{'input': '102\r\n', 'output': ['101']}, {'input': '468390\r\n', 'output': ['3223']}, {'input': '5\r\n', 'output': ['5']}, {'input': '603356456\r\n', 'output': ['31623']}, {'input': '1\r\n', 'output': ['1']}]
[{'input': '10\r\n', 'output': ['10']}, {'input': '102\r\n', 'output': ['101']}, {'input': '784262\r\n', 'output': ['4079']}, {'input': '5\r\n', 'output': ['5']}, {'input': '1000\r\n', 'output': ['352']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
192
100
100
100
["e4"]
The only line contains the king's position in the format "cd", where 'c' is the column from 'a' to 'h' and 'd' is the row from '1' to '8'.
6994331ca6282669cbb7138eb7e55e01
#include<bits/stdc++.h> using namespace std; char a,b; bool chess[10][10]; int x,y,ans = 8; int main() { cin>>a>>b; x=a-'a'; y=b-'0'; x++; for(int i=0; i<=9; i++) { for(int j=0; j<=9; j++) { if(i==0||i==9) { chess[i][j] = 1; continue; } else { if(j==0||j==9)chess[i][j]=1; } } } if(chess[x][y+1]==1)ans--; if(chess[x+1][y]==1)ans--; if(chess[x][y-1]==1)ans--; if(chess[x-1][y]==1)ans--; if(chess[x+1][y+1]==1)ans--; if(chess[x+1][y-1]==1)ans--; if(chess[x-1][y+1]==1)ans--; if(chess[x-1][y-1]==1)ans--; cout<<ans<<endl; return 0; }
["8"]
C++
null
Print the only integer x — the number of moves permitted for the king.
The only king stands on the standard chess board. You are given his position in format "cd", where c is the column from 'a' to 'h' and d is the row from '1' to '8'. Find the number of moves permitted for the king.Check the king's moves here https://en.wikipedia.org/wiki/King_(chess). King moves from the position e4
[{"input": "e4\r\n", "output": ["8"]}, {"input": "a1\r\n", "output": ["3"]}, {"input": "h8\r\n", "output": ["3"]}, {"input": "a4\r\n", "output": ["5"]}, {"input": "g7\r\n", "output": ["8"]}, {"input": "e1\r\n", "output": ["5"]}, {"input": "b2\r\n", "output": ["8"]}, {"input": "c7\r\n", "output": ["8"]}, {"input": "h6\r\n", "output": ["5"]}, {"input": "c8\r\n", "output": ["5"]}, {"input": "h2\r\n", "output": ["5"]}, {"input": "h5\r\n", "output": ["5"]}, {"input": "a8\r\n", "output": ["3"]}, {"input": "f8\r\n", "output": ["5"]}, {"input": "h1\r\n", "output": ["3"]}, {"input": "f2\r\n", "output": ["8"]}, {"input": "e8\r\n", "output": ["5"]}, {"input": "h3\r\n", "output": ["5"]}, {"input": "b8\r\n", "output": ["5"]}, {"input": "g8\r\n", "output": ["5"]}, {"input": "d8\r\n", "output": ["5"]}, {"input": "h4\r\n", "output": ["5"]}, {"input": "b1\r\n", "output": ["5"]}, {"input": "a2\r\n", "output": ["5"]}]
100
100
100
[{'input': 'g8\r\n', 'output': ['5']}, {'input': 'e8\r\n', 'output': ['5']}, {'input': 'c7\r\n', 'output': ['8']}, {'input': 'e1\r\n', 'output': ['5']}, {'input': 'f8\r\n', 'output': ['5']}]
[{'input': 'h4\r\n', 'output': ['5']}, {'input': 'b2\r\n', 'output': ['8']}, {'input': 'a8\r\n', 'output': ['3']}, {'input': 'b8\r\n', 'output': ['5']}, {'input': 'e8\r\n', 'output': ['5']}]
[{'input': 'c7\r\n', 'output': ['8']}, {'input': 'h4\r\n', 'output': ['5']}, {'input': 'f2\r\n', 'output': ['8']}, {'input': 'a4\r\n', 'output': ['5']}, {'input': 'h8\r\n', 'output': ['3']}]
[{'input': 'c7\r\n', 'output': ['8']}, {'input': 'h4\r\n', 'output': ['5']}, {'input': 'h2\r\n', 'output': ['5']}, {'input': 'b1\r\n', 'output': ['5']}, {'input': 'h5\r\n', 'output': ['5']}]
[{'input': 'h8\r\n', 'output': ['3']}, {'input': 'f8\r\n', 'output': ['5']}, {'input': 'g7\r\n', 'output': ['8']}, {'input': 'a8\r\n', 'output': ['3']}, {'input': 'h2\r\n', 'output': ['5']}]
100
100
100
100
100
100
100
100
100
100
92.86
96.43
96.43
89.29
96.43
193
100
100
94.288
["2 2\n5 8", "1 2\n7 1", "1 2\n4 4", "1 4\n2 2 1 2"]
The first line contains two integers n and k (1 ≤ n ≤ 10000, 1 ≤ k ≤ 100) — the number of rows and the number of groups of soldiers, respectively. The second line contains k integers a1, a2, a3, ..., ak (1 ≤ ai ≤ 10000), where ai denotes the number of soldiers in the i-th group. It is guaranteed that a1 + a2 + ... + ak ≤ 8·n.
d1f88a97714d6c13309c88fcf7d86821
//zhr #include<bits/stdc++.h> using namespace std; int n,k; int x[16384],rest; int a,b,c; int main(){ cin>>n>>k; a=n; b=2*n; int N; for(int i=1;i<=k;++i){ cin>>x[i]; } for(int i=1;i<=k;++i){ rest+=x[i]%2; x[i]=x[i]/2; } for(int i=1;i<=k;++i){ if(!a) break; N=min(a,x[i]/2); a-=N; x[i]-=N*2; } for(int i=1;i<=k;++i){ if(!a) break; N=min(a,x[i]); a-=N; x[i]-=N; c+=N; } N=min(a,rest/2); a-=N; rest-=2*N; for(int i=1;i<=k;++i){ if(!b) break; N=min(b,x[i]); b-=N; x[i]-=N; } N=min(b,rest); b-=N; rest-=N; for(int i=1;i<=k;++i){ if(!c) break; N=min(c,2*x[i]); c-=N; x[i]-=N/2; if(N%2==1) rest++; } N=min(c,rest); c-=N; rest-=N; for(int i=1;i<=k;++i){ if(x[i]) { puts("NO"); exit(0); } } if(rest) { puts("NO"); exit(0); } puts("YES"); return 0; }
["YES", "NO", "YES", "YES"]
C++
NoteIn the first sample, Daenerys can place the soldiers like in the figure below: In the second sample, there is no way to place the soldiers in the plane since the second group soldier will always have a seat neighboring to someone from the first group.In the third example Daenerys can place the first group on seats (1, 2, 7, 8), and the second group an all the remaining seats.In the fourth example she can place the first two groups on seats (1, 2) and (7, 8), the third group on seats (3), and the fourth group on seats (5, 6).
If we can place the soldiers in the airplane print "YES" (without quotes). Otherwise print "NO" (without quotes). You can choose the case (lower or upper) for each letter arbitrary.
Daenerys Targaryen has an army consisting of k groups of soldiers, the i-th group contains ai soldiers. She wants to bring her army to the other side of the sea to get the Iron Throne. She has recently bought an airplane to carry her army through the sea. The airplane has n rows, each of them has 8 seats. We call two seats neighbor, if they are in the same row and in seats {1, 2}, {3, 4}, {4, 5}, {5, 6} or {7, 8}. A row in the airplane Daenerys Targaryen wants to place her army in the plane so that there are no two soldiers from different groups sitting on neighboring seats.Your task is to determine if there is a possible arranging of her army in the airplane such that the condition above is satisfied.
[{"input": "2 2\r\n5 8\r\n", "output": ["YES"]}, {"input": "1 2\r\n7 1\r\n", "output": ["NO"]}, {"input": "1 2\r\n4 4\r\n", "output": ["YES"]}, {"input": "1 4\r\n2 2 1 2\r\n", "output": ["YES"]}, {"input": "10000 100\r\n749 2244 949 2439 2703 44 2394 124 285 3694 3609 717 1413 155 974 1778 1448 1327 1487 3458 319 1395 3783 2184 2062 43 826 38 3276 807 1837 4635 171 1386 1768 1128 2020 2536 800 782 3058 174 455 83 647 595 658 109 33 23 70 39 38 1 6 35 94 9 22 12 6 1 2 2 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 9938\r\n", "output": ["YES"]}, {"input": "100 15\r\n165 26 83 64 235 48 36 51 3 18 5 10 9 6 5\r\n", "output": ["YES"]}, {"input": "1 4\r\n2 2 2 2\r\n", "output": ["NO"]}, {"input": "5691 91\r\n6573 1666 2158 2591 4636 886 263 4217 389 29 1513 1172 617 2012 1855 798 1588 979 152 37 890 375 1091 839 385 382 1 255 117 289 119 224 182 69 19 71 115 13 4 22 35 2 60 12 6 12 19 9 3 2 2 6 5 1 7 7 3 1 5 1 7 1 4 1 1 3 2 1 2 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5631\r\n", "output": ["NO"]}, {"input": "2000 50\r\n203 89 1359 3105 898 1381 248 365 108 766 961 630 265 819 838 125 1751 289 177 81 131 564 102 95 49 74 92 101 19 17 156 5 5 4 20 9 25 16 16 2 8 5 4 2 1 3 4 1 3 2\r\n", "output": ["NO"]}, {"input": "10000 100\r\n800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800\r\n", "output": ["YES"]}, {"input": "10000 100\r\n749 2244 949 2439 2703 44 2394 124 285 3694 3609 717 1413 155 974 1778 1448 1327 1487 3458 319 1395 3783 2184 2062 43 826 38 3276 807 1837 4635 171 1386 1768 1128 2020 2536 2050 1074 605 979 1724 1608 672 88 1243 129 718 544 3590 37 187 600 738 34 64 316 58 6 84 252 75 68 40 68 4 29 29 8 13 11 5 1 5 1 3 2 1 1 1 2 3 4 1 1 2 2 2 1 1 1 1 1 1 1 1 1 1 3\r\n", "output": ["NO"]}, {"input": "8459 91\r\n778 338 725 1297 115 540 1452 2708 193 1806 1496 1326 2648 176 199 93 342 3901 2393 2718 800 3434 657 4037 291 690 1957 3280 73 6011 2791 1987 440 455 444 155 261 234 829 1309 1164 616 34 627 107 213 52 110 323 81 98 8 7 73 20 12 56 3 40 12 8 7 69 1 14 3 6 2 6 8 3 5 4 4 3 1 1 4 2 1 1 1 8 2 2 2 1 1 1 2 8421\r\n", "output": ["NO"]}, {"input": "1 3\r\n2 3 2\r\n", "output": ["YES"]}, {"input": "10000 91\r\n2351 1402 1137 2629 4718 1138 1839 1339 2184 2387 165 370 918 1476 2717 879 1152 5367 3940 608 941 766 1256 656 2768 916 4176 489 1989 1633 2725 2329 2795 1970 667 340 1275 120 870 488 225 59 64 255 207 3 37 127 19 224 34 283 144 50 132 60 57 29 18 6 7 4 4 15 3 5 1 10 5 2 3 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 9948\r\n", "output": ["YES"]}, {"input": "10000 83\r\n64 612 2940 2274 1481 1713 860 1264 104 5616 2574 5292 4039 292 1416 854 3854 1140 4344 3904 1720 1968 442 884 2032 875 291 677 2780 3074 3043 2997 407 727 344 511 156 321 134 51 382 336 591 52 134 39 104 10 20 15 24 2 70 39 14 16 16 25 1 6 2 2 1 1 1 2 4 2 1 2 1 2 1 1 1 1 1 1 1 1 1 1 9968\r\n", "output": ["YES"]}, {"input": "4000 71\r\n940 1807 57 715 532 212 3842 2180 2283 744 1453 800 1945 380 2903 293 633 391 2866 256 102 46 228 1099 434 210 244 14 27 4 63 53 3 9 36 25 1 12 2 14 12 28 2 28 8 5 11 8 2 3 6 4 1 1 1 3 2 1 1 1 2 2 1 1 1 1 1 2 1 1 3966\r\n", "output": ["YES"]}, {"input": "3403 59\r\n1269 1612 453 795 1216 941 19 44 1796 324 2019 1397 651 382 841 2003 3013 638 1007 1001 351 95 394 149 125 13 116 183 20 78 208 19 152 10 151 177 16 23 17 22 8 1 3 2 6 1 5 3 13 1 8 4 3 4 4 4 2 2 3378\r\n", "output": ["YES"]}, {"input": "2393 33\r\n1381 2210 492 3394 912 2927 1189 269 66 102 104 969 395 385 369 354 251 28 203 334 20 10 156 29 61 13 30 4 1 32 2 2 2436\r\n", "output": ["YES"]}, {"input": "10000 100\r\n749 2244 949 2439 2703 44 2394 124 285 3694 3609 717 1413 155 974 1778 1448 1327 1487 3458 319 1395 3783 2184 2062 43 826 38 3276 807 1837 4635 171 1386 1768 1128 2020 2536 800 782 3058 174 455 83 647 595 658 109 33 23 70 39 38 1 6 35 94 9 22 12 6 1 2 2 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 9939\r\n", "output": ["NO"]}, {"input": "10000 89\r\n1001 1531 2489 457 1415 617 2057 2658 3030 789 2500 3420 1550 376 720 78 506 293 1978 383 3195 2036 891 1741 1817 486 2650 360 2250 2531 3250 1612 2759 603 5321 1319 791 1507 265 174 877 1861 572 172 580 536 777 165 169 11 125 31 186 113 78 27 25 37 8 21 48 24 4 33 35 13 15 1 3 2 2 8 3 5 1 1 6 1 1 2 1 1 2 2 1 1 2 1 9953\r\n", "output": ["NO"]}, {"input": "4 16\r\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\r\n", "output": ["NO"]}, {"input": "10000 71\r\n110 14 2362 260 423 881 1296 3904 1664 849 57 631 1922 917 4832 1339 3398 4578 59 2663 2223 698 4002 3013 747 699 1230 2750 239 1409 6291 2133 1172 5824 181 797 26 281 574 557 19 82 624 387 278 53 64 163 22 617 15 35 42 48 14 140 171 36 28 22 5 49 17 5 10 14 13 1 3 3 9979\r\n", "output": ["NO"]}, {"input": "3495 83\r\n2775 2523 1178 512 3171 1159 1382 2146 2192 1823 799 231 502 16 99 309 656 665 222 285 11 106 244 137 241 45 41 29 485 6 62 38 94 5 7 93 48 5 10 13 2 1 2 1 4 8 5 9 4 6 1 1 1 3 4 3 7 1 2 3 1 1 7 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 3443\r\n", "output": ["NO"]}, {"input": "1000 40\r\n1701 1203 67 464 1884 761 11 559 29 115 405 133 174 63 147 93 41 19 1 15 41 8 33 4 4 1 4 1 1 2 1 2 1 1 2 1 1 2 1 4\r\n", "output": ["NO"]}, {"input": "347 20\r\n55 390 555 426 140 360 29 115 23 113 58 30 33 1 23 3 35 5 7 363\r\n", "output": ["NO"]}, {"input": "10000 100\r\n749 2244 949 2439 2703 44 2394 124 285 3694 3609 717 1413 155 974 1778 1448 1327 1487 3458 319 1395 3783 2184 2062 43 826 38 3276 807 1837 4635 171 1386 1768 1128 2020 2536 800 782 3058 174 455 83 647 595 658 109 33 23 70 39 38 1 6 35 94 9 22 12 6 1 2 2 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 9940\r\n", "output": ["NO"]}, {"input": "10000 93\r\n1388 119 711 23 4960 4002 2707 188 813 1831 334 543 338 3402 1808 3368 1428 971 985 220 1521 457 457 140 332 1503 1539 2095 1891 269 5223 226 1528 190 428 5061 410 1587 1149 1934 2275 1337 1828 275 181 85 499 29 585 808 751 401 635 461 181 164 274 36 401 255 38 60 76 16 6 35 79 46 1 39 11 2 8 2 4 14 3 1 1 1 1 1 2 1 3 1 1 1 1 2 1 1 9948\r\n", "output": ["NO"]}, {"input": "4981 51\r\n5364 2166 223 742 350 1309 15 229 4100 3988 227 1719 9 125 787 427 141 842 171 2519 32 2554 2253 721 775 88 720 9 397 513 100 291 111 32 238 42 152 108 5 58 96 53 7 19 11 2 5 5 6 2 4966\r\n", "output": ["NO"]}, {"input": "541 31\r\n607 204 308 298 398 213 1182 58 162 46 64 12 38 91 29 2 4 12 19 3 7 9 3 6 1 1 2 1 3 1 529\r\n", "output": ["YES"]}, {"input": "100 100\r\n6 129 61 6 87 104 45 28 3 35 2 14 1 37 2 4 24 4 3 1 6 4 2 1 1 3 1 2 2 9 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 22\r\n", "output": ["NO"]}, {"input": "1 4\r\n2 2 2 1\r\n", "output": ["YES"]}, {"input": "1 3\r\n2 2 2\r\n", "output": ["YES"]}, {"input": "2 5\r\n8 2 2 2 2\r\n", "output": ["YES"]}, {"input": "1 4\r\n1 1 2 2\r\n", "output": ["YES"]}, {"input": "1 3\r\n2 2 3\r\n", "output": ["YES"]}, {"input": "1 3\r\n4 2 2\r\n", "output": ["YES"]}, {"input": "1 4\r\n2 1 2 2\r\n", "output": ["YES"]}, {"input": "1 3\r\n3 2 2\r\n", "output": ["YES"]}, {"input": "2 8\r\n2 2 2 2 2 2 1 1\r\n", "output": ["YES"]}, {"input": "2 6\r\n2 2 2 2 2 2\r\n", "output": ["YES"]}, {"input": "1 4\r\n1 2 2 2\r\n", "output": ["YES"]}, {"input": "1 4\r\n1 1 1 1\r\n", "output": ["YES"]}, {"input": "2 7\r\n2 2 2 2 2 2 2\r\n", "output": ["YES"]}, {"input": "2 8\r\n1 1 1 1 1 1 1 1\r\n", "output": ["YES"]}, {"input": "3 7\r\n12 2 2 2 2 2 2\r\n", "output": ["YES"]}, {"input": "2 6\r\n4 1 3 1 1 3\r\n", "output": ["NO"]}, {"input": "1 3\r\n2 2 4\r\n", "output": ["YES"]}, {"input": "5 15\r\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\r\n", "output": ["YES"]}, {"input": "2 8\r\n2 2 2 2 1 1 1 1\r\n", "output": ["YES"]}, {"input": "1 2\r\n6 2\r\n", "output": ["YES"]}, {"input": "4 13\r\n2 2 2 2 2 2 2 2 2 2 2 2 4\r\n", "output": ["YES"]}, {"input": "2 7\r\n1 1 1 4 2 2 2\r\n", "output": ["YES"]}, {"input": "3 8\r\n8 2 2 2 2 2 2 2\r\n", "output": ["YES"]}, {"input": "2 8\r\n1 1 1 1 2 2 2 2\r\n", "output": ["YES"]}, {"input": "2 8\r\n2 2 2 2 1 1 2 2\r\n", "output": ["YES"]}, {"input": "1 4\r\n2 2 1 1\r\n", "output": ["YES"]}, {"input": "3 9\r\n2 2 2 2 2 2 2 2 2\r\n", "output": ["YES"]}, {"input": "2 6\r\n2 2 2 2 2 5\r\n", "output": ["YES"]}, {"input": "1 1\r\n6\r\n", "output": ["YES"]}, {"input": "2 1\r\n16\r\n", "output": ["YES"]}, {"input": "1 1\r\n2\r\n", "output": ["YES"]}, {"input": "2 8\r\n2 2 2 2 2 2 2 1\r\n", "output": ["NO"]}, {"input": "4 16\r\n1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2\r\n", "output": ["YES"]}, {"input": "2 7\r\n4 1 1 1 1 2 2\r\n", "output": ["YES"]}, {"input": "2 6\r\n2 2 2 5 2 2\r\n", "output": ["YES"]}, {"input": "3 1\r\n22\r\n", "output": ["YES"]}, {"input": "2 8\r\n2 2 2 2 1 1 1 3\r\n", "output": ["NO"]}, {"input": "3 12\r\n2 1 2 2 2 1 2 2 2 1 2 2\r\n", "output": ["YES"]}, {"input": "1 4\r\n2 2 3 1\r\n", "output": ["NO"]}, {"input": "2 6\r\n5 2 2 2 2 2\r\n", "output": ["YES"]}, {"input": "20 100\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n", "output": ["NO"]}, {"input": "1 3\r\n2 2 1\r\n", "output": ["YES"]}, {"input": "1 2\r\n3 3\r\n", "output": ["YES"]}, {"input": "2 6\r\n2 3 2 2 3 2\r\n", "output": ["YES"]}, {"input": "2 8\r\n2 2 1 1 2 2 2 2\r\n", "output": ["YES"]}, {"input": "2 6\r\n3 3 2 2 2 2\r\n", "output": ["YES"]}, {"input": "3 12\r\n2 2 2 2 2 2 2 2 2 1 1 1\r\n", "output": ["YES"]}, {"input": "3 10\r\n2 2 2 2 2 2 2 2 2 3\r\n", "output": ["YES"]}]
100
100
100
[{'input': '1 2\r\n7 1\r\n', 'output': ['NO']}, {'input': '1 3\r\n3 2 2\r\n', 'output': ['YES']}, {'input': '10000 91\r\n2351 1402 1137 2629 4718 1138 1839 1339 2184 2387 165 370 918 1476 2717 879 1152 5367 3940 608 941 766 1256 656 2768 916 4176 489 1989 1633 2725 2329 2795 1970 667 340 1275 120 870 488 225 59 64 255 207 3 37 127 19 224 34 283 144 50 132 60 57 29 18 6 7 4 4 15 3 5 1 10 5 2 3 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 9948\r\n', 'output': ['YES']}, {'input': '2 2\r\n5 8\r\n', 'output': ['YES']}, {'input': '2000 50\r\n203 89 1359 3105 898 1381 248 365 108 766 961 630 265 819 838 125 1751 289 177 81 131 564 102 95 49 74 92 101 19 17 156 5 5 4 20 9 25 16 16 2 8 5 4 2 1 3 4 1 3 2\r\n', 'output': ['NO']}]
[{'input': '3403 59\r\n1269 1612 453 795 1216 941 19 44 1796 324 2019 1397 651 382 841 2003 3013 638 1007 1001 351 95 394 149 125 13 116 183 20 78 208 19 152 10 151 177 16 23 17 22 8 1 3 2 6 1 5 3 13 1 8 4 3 4 4 4 2 2 3378\r\n', 'output': ['YES']}, {'input': '3 12\r\n2 1 2 2 2 1 2 2 2 1 2 2\r\n', 'output': ['YES']}, {'input': '10000 100\r\n749 2244 949 2439 2703 44 2394 124 285 3694 3609 717 1413 155 974 1778 1448 1327 1487 3458 319 1395 3783 2184 2062 43 826 38 3276 807 1837 4635 171 1386 1768 1128 2020 2536 800 782 3058 174 455 83 647 595 658 109 33 23 70 39 38 1 6 35 94 9 22 12 6 1 2 2 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 9939\r\n', 'output': ['NO']}, {'input': '2 6\r\n2 2 2 2 2 2\r\n', 'output': ['YES']}, {'input': '10000 71\r\n110 14 2362 260 423 881 1296 3904 1664 849 57 631 1922 917 4832 1339 3398 4578 59 2663 2223 698 4002 3013 747 699 1230 2750 239 1409 6291 2133 1172 5824 181 797 26 281 574 557 19 82 624 387 278 53 64 163 22 617 15 35 42 48 14 140 171 36 28 22 5 49 17 5 10 14 13 1 3 3 9979\r\n', 'output': ['NO']}]
[{'input': '5691 91\r\n6573 1666 2158 2591 4636 886 263 4217 389 29 1513 1172 617 2012 1855 798 1588 979 152 37 890 375 1091 839 385 382 1 255 117 289 119 224 182 69 19 71 115 13 4 22 35 2 60 12 6 12 19 9 3 2 2 6 5 1 7 7 3 1 5 1 7 1 4 1 1 3 2 1 2 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5631\r\n', 'output': ['NO']}, {'input': '1000 40\r\n1701 1203 67 464 1884 761 11 559 29 115 405 133 174 63 147 93 41 19 1 15 41 8 33 4 4 1 4 1 1 2 1 2 1 1 2 1 1 2 1 4\r\n', 'output': ['NO']}, {'input': '1 4\r\n1 2 2 2\r\n', 'output': ['YES']}, {'input': '3 9\r\n2 2 2 2 2 2 2 2 2\r\n', 'output': ['YES']}, {'input': '1 1\r\n2\r\n', 'output': ['YES']}]
[{'input': '1 1\r\n2\r\n', 'output': ['YES']}, {'input': '1 2\r\n4 4\r\n', 'output': ['YES']}, {'input': '2 6\r\n4 1 3 1 1 3\r\n', 'output': ['NO']}, {'input': '5 15\r\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\r\n', 'output': ['YES']}, {'input': '1 2\r\n6 2\r\n', 'output': ['YES']}]
[{'input': '2 6\r\n5 2 2 2 2 2\r\n', 'output': ['YES']}, {'input': '3 8\r\n8 2 2 2 2 2 2 2\r\n', 'output': ['YES']}, {'input': '3 12\r\n2 1 2 2 2 1 2 2 2 1 2 2\r\n', 'output': ['YES']}, {'input': '1 4\r\n1 1 2 2\r\n', 'output': ['YES']}, {'input': '2 2\r\n5 8\r\n', 'output': ['YES']}]
100
100
100
100
100
95.92
95.92
95.92
95.92
91.84
85.71
85.71
89.29
89.29
78.57
194
100
95.104
85.714
["tour", "Codeforces", "aBAcAba"]
The first line represents input string of Petya's program. This string only consists of uppercase and lowercase Latin letters and its length is from 1 to 100, inclusive.
db9520e85b3e9186dd3a09ff8d1e8c1b
#include<cstdio> #include<cstring> char str[101]; int main() { scanf("%s", str); int len = strlen(str); for (int i = 0; i < len; ++i) { if (str[i] < 'a') str[i] += 32; if (str[i] != 'a' && str[i] != 'e' && str[i] != 'i' && str[i] != 'o' && str[i] != 'u' && str[i] != 'y') printf(".%c", str[i]); } return 0; }
[".t.r", ".c.d.f.r.c.s", ".b.c.b"]
C++
null
Print the resulting string. It is guaranteed that this string is not empty.
Petya started to attend programming lessons. On the first lesson his task was to write a simple program. The program was supposed to do the following: in the given string, consisting if uppercase and lowercase Latin letters, it: deletes all the vowels, inserts a character "." before each consonant, replaces all uppercase consonants with corresponding lowercase ones. Vowels are letters "A", "O", "Y", "E", "U", "I", and the rest are consonants. The program's input is exactly one string, it should return the output as a single string, resulting after the program's processing the initial string.Help Petya cope with this easy task.
[{"input": "tour\r\n", "output": [".t.r"]}, {"input": "Codeforces\r\n", "output": [".c.d.f.r.c.s"]}, {"input": "aBAcAba\r\n", "output": [".b.c.b"]}, {"input": "obn\r\n", "output": [".b.n"]}, {"input": "wpwl\r\n", "output": [".w.p.w.l"]}, {"input": "ggdvq\r\n", "output": [".g.g.d.v.q"]}, {"input": "pumesz\r\n", "output": [".p.m.s.z"]}, {"input": "g\r\n", "output": [".g"]}, {"input": "zjuotps\r\n", "output": [".z.j.t.p.s"]}, {"input": "jzbwuehe\r\n", "output": [".j.z.b.w.h"]}, {"input": "tnkgwuugu\r\n", "output": [".t.n.k.g.w.g"]}, {"input": "kincenvizh\r\n", "output": [".k.n.c.n.v.z.h"]}, {"input": "xattxjenual\r\n", "output": [".x.t.t.x.j.n.l"]}, {"input": "ktajqhpqsvhw\r\n", "output": [".k.t.j.q.h.p.q.s.v.h.w"]}, {"input": "xnhcigytnqcmy\r\n", "output": [".x.n.h.c.g.t.n.q.c.m"]}, {"input": "jfmtbejyilxcec\r\n", "output": [".j.f.m.t.b.j.l.x.c.c"]}, {"input": "D\r\n", "output": [".d"]}, {"input": "ab\r\n", "output": [".b"]}, {"input": "Ab\r\n", "output": [".b"]}, {"input": "aB\r\n", "output": [".b"]}, {"input": "AB\r\n", "output": [".b"]}, {"input": "ba\r\n", "output": [".b"]}, {"input": "bA\r\n", "output": [".b"]}, {"input": "Ba\r\n", "output": [".b"]}, {"input": "BA\r\n", "output": [".b"]}, {"input": "aab\r\n", "output": [".b"]}, {"input": "baa\r\n", "output": [".b"]}, {"input": "femOZeCArKCpUiHYnbBPTIOFmsHmcpObtPYcLCdjFrUMIyqYzAokKUiiKZRouZiNMoiOuGVoQzaaCAOkquRjmmKKElLNqCnhGdQM\r\n", "output": [".f.m.z.c.r.k.c.p.h.n.b.b.p.t.f.m.s.h.m.c.p.b.t.p.c.l.c.d.j.f.r.m.q.z.k.k.k.z.r.z.n.m.g.v.q.z.c.k.q.r.j.m.m.k.k.l.l.n.q.c.n.h.g.d.q.m"]}, {"input": "VMBPMCmMDCLFELLIISUJDWQRXYRDGKMXJXJHXVZADRZWVWJRKFRRNSAWKKDPZZLFLNSGUNIVJFBEQsMDHSBJVDTOCSCgZWWKvZZN\r\n", "output": [".v.m.b.p.m.c.m.m.d.c.l.f.l.l.s.j.d.w.q.r.x.r.d.g.k.m.x.j.x.j.h.x.v.z.d.r.z.w.v.w.j.r.k.f.r.r.n.s.w.k.k.d.p.z.z.l.f.l.n.s.g.n.v.j.f.b.q.s.m.d.h.s.b.j.v.d.t.c.s.c.g.z.w.w.k.v.z.z.n"]}, {"input": "MCGFQQJNUKuAEXrLXibVjClSHjSxmlkQGTKZrRaDNDomIPOmtSgjJAjNVIVLeUGUAOHNkCBwNObVCHOWvNkLFQQbFnugYVMkJruJ\r\n", "output": [".m.c.g.f.q.q.j.n.k.x.r.l.x.b.v.j.c.l.s.h.j.s.x.m.l.k.q.g.t.k.z.r.r.d.n.d.m.p.m.t.s.g.j.j.j.n.v.v.l.g.h.n.k.c.b.w.n.b.v.c.h.w.v.n.k.l.f.q.q.b.f.n.g.v.m.k.j.r.j"]}, {"input": "iyaiuiwioOyzUaOtAeuEYcevvUyveuyioeeueoeiaoeiavizeeoeyYYaaAOuouueaUioueauayoiuuyiuovyOyiyoyioaoyuoyea\r\n", "output": [".w.z.t.c.v.v.v.v.z.v"]}, {"input": "yjnckpfyLtzwjsgpcrgCfpljnjwqzgVcufnOvhxplvflxJzqxnhrwgfJmPzifgubvspffmqrwbzivatlmdiBaddiaktdsfPwsevl\r\n", "output": [".j.n.c.k.p.f.l.t.z.w.j.s.g.p.c.r.g.c.f.p.l.j.n.j.w.q.z.g.v.c.f.n.v.h.x.p.l.v.f.l.x.j.z.q.x.n.h.r.w.g.f.j.m.p.z.f.g.b.v.s.p.f.f.m.q.r.w.b.z.v.t.l.m.d.b.d.d.k.t.d.s.f.p.w.s.v.l"]}, {"input": "RIIIUaAIYJOiuYIUWFPOOAIuaUEZeIooyUEUEAoIyIHYOEAlVAAIiLUAUAeiUIEiUMuuOiAgEUOIAoOUYYEYFEoOIIVeOOAOIIEg\r\n", "output": [".r.j.w.f.p.z.h.l.v.l.m.g.f.v.g"]}, {"input": "VBKQCFBMQHDMGNSGBQVJTGQCNHHRJMNKGKDPPSQRRVQTZNKBZGSXBPBRXPMVFTXCHZMSJVBRNFNTHBHGJLMDZJSVPZZBCCZNVLMQ\r\n", "output": [".v.b.k.q.c.f.b.m.q.h.d.m.g.n.s.g.b.q.v.j.t.g.q.c.n.h.h.r.j.m.n.k.g.k.d.p.p.s.q.r.r.v.q.t.z.n.k.b.z.g.s.x.b.p.b.r.x.p.m.v.f.t.x.c.h.z.m.s.j.v.b.r.n.f.n.t.h.b.h.g.j.l.m.d.z.j.s.v.p.z.z.b.c.c.z.n.v.l.m.q"]}, {"input": "iioyoaayeuyoolyiyoeuouiayiiuyTueyiaoiueyioiouyuauouayyiaeoeiiigmioiououeieeeyuyyaYyioiiooaiuouyoeoeg\r\n", "output": [".l.t.g.m.g"]}, {"input": "ueyiuiauuyyeueykeioouiiauzoyoeyeuyiaoaiiaaoaueyaeydaoauexuueafouiyioueeaaeyoeuaueiyiuiaeeayaioeouiuy\r\n", "output": [".k.z.d.x.f"]}, {"input": "FSNRBXLFQHZXGVMKLQDVHWLDSLKGKFMDRQWMWSSKPKKQBNDZRSCBLRSKCKKFFKRDMZFZGCNSMXNPMZVDLKXGNXGZQCLRTTDXLMXQ\r\n", "output": [".f.s.n.r.b.x.l.f.q.h.z.x.g.v.m.k.l.q.d.v.h.w.l.d.s.l.k.g.k.f.m.d.r.q.w.m.w.s.s.k.p.k.k.q.b.n.d.z.r.s.c.b.l.r.s.k.c.k.k.f.f.k.r.d.m.z.f.z.g.c.n.s.m.x.n.p.m.z.v.d.l.k.x.g.n.x.g.z.q.c.l.r.t.t.d.x.l.m.x.q"]}, {"input": "EYAYAYIOIOYOOAUOEUEUOUUYIYUUMOEOIIIAOIUOAAOIYOIOEUIERCEYYAOIOIGYUIAOYUEOEUAEAYPOYEYUUAUOAOEIYIEYUEEY\r\n", "output": [".m.r.c.g.p"]}, {"input": "jvvzcdcxjstbbksmqjsngxkgtttdxrljjxtwptgwwqzpvqchvgrkqlzxmptzblxhhsmrkmzzmgdfskhtmmnqzzflpmqdctvrfgtx\r\n", "output": [".j.v.v.z.c.d.c.x.j.s.t.b.b.k.s.m.q.j.s.n.g.x.k.g.t.t.t.d.x.r.l.j.j.x.t.w.p.t.g.w.w.q.z.p.v.q.c.h.v.g.r.k.q.l.z.x.m.p.t.z.b.l.x.h.h.s.m.r.k.m.z.z.m.g.d.f.s.k.h.t.m.m.n.q.z.z.f.l.p.m.q.d.c.t.v.r.f.g.t.x"]}, {"input": "YB\r\n", "output": [".b"]}, {"input": "fly\r\n", "output": [".f.l"]}, {"input": "YyyYYYyyYxdwdawdDAWDdaddYYYY\r\n", "output": [".x.d.w.d.w.d.d.w.d.d.d.d"]}, {"input": "SDTFZPLMKFLZGTRPLMQVHTMCDFWPKZNZMHQDSWZKBZFFWZVJKGNDHRBGTVGKNCQRVFCXPSNBVVBGQNVN\r\n", "output": [".s.d.t.f.z.p.l.m.k.f.l.z.g.t.r.p.l.m.q.v.h.t.m.c.d.f.w.p.k.z.n.z.m.h.q.d.s.w.z.k.b.z.f.f.w.z.v.j.k.g.n.d.h.r.b.g.t.v.g.k.n.c.q.r.v.f.c.x.p.s.n.b.v.v.b.g.q.n.v.n"]}, {"input": "QKFSVTNJRDJGLWTHXHWRNVFHFSCSGWTCNBVBXVWDBMZPLGWFKXNLJMGTGFHQJTZZRBVSZDTHZWJSFWRNZV\r\n", "output": [".q.k.f.s.v.t.n.j.r.d.j.g.l.w.t.h.x.h.w.r.n.v.f.h.f.s.c.s.g.w.t.c.n.b.v.b.x.v.w.d.b.m.z.p.l.g.w.f.k.x.n.l.j.m.g.t.g.f.h.q.j.t.z.z.r.b.v.s.z.d.t.h.z.w.j.s.f.w.r.n.z.v"]}, {"input": "MFZHRXPFZCQWHKGJLBDNGWWNGSQJNSCGPSPJSLDXZZGPPVKBZGNSKGLJHCKVFNJGNHPPLFBZMPHFSRXMPHBN\r\n", "output": [".m.f.z.h.r.x.p.f.z.c.q.w.h.k.g.j.l.b.d.n.g.w.w.n.g.s.q.j.n.s.c.g.p.s.p.j.s.l.d.x.z.z.g.p.p.v.k.b.z.g.n.s.k.g.l.j.h.c.k.v.f.n.j.g.n.h.p.p.l.f.b.z.m.p.h.f.s.r.x.m.p.h.b.n"]}, {"input": "KBTTNSRZRBNDMMSBZVKKMZPDHHTNKQJXPMTGXLBJZLBZDLVWBWPPLLZMKBLQBGRMLDXKGQHQQRQRWBTMTRTBWM\r\n", "output": [".k.b.t.t.n.s.r.z.r.b.n.d.m.m.s.b.z.v.k.k.m.z.p.d.h.h.t.n.k.q.j.x.p.m.t.g.x.l.b.j.z.l.b.z.d.l.v.w.b.w.p.p.l.l.z.m.k.b.l.q.b.g.r.m.l.d.x.k.g.q.h.q.q.r.q.r.w.b.t.m.t.r.t.b.w.m"]}, {"input": "HWPJKXTVZXLJSPGCMPQGSLWKXGJDHMPCQFNDCLWDXXWZHRXSQPPWMFFBLXNWGXZTHKQFRBXJSJPPLVQMXDZWLBWC\r\n", "output": [".h.w.p.j.k.x.t.v.z.x.l.j.s.p.g.c.m.p.q.g.s.l.w.k.x.g.j.d.h.m.p.c.q.f.n.d.c.l.w.d.x.x.w.z.h.r.x.s.q.p.p.w.m.f.f.b.l.x.n.w.g.x.z.t.h.k.q.f.r.b.x.j.s.j.p.p.l.v.q.m.x.d.z.w.l.b.w.c"]}, {"input": "SJMBDQJRZGCFHRVKQCTGTJJQSMWVVBFSJVHKLLWBNRTNXJXXMLLVVZJZNLLXLPJWQSXKKWGWCMHVFPHMDRHMZPQHGQ\r\n", "output": [".s.j.m.b.d.q.j.r.z.g.c.f.h.r.v.k.q.c.t.g.t.j.j.q.s.m.w.v.v.b.f.s.j.v.h.k.l.l.w.b.n.r.t.n.x.j.x.x.m.l.l.v.v.z.j.z.n.l.l.x.l.p.j.w.q.s.x.k.k.w.g.w.c.m.h.v.f.p.h.m.d.r.h.m.z.p.q.h.g.q"]}, {"input": "MSPPDBGPBTFRCQBSSJXCNXZLCTDPBGJCCJDJNSZVVDFNKBBZKVLQXJHQMQBXHTMRKRSLGZVRFCTBWJWNBTPQLQLCFHNK\r\n", "output": [".m.s.p.p.d.b.g.p.b.t.f.r.c.q.b.s.s.j.x.c.n.x.z.l.c.t.d.p.b.g.j.c.c.j.d.j.n.s.z.v.v.d.f.n.k.b.b.z.k.v.l.q.x.j.h.q.m.q.b.x.h.t.m.r.k.r.s.l.g.z.v.r.f.c.t.b.w.j.w.n.b.t.p.q.l.q.l.c.f.h.n.k"]}, {"input": "GSSMNBNMDZXFMGVDFFDJSXQGKCZJRKXLVMZWCBDQCNPNGSDPWWCMKRRHKWRNDJRVDQNNMDBMWRRRDSCNXXVTMRFHDXZKWW\r\n", "output": [".g.s.s.m.n.b.n.m.d.z.x.f.m.g.v.d.f.f.d.j.s.x.q.g.k.c.z.j.r.k.x.l.v.m.z.w.c.b.d.q.c.n.p.n.g.s.d.p.w.w.c.m.k.r.r.h.k.w.r.n.d.j.r.v.d.q.n.n.m.d.b.m.w.r.r.r.d.s.c.n.x.x.v.t.m.r.f.h.d.x.z.k.w.w"]}, {"input": "PDLBZLWTVPBBWGCMRLWFMMRBDTFCHFMTPZGVFJWTZPZCBLGPTHRRWBRWJCRNXNVBHQTQJHQQZHFHVMRXHBCMWSXNCPBTFFFZ\r\n", "output": [".p.d.l.b.z.l.w.t.v.p.b.b.w.g.c.m.r.l.w.f.m.m.r.b.d.t.f.c.h.f.m.t.p.z.g.v.f.j.w.t.z.p.z.c.b.l.g.p.t.h.r.r.w.b.r.w.j.c.r.n.x.n.v.b.h.q.t.q.j.h.q.q.z.h.f.h.v.m.r.x.h.b.c.m.w.s.x.n.c.p.b.t.f.f.f.z"]}, {"input": "JDPZZLTQXFDNSFWVFRBBGCJVMCBVWJRDJCCKSQBPGBTCMDSGHRHNKKRNQHJNTRBFBPPRPKGLRXSWMGHXFDTQJSRJBFMTWMFRWJ\r\n", "output": [".j.d.p.z.z.l.t.q.x.f.d.n.s.f.w.v.f.r.b.b.g.c.j.v.m.c.b.v.w.j.r.d.j.c.c.k.s.q.b.p.g.b.t.c.m.d.s.g.h.r.h.n.k.k.r.n.q.h.j.n.t.r.b.f.b.p.p.r.p.k.g.l.r.x.s.w.m.g.h.x.f.d.t.q.j.s.r.j.b.f.m.t.w.m.f.r.w.j"]}, {"input": "GSFSDNNTRGXKGPGNJBWCMSMCNHSMFWMNGGXLPTJXZDSNMLJNSXQDGLLJBMJJQGPXGGQGPHBQPNHJSFPBQKMZLTWCSKKQSDCCXJTW\r\n", "output": [".g.s.f.s.d.n.n.t.r.g.x.k.g.p.g.n.j.b.w.c.m.s.m.c.n.h.s.m.f.w.m.n.g.g.x.l.p.t.j.x.z.d.s.n.m.l.j.n.s.x.q.d.g.l.l.j.b.m.j.j.q.g.p.x.g.g.q.g.p.h.b.q.p.n.h.j.s.f.p.b.q.k.m.z.l.t.w.c.s.k.k.q.s.d.c.c.x.j.t.w"]}]
100
100
100
[{'input': 'Ab\r\n', 'output': ['.b']}, {'input': 'YB\r\n', 'output': ['.b']}, {'input': 'jvvzcdcxjstbbksmqjsngxkgtttdxrljjxtwptgwwqzpvqchvgrkqlzxmptzblxhhsmrkmzzmgdfskhtmmnqzzflpmqdctvrfgtx\r\n', 'output': ['.j.v.v.z.c.d.c.x.j.s.t.b.b.k.s.m.q.j.s.n.g.x.k.g.t.t.t.d.x.r.l.j.j.x.t.w.p.t.g.w.w.q.z.p.v.q.c.h.v.g.r.k.q.l.z.x.m.p.t.z.b.l.x.h.h.s.m.r.k.m.z.z.m.g.d.f.s.k.h.t.m.m.n.q.z.z.f.l.p.m.q.d.c.t.v.r.f.g.t.x']}, {'input': 'JDPZZLTQXFDNSFWVFRBBGCJVMCBVWJRDJCCKSQBPGBTCMDSGHRHNKKRNQHJNTRBFBPPRPKGLRXSWMGHXFDTQJSRJBFMTWMFRWJ\r\n', 'output': ['.j.d.p.z.z.l.t.q.x.f.d.n.s.f.w.v.f.r.b.b.g.c.j.v.m.c.b.v.w.j.r.d.j.c.c.k.s.q.b.p.g.b.t.c.m.d.s.g.h.r.h.n.k.k.r.n.q.h.j.n.t.r.b.f.b.p.p.r.p.k.g.l.r.x.s.w.m.g.h.x.f.d.t.q.j.s.r.j.b.f.m.t.w.m.f.r.w.j']}, {'input': 'SDTFZPLMKFLZGTRPLMQVHTMCDFWPKZNZMHQDSWZKBZFFWZVJKGNDHRBGTVGKNCQRVFCXPSNBVVBGQNVN\r\n', 'output': ['.s.d.t.f.z.p.l.m.k.f.l.z.g.t.r.p.l.m.q.v.h.t.m.c.d.f.w.p.k.z.n.z.m.h.q.d.s.w.z.k.b.z.f.f.w.z.v.j.k.g.n.d.h.r.b.g.t.v.g.k.n.c.q.r.v.f.c.x.p.s.n.b.v.v.b.g.q.n.v.n']}]
[{'input': 'pumesz\r\n', 'output': ['.p.m.s.z']}, {'input': 'iioyoaayeuyoolyiyoeuouiayiiuyTueyiaoiueyioiouyuauouayyiaeoeiiigmioiououeieeeyuyyaYyioiiooaiuouyoeoeg\r\n', 'output': ['.l.t.g.m.g']}, {'input': 'jfmtbejyilxcec\r\n', 'output': ['.j.f.m.t.b.j.l.x.c.c']}, {'input': 'SDTFZPLMKFLZGTRPLMQVHTMCDFWPKZNZMHQDSWZKBZFFWZVJKGNDHRBGTVGKNCQRVFCXPSNBVVBGQNVN\r\n', 'output': ['.s.d.t.f.z.p.l.m.k.f.l.z.g.t.r.p.l.m.q.v.h.t.m.c.d.f.w.p.k.z.n.z.m.h.q.d.s.w.z.k.b.z.f.f.w.z.v.j.k.g.n.d.h.r.b.g.t.v.g.k.n.c.q.r.v.f.c.x.p.s.n.b.v.v.b.g.q.n.v.n']}, {'input': 'BA\r\n', 'output': ['.b']}]
[{'input': 'bA\r\n', 'output': ['.b']}, {'input': 'D\r\n', 'output': ['.d']}, {'input': 'YB\r\n', 'output': ['.b']}, {'input': 'ktajqhpqsvhw\r\n', 'output': ['.k.t.j.q.h.p.q.s.v.h.w']}, {'input': 'QKFSVTNJRDJGLWTHXHWRNVFHFSCSGWTCNBVBXVWDBMZPLGWFKXNLJMGTGFHQJTZZRBVSZDTHZWJSFWRNZV\r\n', 'output': ['.q.k.f.s.v.t.n.j.r.d.j.g.l.w.t.h.x.h.w.r.n.v.f.h.f.s.c.s.g.w.t.c.n.b.v.b.x.v.w.d.b.m.z.p.l.g.w.f.k.x.n.l.j.m.g.t.g.f.h.q.j.t.z.z.r.b.v.s.z.d.t.h.z.w.j.s.f.w.r.n.z.v']}]
[{'input': 'MFZHRXPFZCQWHKGJLBDNGWWNGSQJNSCGPSPJSLDXZZGPPVKBZGNSKGLJHCKVFNJGNHPPLFBZMPHFSRXMPHBN\r\n', 'output': ['.m.f.z.h.r.x.p.f.z.c.q.w.h.k.g.j.l.b.d.n.g.w.w.n.g.s.q.j.n.s.c.g.p.s.p.j.s.l.d.x.z.z.g.p.p.v.k.b.z.g.n.s.k.g.l.j.h.c.k.v.f.n.j.g.n.h.p.p.l.f.b.z.m.p.h.f.s.r.x.m.p.h.b.n']}, {'input': 'obn\r\n', 'output': ['.b.n']}, {'input': 'tour\r\n', 'output': ['.t.r']}, {'input': 'QKFSVTNJRDJGLWTHXHWRNVFHFSCSGWTCNBVBXVWDBMZPLGWFKXNLJMGTGFHQJTZZRBVSZDTHZWJSFWRNZV\r\n', 'output': ['.q.k.f.s.v.t.n.j.r.d.j.g.l.w.t.h.x.h.w.r.n.v.f.h.f.s.c.s.g.w.t.c.n.b.v.b.x.v.w.d.b.m.z.p.l.g.w.f.k.x.n.l.j.m.g.t.g.f.h.q.j.t.z.z.r.b.v.s.z.d.t.h.z.w.j.s.f.w.r.n.z.v']}, {'input': 'tnkgwuugu\r\n', 'output': ['.t.n.k.g.w.g']}]
[{'input': 'obn\r\n', 'output': ['.b.n']}, {'input': 'Codeforces\r\n', 'output': ['.c.d.f.r.c.s']}, {'input': 'Ab\r\n', 'output': ['.b']}, {'input': 'SDTFZPLMKFLZGTRPLMQVHTMCDFWPKZNZMHQDSWZKBZFFWZVJKGNDHRBGTVGKNCQRVFCXPSNBVVBGQNVN\r\n', 'output': ['.s.d.t.f.z.p.l.m.k.f.l.z.g.t.r.p.l.m.q.v.h.t.m.c.d.f.w.p.k.z.n.z.m.h.q.d.s.w.z.k.b.z.f.f.w.z.v.j.k.g.n.d.h.r.b.g.t.v.g.k.n.c.q.r.v.f.c.x.p.s.n.b.v.v.b.g.q.n.v.n']}, {'input': 'AB\r\n', 'output': ['.b']}]
100
100
100
100
100
100
100
100
100
100
75
100
75
75
81.25
195
100
100
81.25
["4\n6 5\n16 13\n61690850361 24777622630\n34 33"]
The first line contains a number $$$t$$$ ($$$1 \leq t \leq 5$$$) — the number of test cases. Each of the next $$$t$$$ lines describes the $$$i$$$-th test case. It contains two integers $$$a$$$ and $$$b~(1 \leq b &lt; a \leq 10^{11})$$$ — the side length of Alice's square and the side length of the square that Bob wants.
5a052e4e6c64333d94c83df890b1183c
#include<bits/stdc++.h> using namespace std; int T; long long a,b; /*long long cf(long long x,long long n,long long p) { if(!n) return 1; long long ans=cf(x,n/2,p); ans=(ans%p)*(ans%p); if(n%2) ans=((ans%p)*(x%p))%p; return ans%p; } bool miller_rabin(long long n) { long long i,j,aa,x,y,t,u,s=10; if(n==2) return true; if(n<2||!(n&1)) return false; for(t=0,u=n-1;!(u&1);t++,u>>=1); for(i=0;i<s;i++) { aa=rand()%(n-1)+1; x=cf(aa,u,n); for(j=0;j<t;j++) { y=x*x%n; if(y==1&&x!=1&&x!=n-1) return false; x=y; } if(x!=1) return false; } return true; }*/ inline bool is_prime(long long x){ long long s=(long long)sqrt((double)x+1.0); for(register long long i=2;i<=s;i++) if(!(x%i)) return false; return true; } int main(){ cin>>T; while(T--){ cin>>a>>b; if(a<=(b+1)){ if(is_prime(a+b)) printf("YES\n"); else printf("NO\n"); } else printf("NO\n"); } return 0; }
["YES\nNO\nNO\nYES"]
C++
NoteThe figure below depicts the first test case. The blue part corresponds to the piece which belongs to Bob, and the red part is the piece that Alice keeps for herself. The area of the red part is $$$6^2 - 5^2 = 36 - 25 = 11$$$, which is prime, so the answer is "YES". In the second case, the area is $$$16^2 - 13^2 = 87$$$, which is divisible by $$$3$$$. In the third case, the area of the remaining piece is $$$61690850361^2 - 24777622630^2 = 3191830435068605713421$$$. This number is not prime because $$$3191830435068605713421 = 36913227731 \cdot 86468472991 $$$.In the last case, the area is $$$34^2 - 33^2 = 67$$$.
Print $$$t$$$ lines, where the $$$i$$$-th line is the answer to the $$$i$$$-th test case. Print "YES" (without quotes) if the area of the remaining piece of cloth is prime, otherwise print "NO". You can print each letter in an arbitrary case (upper or lower).
Alice has a lovely piece of cloth. It has the shape of a square with a side of length $$$a$$$ centimeters. Bob also wants such piece of cloth. He would prefer a square with a side of length $$$b$$$ centimeters (where $$$b &lt; a$$$). Alice wanted to make Bob happy, so she cut the needed square out of the corner of her piece and gave it to Bob. Now she is left with an ugly L shaped cloth (see pictures below).Alice would like to know whether the area of her cloth expressed in square centimeters is prime. Could you help her to determine it?
[{"input": "4\r\n6 5\r\n16 13\r\n61690850361 24777622630\r\n34 33\r\n", "output": ["yes\r\nno\r\nno\r\nyes", "YES\r\nNO\r\nNO\r\nYES"]}, {"input": "5\r\n160 159\r\n223 222\r\n480 479\r\n357 356\r\n345 344\r\n", "output": ["NO\r\nNO\r\nNO\r\nNO\r\nNO", "no\r\nno\r\nno\r\nno\r\nno"]}, {"input": "5\r\n631 582\r\n201 106\r\n780 735\r\n608 528\r\n470 452\r\n", "output": ["NO\r\nNO\r\nNO\r\nNO\r\nNO", "no\r\nno\r\nno\r\nno\r\nno"]}, {"input": "5\r\n2 1\r\n3 1\r\n4 1\r\n5 1\r\n8 7\r\n", "output": ["yes\r\nno\r\nno\r\nno\r\nno", "YES\r\nNO\r\nNO\r\nNO\r\nNO"]}, {"input": "5\r\n2187 2186\r\n517 516\r\n3235 3234\r\n4810 4809\r\n3076 3075\r\n", "output": ["yes\r\nyes\r\nyes\r\nyes\r\nyes", "YES\r\nYES\r\nYES\r\nYES\r\nYES"]}, {"input": "5\r\n40957587394 40957587393\r\n46310781841 46310781840\r\n21618631676 21618631675\r\n17162988704 17162988703\r\n16831085306 16831085305\r\n", "output": ["NO\r\nNO\r\nNO\r\nNO\r\nNO", "no\r\nno\r\nno\r\nno\r\nno"]}, {"input": "5\r\n35838040099 35838040098\r\n26612022790 26612022789\r\n23649629085 23649629084\r\n17783940691 17783940690\r\n31547284201 31547284200\r\n", "output": ["yes\r\nyes\r\nyes\r\nyes\r\nyes", "YES\r\nYES\r\nYES\r\nYES\r\nYES"]}, {"input": "5\r\n45967567181 17972496150\r\n96354194442 71676080197\r\n66915115533 22181324318\r\n62275223621 22258625262\r\n92444726334 84313947726\r\n", "output": ["NO\r\nNO\r\nNO\r\nNO\r\nNO", "no\r\nno\r\nno\r\nno\r\nno"]}, {"input": "5\r\n77734668390 12890100149\r\n62903604396 24274903133\r\n22822672980 7380491861\r\n50311650674 7380960075\r\n63911598474 3692382643\r\n", "output": ["NO\r\nNO\r\nNO\r\nNO\r\nNO", "no\r\nno\r\nno\r\nno\r\nno"]}, {"input": "5\r\n21 20\r\n48 47\r\n59140946515 26225231058\r\n78 38\r\n31 30\r\n", "output": ["YES\r\nNO\r\nNO\r\nNO\r\nYES", "yes\r\nno\r\nno\r\nno\r\nyes"]}, {"input": "5\r\n529 169\r\n232 231\r\n283 282\r\n217 216\r\n34310969148 14703433301\r\n", "output": ["NO\r\nYES\r\nNO\r\nYES\r\nNO", "no\r\nyes\r\nno\r\nyes\r\nno"]}, {"input": "1\r\n100000000000 99999999999\r\n", "output": ["NO", "no"]}, {"input": "5\r\n8680 4410\r\n59011181086 3472811643\r\n770 769\r\n1911 1910\r\n3615 3614\r\n", "output": ["no\r\nno\r\nno\r\nyes\r\nyes", "NO\r\nNO\r\nNO\r\nYES\r\nYES"]}, {"input": "5\r\n62903604396 24274903133\r\n37198 37197\r\n16929 16928\r\n38325 38324\r\n49905 33035\r\n", "output": ["no\r\nno\r\nyes\r\nyes\r\nno", "NO\r\nNO\r\nYES\r\nYES\r\nNO"]}, {"input": "5\r\n5 4\r\n7 6\r\n4 3\r\n4 1\r\n9 8\r\n", "output": ["NO\r\nYES\r\nYES\r\nNO\r\nYES", "no\r\nyes\r\nyes\r\nno\r\nyes"]}, {"input": "5\r\n497334 497333\r\n437006 437005\r\n88531320027 6466043806\r\n863754 694577\r\n151084 151083\r\n", "output": ["YES\r\nNO\r\nNO\r\nNO\r\nYES", "yes\r\nno\r\nno\r\nno\r\nyes"]}, {"input": "5\r\n4606204 4606203\r\n1620972 1620971\r\n67109344913 14791364910\r\n8894157 3383382\r\n4110450 4110449\r\n", "output": ["NO\r\nYES\r\nNO\r\nNO\r\nYES", "no\r\nyes\r\nno\r\nno\r\nyes"]}, {"input": "5\r\n24095027715 9551467282\r\n34945375 34945374\r\n16603803 16603802\r\n58997777 26551505\r\n39762660 39762659\r\n", "output": ["NO\r\nYES\r\nNO\r\nNO\r\nYES", "no\r\nyes\r\nno\r\nno\r\nyes"]}, {"input": "5\r\n313997256 313997255\r\n224581770 224581769\r\n549346780 476752290\r\n60559465837 28745119200\r\n274287972 274287971\r\n", "output": ["YES\r\nNO\r\nNO\r\nNO\r\nYES", "yes\r\nno\r\nno\r\nno\r\nyes"]}, {"input": "2\r\n10 9\r\n3 2\r\n", "output": ["yes\r\nyes", "YES\r\nYES"]}, {"input": "5\r\n31125459810 8334535873\r\n3439858310 3439858309\r\n9242031363 5238155938\r\n1025900247 1025900246\r\n3754943269 3754943268\r\n", "output": ["no\r\nno\r\nno\r\nyes\r\nyes", "NO\r\nNO\r\nNO\r\nYES\r\nYES"]}, {"input": "5\r\n81271189833 16089352976\r\n98451628984 76827432884\r\n19327420986 19327420985\r\n15702367716 15702367715\r\n49419997643 49419997642\r\n", "output": ["no\r\nno\r\nyes\r\nyes\r\nno", "NO\r\nNO\r\nYES\r\nYES\r\nNO"]}, {"input": "5\r\n41024865848 173372595\r\n60687612551 33296061228\r\n64391844305 16241932104\r\n81009941361 1976380712\r\n58548577555 28344963216\r\n", "output": ["NO\r\nNO\r\nNO\r\nNO\r\nNO", "no\r\nno\r\nno\r\nno\r\nno"]}, {"input": "5\r\n18975453681 18975453680\r\n33749667489 33749667488\r\n32212198515 32212198514\r\n39519664171 39519664170\r\n5846685141 5846685140\r\n", "output": ["yes\r\nyes\r\nyes\r\nyes\r\nyes", "YES\r\nYES\r\nYES\r\nYES\r\nYES"]}, {"input": "5\r\n11065751057 11065751056\r\n14816488910 14816488909\r\n7599636437 7599636436\r\n32868029728 32868029727\r\n29658708183 29658708182\r\n", "output": ["NO\r\nNO\r\nNO\r\nNO\r\nNO", "no\r\nno\r\nno\r\nno\r\nno"]}, {"input": "5\r\n61150570394 22605752451\r\n64903938253 57679397316\r\n79673778456 37950907361\r\n59209507183 35302232713\r\n88726603470 50246884625\r\n", "output": ["NO\r\nNO\r\nNO\r\nNO\r\nNO", "no\r\nno\r\nno\r\nno\r\nno"]}, {"input": "5\r\n45925060463 34682596536\r\n34161192623 19459231506\r\n74417875602 23392925845\r\n58874966000 740257587\r\n64371611777 32770840566\r\n", "output": ["NO\r\nNO\r\nNO\r\nNO\r\nNO", "no\r\nno\r\nno\r\nno\r\nno"]}, {"input": "5\r\n17406961899 17406961898\r\n21570966087 21570966086\r\n31354673689 31354673688\r\n24493273605 24493273604\r\n44187316822 44187316821\r\n", "output": ["yes\r\nyes\r\nyes\r\nyes\r\nyes", "YES\r\nYES\r\nYES\r\nYES\r\nYES"]}, {"input": "5\r\n49948848825 49948848824\r\n33118965298 33118965297\r\n34285673904 34285673903\r\n46923258767 46923258766\r\n48431110341 48431110340\r\n", "output": ["NO\r\nNO\r\nNO\r\nNO\r\nNO", "no\r\nno\r\nno\r\nno\r\nno"]}, {"input": "5\r\n38196676529 10033677341\r\n76701388169 39387747140\r\n96968196508 53479702571\r\n98601117347 56935774756\r\n89303447903 62932115422\r\n", "output": ["NO\r\nNO\r\nNO\r\nNO\r\nNO", "no\r\nno\r\nno\r\nno\r\nno"]}, {"input": "5\r\n84969448764 45272932776\r\n40645404603 21303358412\r\n95260279132 55067325137\r\n92908555827 18951498996\r\n73854112015 59320860713\r\n", "output": ["NO\r\nNO\r\nNO\r\nNO\r\nNO", "no\r\nno\r\nno\r\nno\r\nno"]}, {"input": "1\r\n5 4\r\n", "output": ["NO", "no"]}, {"input": "1\r\n25 24\r\n", "output": ["NO", "no"]}, {"input": "1\r\n13 12\r\n", "output": ["NO", "no"]}, {"input": "2\r\n50000000605 50000000604\r\n5 4\r\n", "output": ["YES\r\nNO", "yes\r\nno"]}, {"input": "1\r\n281 280\r\n", "output": ["NO", "no"]}, {"input": "3\r\n5 4\r\n13 12\r\n25 24\r\n", "output": ["NO\r\nNO\r\nNO", "no\r\nno\r\nno"]}, {"input": "1\r\n45131796361 45131796360\r\n", "output": ["NO", "no"]}, {"input": "5\r\n61 60\r\n10000010 10\r\n12345 45\r\n12343345 65\r\n1030 6\r\n", "output": ["NO\r\nNO\r\nNO\r\nNO\r\nNO", "no\r\nno\r\nno\r\nno\r\nno"]}, {"input": "2\r\n61 60\r\n85 84\r\n", "output": ["NO\r\nNO", "no\r\nno"]}, {"input": "5\r\n61 60\r\n5242157731 5242157730\r\n12345 45\r\n5011907031 5011907030\r\n20207223564 20207223563\r\n", "output": ["NO\r\nNO\r\nNO\r\nNO\r\nNO", "no\r\nno\r\nno\r\nno\r\nno"]}, {"input": "1\r\n80003600041 80003600040\r\n", "output": ["NO", "no"]}, {"input": "5\r\n5242157731 5242157730\r\n12345 45\r\n5011907031 5011907030\r\n20207223564 20207223563\r\n61 60\r\n", "output": ["NO\r\nNO\r\nNO\r\nNO\r\nNO", "no\r\nno\r\nno\r\nno\r\nno"]}, {"input": "3\r\n25 24\r\n841 840\r\n28561 28560\r\n", "output": ["NO\r\nNO\r\nNO", "no\r\nno\r\nno"]}, {"input": "1\r\n61 60\r\n", "output": ["NO", "no"]}, {"input": "1\r\n7 6\r\n", "output": ["YES", "yes"]}, {"input": "1\r\n99999999999 36\r\n", "output": ["NO", "no"]}, {"input": "1\r\n421 420\r\n", "output": ["NO", "no"]}, {"input": "1\r\n5928189385 5928189384\r\n", "output": ["NO", "no"]}, {"input": "1\r\n122 121\r\n", "output": ["NO", "no"]}, {"input": "1\r\n61251050005 61251050004\r\n", "output": ["NO", "no"]}, {"input": "1\r\n160489044 125525827\r\n", "output": ["NO", "no"]}, {"input": "1\r\n18 14\r\n", "output": ["NO", "no"]}, {"input": "1\r\n96793840086 96793840085\r\n", "output": ["NO", "no"]}, {"input": "1\r\n84777676971 84777676970\r\n", "output": ["NO", "no"]}, {"input": "1\r\n3121 3120\r\n", "output": ["NO", "no"]}, {"input": "1\r\n500000041 500000040\r\n", "output": ["NO", "no"]}, {"input": "1\r\n5484081721 5484081720\r\n", "output": ["NO", "no"]}, {"input": "1\r\n4999100041 4999100040\r\n", "output": ["NO", "no"]}]
100
100
100
[{'input': '5\r\n62903604396 24274903133\r\n37198 37197\r\n16929 16928\r\n38325 38324\r\n49905 33035\r\n', 'output': ['no\r\nno\r\nyes\r\nyes\r\nno', 'NO\r\nNO\r\nYES\r\nYES\r\nNO']}, {'input': '5\r\n81271189833 16089352976\r\n98451628984 76827432884\r\n19327420986 19327420985\r\n15702367716 15702367715\r\n49419997643 49419997642\r\n', 'output': ['no\r\nno\r\nyes\r\nyes\r\nno', 'NO\r\nNO\r\nYES\r\nYES\r\nNO']}, {'input': '1\r\n45131796361 45131796360\r\n', 'output': ['NO', 'no']}, {'input': '1\r\n100000000000 99999999999\r\n', 'output': ['NO', 'no']}, {'input': '5\r\n41024865848 173372595\r\n60687612551 33296061228\r\n64391844305 16241932104\r\n81009941361 1976380712\r\n58548577555 28344963216\r\n', 'output': ['NO\r\nNO\r\nNO\r\nNO\r\nNO', 'no\r\nno\r\nno\r\nno\r\nno']}]
[{'input': '1\r\n84777676971 84777676970\r\n', 'output': ['NO', 'no']}, {'input': '5\r\n5242157731 5242157730\r\n12345 45\r\n5011907031 5011907030\r\n20207223564 20207223563\r\n61 60\r\n', 'output': ['NO\r\nNO\r\nNO\r\nNO\r\nNO', 'no\r\nno\r\nno\r\nno\r\nno']}, {'input': '5\r\n160 159\r\n223 222\r\n480 479\r\n357 356\r\n345 344\r\n', 'output': ['NO\r\nNO\r\nNO\r\nNO\r\nNO', 'no\r\nno\r\nno\r\nno\r\nno']}, {'input': '1\r\n281 280\r\n', 'output': ['NO', 'no']}, {'input': '5\r\n84969448764 45272932776\r\n40645404603 21303358412\r\n95260279132 55067325137\r\n92908555827 18951498996\r\n73854112015 59320860713\r\n', 'output': ['NO\r\nNO\r\nNO\r\nNO\r\nNO', 'no\r\nno\r\nno\r\nno\r\nno']}]
[{'input': '1\r\n7 6\r\n', 'output': ['YES', 'yes']}, {'input': '1\r\n500000041 500000040\r\n', 'output': ['NO', 'no']}, {'input': '5\r\n631 582\r\n201 106\r\n780 735\r\n608 528\r\n470 452\r\n', 'output': ['NO\r\nNO\r\nNO\r\nNO\r\nNO', 'no\r\nno\r\nno\r\nno\r\nno']}, {'input': '5\r\n2187 2186\r\n517 516\r\n3235 3234\r\n4810 4809\r\n3076 3075\r\n', 'output': ['yes\r\nyes\r\nyes\r\nyes\r\nyes', 'YES\r\nYES\r\nYES\r\nYES\r\nYES']}, {'input': '2\r\n50000000605 50000000604\r\n5 4\r\n', 'output': ['YES\r\nNO', 'yes\r\nno']}]
[{'input': '1\r\n5928189385 5928189384\r\n', 'output': ['NO', 'no']}, {'input': '1\r\n160489044 125525827\r\n', 'output': ['NO', 'no']}, {'input': '4\r\n6 5\r\n16 13\r\n61690850361 24777622630\r\n34 33\r\n', 'output': ['yes\r\nno\r\nno\r\nyes', 'YES\r\nNO\r\nNO\r\nYES']}, {'input': '5\r\n497334 497333\r\n437006 437005\r\n88531320027 6466043806\r\n863754 694577\r\n151084 151083\r\n', 'output': ['YES\r\nNO\r\nNO\r\nNO\r\nYES', 'yes\r\nno\r\nno\r\nno\r\nyes']}, {'input': '1\r\n18 14\r\n', 'output': ['NO', 'no']}]
[{'input': '5\r\n5242157731 5242157730\r\n12345 45\r\n5011907031 5011907030\r\n20207223564 20207223563\r\n61 60\r\n', 'output': ['NO\r\nNO\r\nNO\r\nNO\r\nNO', 'no\r\nno\r\nno\r\nno\r\nno']}, {'input': '5\r\n24095027715 9551467282\r\n34945375 34945374\r\n16603803 16603802\r\n58997777 26551505\r\n39762660 39762659\r\n', 'output': ['NO\r\nYES\r\nNO\r\nNO\r\nYES', 'no\r\nyes\r\nno\r\nno\r\nyes']}, {'input': '1\r\n100000000000 99999999999\r\n', 'output': ['NO', 'no']}, {'input': '5\r\n8680 4410\r\n59011181086 3472811643\r\n770 769\r\n1911 1910\r\n3615 3614\r\n', 'output': ['no\r\nno\r\nno\r\nyes\r\nyes', 'NO\r\nNO\r\nNO\r\nYES\r\nYES']}, {'input': '5\r\n18975453681 18975453680\r\n33749667489 33749667488\r\n32212198515 32212198514\r\n39519664171 39519664170\r\n5846685141 5846685140\r\n', 'output': ['yes\r\nyes\r\nyes\r\nyes\r\nyes', 'YES\r\nYES\r\nYES\r\nYES\r\nYES']}]
100
100
100
100
100
100
92.31
100
100
100
100
80
100
100
100
196
100
98.462
96
["0 0 0\n0 1 0", "1 1 0\n0 1 0", "0 0 0\n1 1 1"]
The first line contains three space-separated integers (0 or 1) — the coordinates of the first fly, the second line analogously contains the coordinates of the second fly.
91c9dbbceb467d5fd420e92c2919ecb6
#include<iostream> using namespace std; int a[10][10],f; int main() { for(int i=1;i<=2;i++) for(int j=1;j<=3;j++) cin>>a[i][j]; for(int i=1;i<=3;i++) if(a[1][i]==a[2][i]){f=1;break;} cout<<(f?"YES\n":"NO\n"); return 0; }
["YES", "YES", "NO"]
C++
null
Output "YES" (without quotes) if the flies see each other. Otherwise, output "NO".
You can find anything whatsoever in our Galaxy! A cubical planet goes round an icosahedral star. Let us introduce a system of axes so that the edges of the cubical planet are parallel to the coordinate axes and two opposite vertices lay in the points (0, 0, 0) and (1, 1, 1). Two flies live on the planet. At the moment they are sitting on two different vertices of the cubical planet. Your task is to determine whether they see each other or not. The flies see each other when the vertices they occupy lie on the same face of the cube.
[{"input": "0 0 0\r\n0 1 0\r\n", "output": ["YES"]}, {"input": "1 1 0\r\n0 1 0\r\n", "output": ["YES"]}, {"input": "0 0 0\r\n1 1 1\r\n", "output": ["No", "NO"]}, {"input": "0 0 0\r\n1 0 0\r\n", "output": ["YES"]}, {"input": "0 0 0\r\n0 1 0\r\n", "output": ["YES"]}, {"input": "0 0 0\r\n1 1 0\r\n", "output": ["YES"]}, {"input": "0 0 0\r\n0 0 1\r\n", "output": ["YES"]}, {"input": "0 0 0\r\n1 0 1\r\n", "output": ["YES"]}, {"input": "0 0 0\r\n0 1 1\r\n", "output": ["YES"]}, {"input": "0 0 0\r\n1 1 1\r\n", "output": ["No", "NO"]}, {"input": "1 0 0\r\n0 0 0\r\n", "output": ["YES"]}, {"input": "1 0 0\r\n0 1 0\r\n", "output": ["YES"]}, {"input": "1 0 0\r\n1 1 0\r\n", "output": ["YES"]}, {"input": "1 0 0\r\n0 0 1\r\n", "output": ["YES"]}, {"input": "1 0 0\r\n1 0 1\r\n", "output": ["YES"]}, {"input": "1 0 0\r\n0 1 1\r\n", "output": ["No", "NO"]}, {"input": "1 0 0\r\n1 1 1\r\n", "output": ["YES"]}, {"input": "0 1 0\r\n0 0 0\r\n", "output": ["YES"]}, {"input": "0 1 0\r\n1 0 0\r\n", "output": ["YES"]}, {"input": "0 1 0\r\n1 1 0\r\n", "output": ["YES"]}, {"input": "0 1 0\r\n0 0 1\r\n", "output": ["YES"]}, {"input": "0 1 0\r\n1 0 1\r\n", "output": ["No", "NO"]}, {"input": "0 1 0\r\n0 1 1\r\n", "output": ["YES"]}, {"input": "0 1 0\r\n1 1 1\r\n", "output": ["YES"]}, {"input": "1 1 0\r\n0 0 0\r\n", "output": ["YES"]}, {"input": "1 1 0\r\n1 0 0\r\n", "output": ["YES"]}, {"input": "1 1 0\r\n0 1 0\r\n", "output": ["YES"]}, {"input": "1 1 0\r\n0 0 1\r\n", "output": ["No", "NO"]}, {"input": "1 1 0\r\n1 0 1\r\n", "output": ["YES"]}, {"input": "1 1 0\r\n0 1 1\r\n", "output": ["YES"]}, {"input": "1 1 0\r\n1 1 1\r\n", "output": ["YES"]}, {"input": "0 0 1\r\n0 0 0\r\n", "output": ["YES"]}, {"input": "0 0 1\r\n1 0 0\r\n", "output": ["YES"]}, {"input": "0 0 1\r\n0 1 0\r\n", "output": ["YES"]}, {"input": "0 0 1\r\n1 1 0\r\n", "output": ["No", "NO"]}, {"input": "0 0 1\r\n1 0 1\r\n", "output": ["YES"]}, {"input": "0 0 1\r\n0 1 1\r\n", "output": ["YES"]}, {"input": "0 0 1\r\n1 1 1\r\n", "output": ["YES"]}, {"input": "1 0 1\r\n0 0 0\r\n", "output": ["YES"]}, {"input": "1 0 1\r\n1 0 0\r\n", "output": ["YES"]}, {"input": "1 0 1\r\n0 1 0\r\n", "output": ["No", "NO"]}, {"input": "1 0 1\r\n1 1 0\r\n", "output": ["YES"]}, {"input": "1 0 1\r\n0 0 1\r\n", "output": ["YES"]}, {"input": "1 0 1\r\n0 1 1\r\n", "output": ["YES"]}, {"input": "1 0 1\r\n1 1 1\r\n", "output": ["YES"]}, {"input": "0 1 1\r\n0 0 0\r\n", "output": ["YES"]}, {"input": "0 1 1\r\n1 0 0\r\n", "output": ["No", "NO"]}, {"input": "0 1 1\r\n0 1 0\r\n", "output": ["YES"]}, {"input": "0 1 1\r\n1 1 0\r\n", "output": ["YES"]}, {"input": "0 1 1\r\n0 0 1\r\n", "output": ["YES"]}, {"input": "0 1 1\r\n1 0 1\r\n", "output": ["YES"]}, {"input": "0 1 1\r\n1 1 1\r\n", "output": ["YES"]}, {"input": "1 1 1\r\n0 0 0\r\n", "output": ["No", "NO"]}, {"input": "1 1 1\r\n1 0 0\r\n", "output": ["YES"]}, {"input": "1 1 1\r\n0 1 0\r\n", "output": ["YES"]}, {"input": "1 1 1\r\n1 1 0\r\n", "output": ["YES"]}, {"input": "1 1 1\r\n0 0 1\r\n", "output": ["YES"]}, {"input": "1 1 1\r\n1 0 1\r\n", "output": ["YES"]}, {"input": "1 1 1\r\n0 1 1\r\n", "output": ["YES"]}]
100
100
100
[{'input': '1 1 1\r\n0 1 0\r\n', 'output': ['YES']}, {'input': '0 1 1\r\n1 0 0\r\n', 'output': ['No', 'NO']}, {'input': '0 1 1\r\n0 0 1\r\n', 'output': ['YES']}, {'input': '1 1 0\r\n1 0 0\r\n', 'output': ['YES']}, {'input': '1 1 1\r\n0 0 0\r\n', 'output': ['No', 'NO']}]
[{'input': '1 1 1\r\n0 1 0\r\n', 'output': ['YES']}, {'input': '0 1 1\r\n1 1 0\r\n', 'output': ['YES']}, {'input': '0 1 0\r\n0 0 1\r\n', 'output': ['YES']}, {'input': '0 0 0\r\n1 0 0\r\n', 'output': ['YES']}, {'input': '0 1 0\r\n1 1 0\r\n', 'output': ['YES']}]
[{'input': '1 0 0\r\n0 1 0\r\n', 'output': ['YES']}, {'input': '1 0 1\r\n1 1 0\r\n', 'output': ['YES']}, {'input': '0 1 0\r\n1 1 0\r\n', 'output': ['YES']}, {'input': '1 1 1\r\n1 0 1\r\n', 'output': ['YES']}, {'input': '1 0 0\r\n0 1 1\r\n', 'output': ['No', 'NO']}]
[{'input': '1 0 1\r\n0 0 0\r\n', 'output': ['YES']}, {'input': '0 0 0\r\n0 1 1\r\n', 'output': ['YES']}, {'input': '0 0 0\r\n1 0 1\r\n', 'output': ['YES']}, {'input': '0 1 1\r\n1 0 0\r\n', 'output': ['No', 'NO']}, {'input': '1 0 0\r\n1 1 1\r\n', 'output': ['YES']}]
[{'input': '1 0 1\r\n1 0 0\r\n', 'output': ['YES']}, {'input': '1 1 1\r\n1 1 0\r\n', 'output': ['YES']}, {'input': '0 1 0\r\n0 0 0\r\n', 'output': ['YES']}, {'input': '0 0 1\r\n0 1 0\r\n', 'output': ['YES']}, {'input': '0 0 1\r\n1 1 0\r\n', 'output': ['No', 'NO']}]
100
100
100
100
100
100
100
100
100
100
100
80
100
100
100
197
100
100
96
["1 1 6 1\n1 0 6 0\n6 0 6 1\n1 1 1 0", "0 0 0 3\n2 0 0 0\n2 2 2 0\n0 2 2 2"]
The input data contain four lines. Each of these lines contains four integers x1, y1, x2, y2 ( - 109 ≤ x1, y1, x2, y2 ≤ 109) — coordinates of segment's beginning and end positions. The given segments can degenerate into points.
ad105c08f63e9761fe90f69630628027
#include <bits/stdc++.h> using namespace std; int n, sx[10], id[10], sy[10], fx[10], fy[10], SX[10], SY[10], FX[10], FY[10]; int main() { for (int i = 1; i <= 4; i ++) { scanf("%d %d %d %d", &SX[i], &SY[i], &FX[i], &FY[i]); id[i] = i; } bool flag = 0; do { for (int i = 1; i <= 4; i ++) { sx[i-1] = SX[id[i]]; fx[i-1] = FX[id[i]]; sy[i-1] = SY[id[i]]; fy[i-1] = FY[id[i]]; } for (int i = 0; i < 2; i ++) { swap(sx[0], fx[0]); swap(sy[0], fy[0]); for (int j = 0; j < 2; j ++) { swap(sx[1], fx[1]); swap(sy[1], fy[1]); for (int k = 0; k < 2; k ++) { swap(sx[2], fx[2]); swap(sy[2], fy[2]); for (int l = 0; l < 2; l ++) { swap(sx[3], fx[3]); swap(sy[3], fy[3]); if (sy[0] != fy[0]) continue; if (sx[1] != fx[1]) continue; if (sy[2] != fy[2]) continue; if (sx[3] != fx[3]) continue; if (fy[0] != sy[1] || fx[0] != sx[1]) continue; if (fy[1] != sy[2] || fx[1] != sx[2]) continue; if (fy[2] != sy[3] || fx[2] != sx[3]) continue; if (fy[3] != sy[0] || fx[3] != sx[0]) continue; if (sy[0] == sy[2]) continue; if (sx[0] == sx[2]) continue; flag = 1; goto lp; } } } } } while (next_permutation(id+1, id+5)); lp: if (flag) puts("YES"); else puts("NO"); return 0; }
["YES", "NO"]
C++
null
Output the word «YES», if the given four segments form the required rectangle, otherwise output «NO».
Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the program detects if the four given segments form a rectangle of a positive area and with sides parallel to coordinate axes. As Alex does badly at school and can't write this program by himself, he asks you to help him.
[{"input": "1 1 6 1\r\n1 0 6 0\r\n6 0 6 1\r\n1 1 1 0\r\n", "output": ["YES"]}, {"input": "0 0 0 3\r\n2 0 0 0\r\n2 2 2 0\r\n0 2 2 2\r\n", "output": ["NO"]}, {"input": "0 0 0 2\r\n2 0 0 0\r\n2 2 2 0\r\n0 2 2 2\r\n", "output": ["YES"]}, {"input": "0 0 10 0\r\n0 0 10 0\r\n0 0 0 5\r\n0 0 0 -5\r\n", "output": ["NO"]}, {"input": "0 0 4 0\r\n4 0 3 0\r\n3 0 2 0\r\n2 0 0 0\r\n", "output": ["NO"]}, {"input": "0 0 3 0\r\n0 0 0 3\r\n0 3 3 3\r\n3 3 3 0\r\n", "output": ["YES"]}, {"input": "0 0 1 0\r\n1 0 1 1\r\n0 1 1 1\r\n0 0 0 1\r\n", "output": ["YES"]}, {"input": "0 0 1 0\r\n1 0 1 1\r\n1 1 1 0\r\n1 0 0 0\r\n", "output": ["NO"]}, {"input": "0 0 1 1\r\n1 1 2 0\r\n2 0 1 -1\r\n1 -1 0 0\r\n", "output": ["NO"]}, {"input": "0 0 0 10\r\n0 10 0 9\r\n0 9 0 8\r\n0 8 0 0\r\n", "output": ["NO"]}, {"input": "0 0 4 0\r\n4 0 4 0\r\n4 0 0 0\r\n0 0 0 0\r\n", "output": ["NO"]}, {"input": "0 0 0 2\r\n0 2 2 2\r\n0 0 2 2\r\n2 2 2 0\r\n", "output": ["NO"]}, {"input": "0 0 0 2\r\n2 0 2 2\r\n0 2 0 0\r\n2 2 2 0\r\n", "output": ["NO"]}, {"input": "13 13 13 13\r\n13 13 13 13\r\n13 13 13 13\r\n13 13 13 13\r\n", "output": ["NO"]}, {"input": "0 0 2 0\r\n0 1 0 3\r\n0 4 3 4\r\n3 0 3 3\r\n", "output": ["NO"]}, {"input": "1 1 1 1\r\n0 1 -1 1\r\n-1 1 1 1\r\n-1 1 1 1\r\n", "output": ["NO"]}, {"input": "1 -1 1 -1\r\n1 -1 1 -1\r\n1 -1 1 -1\r\n1 -1 1 -1\r\n", "output": ["NO"]}, {"input": "-1 0 -1 0\r\n-1 0 -1 0\r\n-1 0 -1 0\r\n-1 0 -1 0\r\n", "output": ["NO"]}, {"input": "0 -1 0 1\r\n0 0 0 1\r\n0 -1 0 -1\r\n0 -1 0 -1\r\n", "output": ["NO"]}, {"input": "0 0 -1 0\r\n-1 0 0 0\r\n-1 0 -1 0\r\n-1 0 -1 0\r\n", "output": ["NO"]}, {"input": "0 0 0 0\r\n0 0 0 1\r\n0 0 0 1\r\n0 0 0 0\r\n", "output": ["NO"]}, {"input": "-1 1 -1 1\r\n-1 1 -1 1\r\n-1 1 -1 1\r\n-1 1 -1 1\r\n", "output": ["NO"]}, {"input": "-1 1 -1 1\r\n0 1 1 1\r\n1 -1 -1 1\r\n-1 1 1 1\r\n", "output": ["NO"]}, {"input": "-1 -1 -1 -1\r\n-1 0 -1 0\r\n-1 0 -1 0\r\n-1 -1 -1 -1\r\n", "output": ["NO"]}, {"input": "1 2 1 2\r\n-2 2 1 2\r\n1 -2 -2 2\r\n-2 -2 1 -2\r\n", "output": ["NO"]}, {"input": "-2 1 -2 -1\r\n-2 -2 -2 -2\r\n-2 -1 -2 -2\r\n-2 1 -2 -1\r\n", "output": ["NO"]}, {"input": "1 2 1 2\r\n1 -1 1 -1\r\n1 -1 1 -1\r\n1 -1 1 -1\r\n", "output": ["NO"]}, {"input": "-2 0 -2 -1\r\n-2 2 -2 0\r\n-2 2 -2 2\r\n-2 0 -2 -1\r\n", "output": ["NO"]}, {"input": "-1 1 -2 1\r\n0 -1 -1 1\r\n-2 1 -1 -1\r\n0 1 0 -1\r\n", "output": ["NO"]}, {"input": "2 -1 -2 -1\r\n2 -1 2 -1\r\n2 -1 -2 -1\r\n2 -1 2 -1\r\n", "output": ["NO"]}, {"input": "0 2 0 2\r\n0 2 0 1\r\n0 1 0 1\r\n0 2 0 1\r\n", "output": ["NO"]}, {"input": "1 0 1 0\r\n1 0 1 0\r\n1 0 0 0\r\n1 0 1 0\r\n", "output": ["NO"]}, {"input": "-1 1 2 1\r\n0 1 0 1\r\n0 1 2 1\r\n2 1 -1 1\r\n", "output": ["NO"]}, {"input": "0 0 2 0\r\n0 0 2 0\r\n0 -2 0 0\r\n0 -2 0 0\r\n", "output": ["NO"]}, {"input": "0 -3 0 -1\r\n1 -1 1 -1\r\n0 -1 1 -2\r\n0 -2 -2 -3\r\n", "output": ["NO"]}, {"input": "-3 -2 -2 -2\r\n3 -2 3 -2\r\n-3 -2 -2 -2\r\n3 -2 3 -2\r\n", "output": ["NO"]}, {"input": "1 2 -2 2\r\n-2 2 3 2\r\n1 2 -2 2\r\n-2 2 3 2\r\n", "output": ["NO"]}, {"input": "0 -2 1 3\r\n1 3 1 3\r\n1 3 1 3\r\n1 3 1 -2\r\n", "output": ["NO"]}, {"input": "0 -3 -2 -3\r\n0 1 0 -3\r\n0 1 0 -3\r\n0 1 0 -3\r\n", "output": ["NO"]}, {"input": "1 -3 1 -3\r\n1 -3 1 -3\r\n1 -3 1 -3\r\n1 -3 1 -3\r\n", "output": ["NO"]}, {"input": "-3 2 -2 1\r\n0 2 0 -3\r\n0 -3 -2 1\r\n0 1 -3 -3\r\n", "output": ["NO"]}, {"input": "-3 3 2 3\r\n2 3 2 3\r\n-3 3 -3 3\r\n-3 3 2 3\r\n", "output": ["NO"]}, {"input": "2 -2 2 -2\r\n2 -2 2 -2\r\n2 -2 2 -2\r\n2 -2 2 -2\r\n", "output": ["NO"]}, {"input": "2 -1 0 -2\r\n-3 -2 -3 3\r\n2 -2 2 -2\r\n0 3 -3 -2\r\n", "output": ["NO"]}, {"input": "1 -3 -1 1\r\n0 -2 1 -3\r\n1 1 0 1\r\n1 -3 0 1\r\n", "output": ["NO"]}, {"input": "-2 4 -2 4\r\n-2 4 -2 -2\r\n-2 4 -2 -2\r\n-2 4 -2 -2\r\n", "output": ["NO"]}, {"input": "3 1 3 1\r\n-3 1 3 1\r\n3 3 -3 1\r\n-3 1 3 1\r\n", "output": ["NO"]}, {"input": "0 1 4 1\r\n0 1 4 1\r\n4 1 0 1\r\n0 -2 4 1\r\n", "output": ["NO"]}, {"input": "0 -2 0 -1\r\n0 -1 0 -2\r\n0 -2 0 -2\r\n0 -2 0 -2\r\n", "output": ["NO"]}, {"input": "-1 1 -1 1\r\n-1 1 -1 1\r\n-1 1 -1 3\r\n-3 1 -3 1\r\n", "output": ["NO"]}, {"input": "578327678 518066351 578327678 498442467\r\n583129774 498442467 578327678 518066351\r\n583129774 518066351 578327678 518066351\r\n583129774 498442467 578327678 518066351\r\n", "output": ["NO"]}, {"input": "-973576966 32484917 -973576966 32484917\r\n-973576966 32484917 347173379 32484917\r\n-973576966 32484917 347173379 32484917\r\n-973576966 32484917 347173379 32484917\r\n", "output": ["NO"]}, {"input": "572793036 194804279 572793036 -866298887\r\n572793036 461349977 -860420833 194804279\r\n572793036 461349977 572793036 -866298887\r\n-860420833 461349977 572793036 -866298887\r\n", "output": ["NO"]}, {"input": "949753871 -467933239 -72251156 462207752\r\n949753871 462207752 425479768 -467933239\r\n425479768 462207752 425479768 -467933239\r\n949753871 -467933239 949753871 462207752\r\n", "output": ["NO"]}, {"input": "1 -1 1 -1\r\n-1 -1 -1 -1\r\n1 0 -1 -1\r\n1 -1 -1 -1\r\n", "output": ["NO"]}, {"input": "1 -1 1 -1\r\n1 0 1 0\r\n1 0 1 -1\r\n1 0 1 -1\r\n", "output": ["NO"]}, {"input": "0 0 0 1\r\n0 1 0 1\r\n0 1 0 0\r\n0 1 0 1\r\n", "output": ["NO"]}, {"input": "1 -1 1 0\r\n1 0 1 0\r\n0 0 0 -1\r\n1 -1 1 0\r\n", "output": ["NO"]}, {"input": "0 0 2 2\r\n0 0 2 0\r\n2 2 2 2\r\n0 2 0 2\r\n", "output": ["NO"]}, {"input": "-2 -1 -1 -1\r\n-2 -1 -1 -1\r\n-2 -1 -2 2\r\n-2 2 -1 2\r\n", "output": ["NO"]}, {"input": "2 1 -1 0\r\n-1 0 2 1\r\n2 1 2 1\r\n-1 0 2 1\r\n", "output": ["NO"]}, {"input": "1 -1 2 -1\r\n1 -2 2 -2\r\n1 -2 2 -2\r\n1 -2 2 -2\r\n", "output": ["NO"]}, {"input": "-1 -2 -1 2\r\n-1 -2 -1 -2\r\n-1 2 -1 2\r\n-1 -2 -1 -2\r\n", "output": ["NO"]}, {"input": "2 0 2 -1\r\n2 -1 -1 0\r\n2 -1 -1 0\r\n2 -1 -1 0\r\n", "output": ["NO"]}, {"input": "2 -3 1 3\r\n1 -3 1 3\r\n2 3 2 -3\r\n2 -3 2 -3\r\n", "output": ["NO"]}, {"input": "130120899 550158649 130120899 831843953\r\n130120899 550158649 130120899 831843953\r\n130120899 550158649 434006978 831843953\r\n434006978 550158649 434006978 550158649\r\n", "output": ["NO"]}, {"input": "-214484034 559719641 -214484034 559719641\r\n-214484034 559719641 -214484034 559719641\r\n-214484034 2764087 -214484034 559719641\r\n-214484034 2764087 734280017 2764087\r\n", "output": ["NO"]}, {"input": "-966947426 664261857 -994206270 664261857\r\n-966947426 664261857 -994206270 664261857\r\n-966947426 789165019 -966947426 789165019\r\n-966947426 664261857 -966947426 789165019\r\n", "output": ["NO"]}, {"input": "264411509 -329579381 264411509 -329579381\r\n-726758913 -329579381 264411509 357369289\r\n-726758913 -329579381 264411509 -329579381\r\n264411509 -329579381 264411509 -329579381\r\n", "output": ["NO"]}, {"input": "-193720583 -547078093 -570748852 58725936\r\n-570748852 -547078093 -570748852 58725936\r\n-193720583 58725936 -570748852 -547078093\r\n-570748852 -547078093 -193720583 58725936\r\n", "output": ["NO"]}, {"input": "-534094150 -333730697 120658438 -333730697\r\n-534094150 -333730697 120658438 869464313\r\n-534094150 -333730697 -534094150 -333730697\r\n-534094150 869464313 -534094150 -333730697\r\n", "output": ["NO"]}, {"input": "-328545071 835751660 -345950135 835751660\r\n-345950135 243569491 -328545071 835751660\r\n-328545071 835751660 -345950135 243569491\r\n-328545071 243569491 -328545071 243569491\r\n", "output": ["NO"]}, {"input": "-985236057 -809433993 -985236057 -225363622\r\n-484344733 -225363622 -484344733 -225363622\r\n-985236057 -225363622 -985236057 -809433993\r\n-484344733 -225363622 -484344733 -809433993\r\n", "output": ["NO"]}, {"input": "774287068 919049158 774287068 919049158\r\n250033372 653817677 250033372 653817677\r\n250033372 919049158 774287068 653817677\r\n250033372 653817677 250033372 653817677\r\n", "output": ["NO"]}, {"input": "15319063 -661389770 632904085 -661389770\r\n15319063 834266473 632904085 834266473\r\n15319063 834266473 15319063 -661389770\r\n632904085 -661389770 632904085 834266473\r\n", "output": ["YES"]}, {"input": "157550209 -594704878 157550209 524666828\r\n671878188 -594704878 157550209 -594704878\r\n671878188 -594704878 671878188 524666828\r\n671878188 524666828 157550209 524666828\r\n", "output": ["YES"]}, {"input": "-887135208 728202342 127569272 728202342\r\n127569272 728202342 127569272 -932260532\r\n-887135208 -932260532 -887135208 728202342\r\n127569272 -932260532 -887135208 -932260532\r\n", "output": ["YES"]}, {"input": "-777411660 -392696120 -777411660 878250237\r\n461320023 878250237 -777411660 878250237\r\n461320023 878250237 461320023 -392696120\r\n461320023 -392696120 -777411660 -392696120\r\n", "output": ["YES"]}, {"input": "-892785315 567101756 -892785315 212349618\r\n-403060667 212349618 -403060667 567101756\r\n-403060667 567101756 -892785315 567101756\r\n-892785315 212349618 -403060667 212349618\r\n", "output": ["YES"]}, {"input": "-360046034 -871603961 -37695563 -871603961\r\n-37695563 664955871 -37695563 -871603961\r\n-360046034 664955871 -360046034 -871603961\r\n-360046034 664955871 -37695563 664955871\r\n", "output": ["YES"]}, {"input": "375089524 -852468724 -952575952 -852468724\r\n-952575952 -852468724 -952575952 -883150295\r\n-952575952 -883150295 375089524 -883150295\r\n375089524 -852468724 375089524 -883150295\r\n", "output": ["YES"]}, {"input": "851113265 -893293930 851113265 -444742025\r\n-864765585 -893293930 -864765585 -444742025\r\n-864765585 -893293930 851113265 -893293930\r\n-864765585 -444742025 851113265 -444742025\r\n", "output": ["YES"]}, {"input": "-309306779 559081237 255096743 559081237\r\n-309306779 -359724178 255096743 -359724178\r\n255096743 -359724178 255096743 559081237\r\n-309306779 559081237 -309306779 -359724178\r\n", "output": ["YES"]}, {"input": "542957347 -480242202 566995046 -480242202\r\n542957347 -480242202 542957347 -298569507\r\n566995046 -298569507 542957347 -298569507\r\n566995046 -298569507 566995046 -480242202\r\n", "output": ["YES"]}, {"input": "724715871 -943657730 964573294 -943657730\r\n724715871 -943657730 724715871 -216459206\r\n964573294 -216459206 964573294 -943657730\r\n724715871 -216459206 964573294 -216459206\r\n", "output": ["YES"]}, {"input": "-394306310 -279360055 -394306310 771835446\r\n-394306310 -279360055 -358661829 -279360055\r\n-358661829 771835446 -358661829 -279360055\r\n-358661829 771835446 -394306310 771835446\r\n", "output": ["YES"]}, {"input": "-204472047 -894485730 -204472047 640004355\r\n960702643 -894485730 960702643 640004355\r\n960702643 -894485730 -204472047 -894485730\r\n-204472047 640004355 960702643 640004355\r\n", "output": ["YES"]}, {"input": "747591 5158024 -837871358 5158024\r\n-837871358 -874026904 747591 -874026904\r\n747591 -874026904 747591 5158024\r\n-837871358 -874026904 -837871358 5158024\r\n", "output": ["YES"]}, {"input": "-442585231 90863587 800882871 90863587\r\n800882871 288218107 800882871 90863587\r\n800882871 288218107 -442585231 288218107\r\n-442585231 90863587 -442585231 288218107\r\n", "output": ["YES"]}, {"input": "-969490772 476931470 -969490772 929999730\r\n-426216863 929999730 -969490772 929999730\r\n-426216863 929999730 -426216863 476931470\r\n-969490772 476931470 -426216863 476931470\r\n", "output": ["YES"]}, {"input": "-683046010 -125472203 -683046010 418507423\r\n817863270 418507423 817863270 -125472203\r\n817863270 418507423 -683046010 418507423\r\n817863270 -125472203 -683046010 -125472203\r\n", "output": ["YES"]}, {"input": "231996287 974811621 -923122611 974811621\r\n-923122611 646880519 -923122611 974811621\r\n231996287 646880519 231996287 974811621\r\n-923122611 646880519 231996287 646880519\r\n", "output": ["YES"]}, {"input": "-83429272 -350159212 -990378619 -350159212\r\n-990378619 -350159212 -990378619 247777831\r\n-83429272 -350159212 -83429272 247777831\r\n-990378619 247777831 -83429272 247777831\r\n", "output": ["YES"]}, {"input": "-679599706 974881765 -679599706 -84192294\r\n-554774137 -84192294 -554774137 974881765\r\n-554774137 974881765 -679599706 974881765\r\n-554774137 -84192294 -679599706 -84192294\r\n", "output": ["YES"]}, {"input": "-155221108 -190475340 -155221108 -819044368\r\n-155221108 -190475340 -155875856 -190475340\r\n-155875856 -190475340 -155875856 -819044368\r\n-155875856 -819044368 -155221108 -819044368\r\n", "output": ["YES"]}, {"input": "377126871 -877660066 -633390329 -877660066\r\n377126871 -175686511 377126871 -877660066\r\n-633390329 -877660066 -633390329 -175686511\r\n-633390329 -175686511 377126871 -175686511\r\n", "output": ["YES"]}, {"input": "919022298 897009314 77151365 897009314\r\n77151365 579795002 919022298 579795002\r\n77151365 579795002 77151365 897009314\r\n919022298 579795002 919022298 897009314\r\n", "output": ["YES"]}, {"input": "146411776 -188986353 146411776 -808042296\r\n-381166510 -808042296 -381166510 -188986353\r\n146411776 -188986353 -381166510 -188986353\r\n146411776 -808042296 -381166510 -808042296\r\n", "output": ["YES"]}, {"input": "438703475 871560515 571565350 871560515\r\n571565350 -204157747 438703475 -204157747\r\n438703475 -204157747 438703475 871560515\r\n571565350 -204157747 571565350 871560515\r\n", "output": ["YES"]}, {"input": "0 0 0 0\r\n5 5 5 5\r\n5 0 5 5\r\n0 5 0 0\r\n", "output": ["NO"]}, {"input": "0 1 1 2\r\n2 1 1 2\r\n1 0 0 1\r\n2 1 1 0\r\n", "output": ["NO"]}, {"input": "-3 0 -3 3\r\n0 0 0 3\r\n3 3 -3 3\r\n3 0 -3 0\r\n", "output": ["NO"]}, {"input": "0 0 0 0\r\n1 1 1 1\r\n0 1 0 1\r\n1 0 1 0\r\n", "output": ["NO"]}, {"input": "0 0 0 0\r\n0 0 0 1\r\n0 0 1 0\r\n1 1 1 1\r\n", "output": ["NO"]}, {"input": "0 0 1 0\r\n1 1 0 1\r\n0 0 1 0\r\n1 1 0 1\r\n", "output": ["NO"]}, {"input": "0 0 0 1\r\n0 1 1 1\r\n1 1 1 0\r\n1 0 0 1\r\n", "output": ["NO"]}, {"input": "0 0 1 1\r\n0 1 1 0\r\n1 1 0 0\r\n1 0 0 1\r\n", "output": ["NO"]}, {"input": "0 0 0 0\r\n1 1 1 1\r\n0 1 1 0\r\n1 0 0 1\r\n", "output": ["NO"]}, {"input": "0 0 1 0\r\n0 1 1 1\r\n0 0 1 0\r\n0 1 1 1\r\n", "output": ["NO"]}]
100
100
100
[{'input': '-3 0 -3 3\r\n0 0 0 3\r\n3 3 -3 3\r\n3 0 -3 0\r\n', 'output': ['NO']}, {'input': '0 -3 0 -1\r\n1 -1 1 -1\r\n0 -1 1 -2\r\n0 -2 -2 -3\r\n', 'output': ['NO']}, {'input': '0 0 0 2\r\n2 0 0 0\r\n2 2 2 0\r\n0 2 2 2\r\n', 'output': ['YES']}, {'input': '0 0 0 0\r\n0 0 0 1\r\n0 0 0 1\r\n0 0 0 0\r\n', 'output': ['NO']}, {'input': '1 -3 -1 1\r\n0 -2 1 -3\r\n1 1 0 1\r\n1 -3 0 1\r\n', 'output': ['NO']}]
[{'input': '2 -1 0 -2\r\n-3 -2 -3 3\r\n2 -2 2 -2\r\n0 3 -3 -2\r\n', 'output': ['NO']}, {'input': '-3 2 -2 1\r\n0 2 0 -3\r\n0 -3 -2 1\r\n0 1 -3 -3\r\n', 'output': ['NO']}, {'input': '375089524 -852468724 -952575952 -852468724\r\n-952575952 -852468724 -952575952 -883150295\r\n-952575952 -883150295 375089524 -883150295\r\n375089524 -852468724 375089524 -883150295\r\n', 'output': ['YES']}, {'input': '-1 0 -1 0\r\n-1 0 -1 0\r\n-1 0 -1 0\r\n-1 0 -1 0\r\n', 'output': ['NO']}, {'input': '0 0 0 2\r\n2 0 2 2\r\n0 2 0 0\r\n2 2 2 0\r\n', 'output': ['NO']}]
[{'input': '1 2 1 2\r\n-2 2 1 2\r\n1 -2 -2 2\r\n-2 -2 1 -2\r\n', 'output': ['NO']}, {'input': '-969490772 476931470 -969490772 929999730\r\n-426216863 929999730 -969490772 929999730\r\n-426216863 929999730 -426216863 476931470\r\n-969490772 476931470 -426216863 476931470\r\n', 'output': ['YES']}, {'input': '-3 3 2 3\r\n2 3 2 3\r\n-3 3 -3 3\r\n-3 3 2 3\r\n', 'output': ['NO']}, {'input': '-1 1 -1 1\r\n-1 1 -1 1\r\n-1 1 -1 1\r\n-1 1 -1 1\r\n', 'output': ['NO']}, {'input': '-2 -1 -1 -1\r\n-2 -1 -1 -1\r\n-2 -1 -2 2\r\n-2 2 -1 2\r\n', 'output': ['NO']}]
[{'input': '1 2 1 2\r\n1 -1 1 -1\r\n1 -1 1 -1\r\n1 -1 1 -1\r\n', 'output': ['NO']}, {'input': '1 1 6 1\r\n1 0 6 0\r\n6 0 6 1\r\n1 1 1 0\r\n', 'output': ['YES']}, {'input': '0 0 0 2\r\n2 0 2 2\r\n0 2 0 0\r\n2 2 2 0\r\n', 'output': ['NO']}, {'input': '264411509 -329579381 264411509 -329579381\r\n-726758913 -329579381 264411509 357369289\r\n-726758913 -329579381 264411509 -329579381\r\n264411509 -329579381 264411509 -329579381\r\n', 'output': ['NO']}, {'input': '1 -3 1 -3\r\n1 -3 1 -3\r\n1 -3 1 -3\r\n1 -3 1 -3\r\n', 'output': ['NO']}]
[{'input': '747591 5158024 -837871358 5158024\r\n-837871358 -874026904 747591 -874026904\r\n747591 -874026904 747591 5158024\r\n-837871358 -874026904 -837871358 5158024\r\n', 'output': ['YES']}, {'input': '1 0 1 0\r\n1 0 1 0\r\n1 0 0 0\r\n1 0 1 0\r\n', 'output': ['NO']}, {'input': '0 0 0 0\r\n5 5 5 5\r\n5 0 5 5\r\n0 5 0 0\r\n', 'output': ['NO']}, {'input': '0 0 4 0\r\n4 0 3 0\r\n3 0 2 0\r\n2 0 0 0\r\n', 'output': ['NO']}, {'input': '13 13 13 13\r\n13 13 13 13\r\n13 13 13 13\r\n13 13 13 13\r\n', 'output': ['NO']}]
100
100
100
100
100
100
100
100
100
100
88.64
84.09
86.36
88.64
93.18
198
100
100
88.182
["3 3\n1", "3 3\n2", "1 1\n1"]
The first line contains integers n and m (1 ≤ n, m ≤ 5000). The second line contains integer x (1 ≤ x ≤ 109).
fa1ef5f9bceeb7266cc597ba8f2161cb
/// B : Coded by Choe Kwang #include <bits/stdc++.h> using namespace std; int n, m, x; int calc(int x) { return (max(0, n - 2 * x) * max(0, m - 2 * x) + 1) / 2; } int main() { scanf("%d %d %d", &n, &m, &x); printf("%d\n", calc(x - 1) - calc(x)); return 0; }
["4", "1", "1"]
C++
null
Print how many squares will be painted exactly x times.
A chessboard n × m in size is given. During the zero minute we repaint all the black squares to the 0 color. During the i-th minute we repaint to the i color the initially black squares that have exactly four corner-adjacent squares painted i - 1 (all such squares are repainted simultaneously). This process continues ad infinitum. You have to figure out how many squares we repainted exactly x times.The upper left square of the board has to be assumed to be always black. Two squares are called corner-adjacent, if they have exactly one common point.
[{"input": "3 3\r\n1\r\n", "output": ["4"]}, {"input": "3 3\r\n2\r\n", "output": ["1"]}, {"input": "1 1\r\n1\r\n", "output": ["1"]}, {"input": "8 8\r\n8\r\n", "output": ["0"]}, {"input": "9 10\r\n1\r\n", "output": ["17"]}, {"input": "9 9\r\n3\r\n", "output": ["8"]}, {"input": "10 9\r\n4\r\n", "output": ["5"]}, {"input": "1 5000\r\n3\r\n", "output": ["0"]}, {"input": "5000 1\r\n3\r\n", "output": ["0"]}, {"input": "4999 1\r\n7\r\n", "output": ["0"]}, {"input": "1 4999\r\n2309\r\n", "output": ["0"]}, {"input": "1 4999\r\n1000000\r\n", "output": ["0"]}, {"input": "1 1\r\n200\r\n", "output": ["0"]}, {"input": "5000 5000\r\n1000000000\r\n", "output": ["0"]}, {"input": "7 7\r\n777\r\n", "output": ["0"]}, {"input": "126 4125\r\n52\r\n", "output": ["4045"]}, {"input": "1755 2051\r\n1\r\n", "output": ["3804"]}, {"input": "3385 4978\r\n192\r\n", "output": ["7597"]}, {"input": "3663 2904\r\n1149\r\n", "output": ["1973"]}, {"input": "293 2183\r\n60\r\n", "output": ["2238"]}, {"input": "1922 109\r\n41\r\n", "output": ["1869"]}, {"input": "3552 3036\r\n199\r\n", "output": ["5794"]}, {"input": "182 2314\r\n54\r\n", "output": ["2282"]}, {"input": "1812 240\r\n9\r\n", "output": ["2018"]}, {"input": "1595 2881\r\n710\r\n", "output": ["1638"]}, {"input": "4694 685\r\n208\r\n", "output": ["4549"]}, {"input": "2793 4840\r\n901\r\n", "output": ["4031"]}, {"input": "892 3996\r\n288\r\n", "output": ["3738"]}, {"input": "3990 1800\r\n171\r\n", "output": ["5108"]}, {"input": "2089 955\r\n476\r\n", "output": ["1142"]}, {"input": "188 3759\r\n53\r\n", "output": ["3737"]}, {"input": "3287 2915\r\n538\r\n", "output": ["4052"]}, {"input": "2738 718\r\n308\r\n", "output": ["2226"]}, {"input": "837 4874\r\n208\r\n", "output": ["4881"]}, {"input": "991 2301\r\n291\r\n", "output": ["2130"]}, {"input": "2016 4549\r\n433\r\n", "output": ["4835"]}, {"input": "3042 1798\r\n93\r\n", "output": ["4470"]}, {"input": "419 4046\r\n174\r\n", "output": ["3771"]}, {"input": "1444 2646\r\n660\r\n", "output": ["1452"]}, {"input": "2470 4895\r\n421\r\n", "output": ["5683"]}, {"input": "4847 2143\r\n827\r\n", "output": ["3684"]}, {"input": "873 744\r\n42\r\n", "output": ["1451"]}, {"input": "3250 2992\r\n127\r\n", "output": ["5736"]}, {"input": "4275 240\r\n16\r\n", "output": ["4453"]}, {"input": "4035 369\r\n26\r\n", "output": ["4302"]}, {"input": "4339 2062\r\n462\r\n", "output": ["4555"]}, {"input": "4643 3755\r\n1381\r\n", "output": ["2876"]}, {"input": "3595 448\r\n110\r\n", "output": ["3605"]}, {"input": "3899 2141\r\n428\r\n", "output": ["4330"]}, {"input": "4202 3834\r\n1478\r\n", "output": ["2126"]}, {"input": "3154 527\r\n112\r\n", "output": ["3235"]}, {"input": "3458 2220\r\n526\r\n", "output": ["3576"]}, {"input": "3762 3914\r\n1073\r\n", "output": ["3386"]}, {"input": "2714 607\r\n189\r\n", "output": ["2567"]}, {"input": "3432 4788\r\n1203\r\n", "output": ["3410"]}, {"input": "1662 926\r\n452\r\n", "output": ["782"]}, {"input": "4892 712\r\n340\r\n", "output": ["4246"]}, {"input": "3122 1850\r\n201\r\n", "output": ["4170"]}, {"input": "1353 2988\r\n589\r\n", "output": ["1987"]}, {"input": "4583 2774\r\n1206\r\n", "output": ["2535"]}, {"input": "2813 3911\r\n560\r\n", "output": ["4486"]}, {"input": "1043 49\r\n10\r\n", "output": ["1054"]}, {"input": "4273 4835\r\n159\r\n", "output": ["8474"]}, {"input": "2504 973\r\n201\r\n", "output": ["2675"]}, {"input": "2828 4208\r\n912\r\n", "output": ["3390"]}, {"input": "10 10\r\n1\r\n", "output": ["18"]}, {"input": "10 10\r\n2\r\n", "output": ["14"]}, {"input": "10 10\r\n3\r\n", "output": ["10"]}, {"input": "10 10\r\n4\r\n", "output": ["6"]}, {"input": "10 10\r\n5\r\n", "output": ["2"]}]
100
100
100
[{'input': '892 3996\r\n288\r\n', 'output': ['3738']}, {'input': '1595 2881\r\n710\r\n', 'output': ['1638']}, {'input': '293 2183\r\n60\r\n', 'output': ['2238']}, {'input': '3122 1850\r\n201\r\n', 'output': ['4170']}, {'input': '4339 2062\r\n462\r\n', 'output': ['4555']}]
[{'input': '188 3759\r\n53\r\n', 'output': ['3737']}, {'input': '9 10\r\n1\r\n', 'output': ['17']}, {'input': '4847 2143\r\n827\r\n', 'output': ['3684']}, {'input': '3250 2992\r\n127\r\n', 'output': ['5736']}, {'input': '1 1\r\n1\r\n', 'output': ['1']}]
[{'input': '3595 448\r\n110\r\n', 'output': ['3605']}, {'input': '2504 973\r\n201\r\n', 'output': ['2675']}, {'input': '3990 1800\r\n171\r\n', 'output': ['5108']}, {'input': '4999 1\r\n7\r\n', 'output': ['0']}, {'input': '9 9\r\n3\r\n', 'output': ['8']}]
[{'input': '1 1\r\n200\r\n', 'output': ['0']}, {'input': '1353 2988\r\n589\r\n', 'output': ['1987']}, {'input': '2793 4840\r\n901\r\n', 'output': ['4031']}, {'input': '2089 955\r\n476\r\n', 'output': ['1142']}, {'input': '3122 1850\r\n201\r\n', 'output': ['4170']}]
[{'input': '10 10\r\n3\r\n', 'output': ['10']}, {'input': '3990 1800\r\n171\r\n', 'output': ['5108']}, {'input': '1 1\r\n200\r\n', 'output': ['0']}, {'input': '3552 3036\r\n199\r\n', 'output': ['5794']}, {'input': '1 4999\r\n1000000\r\n', 'output': ['0']}]
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
199
100
100
100
["2 7 1 8 2 8", "20 30 40 50 0 100", "31 41 59 26 17 43"]
First line of the input will contain 6 integers, separated by spaces: p1, p2, p3, p4, a, b (1 ≤ p1, p2, p3, p4 ≤ 1000, 0 ≤ a ≤ b ≤ 31415). It is guaranteed that numbers p1, p2, p3, p4 will be pairwise distinct.
63b9dc70e6ad83d89a487ffebe007b0a
#include<cstdio> using namespace std; int p1,p2,p3,p4,n,m,sum=0; int main() { scanf("%d%d%d%d%d%d",&p1,&p2,&p3,&p4,&n,&m); for(int i=n;i<=m;i++) { if(i%p1!=i) continue; if(i%p2!=i) continue; if(i%p3!=i) continue; if(i%p4!=i) continue; sum++; } printf("%d",sum); return 0; }
["0", "20", "9"]
C++
null
Output the number of integers in the given range that have the given property.
Little Petya was given this problem for homework:You are given function (here represents the operation of taking the remainder). His task is to count the number of integers x in range [a;b] with property f(x) = x.It is a pity that Petya forgot the order in which the remainders should be taken and wrote down only 4 numbers. Each of 24 possible orders of taking the remainder has equal probability of being chosen. For example, if Petya has numbers 1, 2, 3, 4 then he can take remainders in that order or first take remainder modulo 4, then modulo 2, 3, 1. There also are 22 other permutations of these numbers that represent orders in which remainder can be taken. In this problem 4 numbers wrote down by Petya will be pairwise distinct.Now it is impossible for Petya to complete the task given by teacher but just for fun he decided to find the number of integers with property that probability that f(x) = x is not less than 31.4159265352718281828459045%. In other words, Petya will pick up the number x if there exist at least 7 permutations of numbers p1, p2, p3, p4, for which f(x) = x.
[{"input": "2 7 1 8 2 8\r\n", "output": ["0"]}, {"input": "20 30 40 50 0 100\r\n", "output": ["20"]}, {"input": "31 41 59 26 17 43\r\n", "output": ["9"]}, {"input": "1 2 3 4 0 0\r\n", "output": ["1"]}, {"input": "1 2 3 4 1 1\r\n", "output": ["0"]}, {"input": "1 2 999 1000 30 40\r\n", "output": ["0"]}, {"input": "17 18 19 20 17 20\r\n", "output": ["0"]}, {"input": "17 18 19 20 16 20\r\n", "output": ["1"]}, {"input": "41 449 328 474 150 709\r\n", "output": ["0"]}, {"input": "467 329 936 440 117 700\r\n", "output": ["212"]}, {"input": "258 811 952 491 931 993\r\n", "output": ["0"]}, {"input": "823 431 359 590 153 899\r\n", "output": ["206"]}, {"input": "292 370 404 698 699 876\r\n", "output": ["0"]}, {"input": "442 705 757 527 868 893\r\n", "output": ["0"]}, {"input": "642 273 18 885 675 788\r\n", "output": ["0"]}, {"input": "291 303 656 660 126 704\r\n", "output": ["165"]}, {"input": "225 862 522 617 630 725\r\n", "output": ["0"]}, {"input": "17 847 715 732 502 778\r\n", "output": ["0"]}, {"input": "41 449 328 474 15724 19169\r\n", "output": ["0"]}, {"input": "467 329 936 440 5705 28145\r\n", "output": ["0"]}, {"input": "258 811 952 491 2995 11942\r\n", "output": ["0"]}, {"input": "823 431 359 590 153 3902\r\n", "output": ["206"]}, {"input": "292 370 404 698 19718 19895\r\n", "output": ["0"]}, {"input": "442 705 757 527 1869 19912\r\n", "output": ["0"]}, {"input": "642 273 18 885 23811 28703\r\n", "output": ["0"]}, {"input": "291 303 656 660 7711 15141\r\n", "output": ["0"]}, {"input": "225 862 522 617 1246 1341\r\n", "output": ["0"]}, {"input": "17 847 715 732 778 27529\r\n", "output": ["0"]}, {"input": "997 998 999 1000 0 31415\r\n", "output": ["997"]}, {"input": "1 2 3 4 0 31415\r\n", "output": ["1"]}, {"input": "541 931 822 948 131 193\r\n", "output": ["63"]}, {"input": "956 800 909 916 89 194\r\n", "output": ["106"]}, {"input": "735 794 942 991 419 490\r\n", "output": ["72"]}, {"input": "818 926 827 575 153 395\r\n", "output": ["243"]}, {"input": "792 858 887 679 179 356\r\n", "output": ["178"]}, {"input": "937 683 742 515 366 373\r\n", "output": ["8"]}, {"input": "616 747 501 875 146 264\r\n", "output": ["119"]}, {"input": "760 773 638 655 111 196\r\n", "output": ["86"]}, {"input": "697 855 997 589 97 192\r\n", "output": ["96"]}, {"input": "998 834 706 722 277 475\r\n", "output": ["199"]}, {"input": "100 101 102 103 10 20\r\n", "output": ["11"]}]
100
100
100
[{'input': '735 794 942 991 419 490\r\n', 'output': ['72']}, {'input': '291 303 656 660 126 704\r\n', 'output': ['165']}, {'input': '20 30 40 50 0 100\r\n', 'output': ['20']}, {'input': '100 101 102 103 10 20\r\n', 'output': ['11']}, {'input': '17 847 715 732 502 778\r\n', 'output': ['0']}]
[{'input': '1 2 999 1000 30 40\r\n', 'output': ['0']}, {'input': '760 773 638 655 111 196\r\n', 'output': ['86']}, {'input': '956 800 909 916 89 194\r\n', 'output': ['106']}, {'input': '17 847 715 732 778 27529\r\n', 'output': ['0']}, {'input': '1 2 3 4 0 31415\r\n', 'output': ['1']}]
[{'input': '998 834 706 722 277 475\r\n', 'output': ['199']}, {'input': '956 800 909 916 89 194\r\n', 'output': ['106']}, {'input': '1 2 3 4 0 31415\r\n', 'output': ['1']}, {'input': '100 101 102 103 10 20\r\n', 'output': ['11']}, {'input': '642 273 18 885 675 788\r\n', 'output': ['0']}]
[{'input': '2 7 1 8 2 8\r\n', 'output': ['0']}, {'input': '225 862 522 617 630 725\r\n', 'output': ['0']}, {'input': '956 800 909 916 89 194\r\n', 'output': ['106']}, {'input': '442 705 757 527 1869 19912\r\n', 'output': ['0']}, {'input': '998 834 706 722 277 475\r\n', 'output': ['199']}]
[{'input': '997 998 999 1000 0 31415\r\n', 'output': ['997']}, {'input': '41 449 328 474 150 709\r\n', 'output': ['0']}, {'input': '823 431 359 590 153 3902\r\n', 'output': ['206']}, {'input': '1 2 3 4 1 1\r\n', 'output': ['0']}, {'input': '442 705 757 527 868 893\r\n', 'output': ['0']}]
100
100
100
100
100
100
100
100
100
100
70
70
70
70
90
200
100
100
74