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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
["6 3\n1 1 1 0 1 0", "5 2\n0 0 0 1 0"] | The first line of the input contains two integers n and a (1ββ€βaββ€βnββ€β100)Β β the number of cities and the index of city where Limak lives. The second line contains n integers t1,βt2,β...,βtn (0ββ€βtiββ€β1). There are ti criminals in the i-th city. | 4840d571d4ce6e1096bb678b6c100ae5 | #include<stdio.h>
int main()
{
int n,i,j,pos,counter;
int criminals[100];
counter=0;
scanf("%d%d",&n,&pos);
for(i=0;i<n;i++)
scanf("%d",&criminals[i]);
if(criminals[pos-1]==1)
counter+=1;
for(j=1;j<=i;j++)
{
if((pos-1-j>=0)&&(pos-1+j<n)&&((criminals[pos-1-j]&criminals[pos-1+j])==1))
counter+=2;
else if((pos-1-j>=0)&&(pos-1+j>=n)&&(criminals[pos-1-j]==1))
counter+=1;
else if((pos-1-j<0)&&(pos-1+j<n)&&(criminals[pos-1+j]==1))
counter+=1;}
printf("%d",counter);
return 0;} | ["3", "1"] | C | NoteIn the first sample, there are six cities and Limak lives in the third one (blue arrow below). Criminals are in cities marked red. Using the BCD gives Limak the following information: There is one criminal at distance 0 from the third cityΒ β Limak is sure that this criminal is exactly in the third city. There is one criminal at distance 1 from the third cityΒ β Limak doesn't know if a criminal is in the second or fourth city. There are two criminals at distance 2 from the third cityΒ β Limak is sure that there is one criminal in the first city and one in the fifth city. There are zero criminals for every greater distance. So, Limak will catch criminals in cities 1, 3 and 5, that is 3 criminals in total.In the second sample (drawing below), the BCD gives Limak the information that there is one criminal at distance 2 from Limak's city. There is only one city at distance 2 so Limak is sure where a criminal is. | Print the number of criminals Limak will catch. | There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |iβ-βj|.Limak is a police officer. He lives in a city a. His job is to catch criminals. It's hard because he doesn't know in which cities criminals are. Though, he knows that there is at most one criminal in each city.Limak is going to use a BCD (Bear Criminal Detector). The BCD will tell Limak how many criminals there are for every distance from a city a. After that, Limak can catch a criminal in each city for which he is sure that there must be a criminal.You know in which cities criminals are. Count the number of criminals Limak will catch, after he uses the BCD. | [{"input": "6 3\r\n1 1 1 0 1 0\r\n", "output": ["3"]}, {"input": "5 2\r\n0 0 0 1 0\r\n", "output": ["1"]}, {"input": "1 1\r\n1\r\n", "output": ["1"]}, {"input": "1 1\r\n0\r\n", "output": ["0"]}, {"input": "9 3\r\n1 1 1 1 1 1 1 1 0\r\n", "output": ["8"]}, {"input": "9 5\r\n1 0 1 0 1 0 1 0 1\r\n", "output": ["5"]}, {"input": "20 17\r\n1 1 0 1 1 1 1 0 1 0 1 1 1 0 1 1 0 0 0 0\r\n", "output": ["10"]}, {"input": "100 60\r\n1 1 1 1 1 1 0 1 0 0 1 1 0 1 1 1 1 1 0 0 1 1 0 0 0 0 0 1 0 1 1 0 1 0 1 0 1 0 1 1 0 0 0 0 0 1 1 1 0 1 1 0 0 0 1 0 0 0 1 1 1 0 1 0 0 1 1 1 0 1 1 1 0 0 1 1 0 1 0 0 0 1 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 1 0 0\r\n", "output": ["27"]}, {"input": "8 1\r\n1 0 1 1 0 0 1 0\r\n", "output": ["4"]}, {"input": "11 11\r\n0 1 0 0 1 1 1 0 0 0 0\r\n", "output": ["4"]}, {"input": "19 10\r\n0 1 1 0 1 0 0 1 1 0 0 1 0 1 0 0 1 0 1\r\n", "output": ["4"]}, {"input": "100 38\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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n", "output": ["0"]}, {"input": "100 38\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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n", "output": ["1"]}, {"input": "100 38\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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n", "output": ["3"]}, {"input": "99 38\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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": ["25"]}, {"input": "99 38\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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": ["24"]}, {"input": "99 38\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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": ["24"]}, {"input": "98 70\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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n", "output": ["41"]}, {"input": "99 70\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 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": ["9"]}, {"input": "99 60\r\n0 0 0 1 1 0 1 1 0 0 1 0 0 0 0 0 1 0 1 0 0 0 1 0 1 1 1 0 1 1 1 1 0 0 1 1 1 0 1 1 1 1 1 0 1 1 0 0 0 0 0 1 0 0 1 0 1 1 1 1 1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0 1 1 1 0 0 0 0 1 1 0 1 1 1 1 0 0 0 0 0 0 1 1 1\r\n", "output": ["34"]}, {"input": "98 24\r\n0 0 0 1 1 0 1 1 0 0 0 0 1 0 0 1 0 0 1 1 1 0 0 1 0 0 1 0 1 0 0 1 1 0 1 1 1 0 1 0 0 1 0 0 0 1 1 1 1 0 1 1 1 0 1 1 1 1 0 0 1 0 0 0 1 0 1 1 0 1 0 1 1 1 0 0 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 1 0 1 0 0 1 1\r\n", "output": ["39"]}, {"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": ["100"]}, {"input": "100 1\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n", "output": ["0"]}, {"input": "2 1\r\n0 1\r\n", "output": ["1"]}] | 100 | 100 | 100 | [{'input': '6 3\r\n1 1 1 0 1 0\r\n', 'output': ['3']}, {'input': '98 24\r\n0 0 0 1 1 0 1 1 0 0 0 0 1 0 0 1 0 0 1 1 1 0 0 1 0 0 1 0 1 0 0 1 1 0 1 1 1 0 1 0 0 1 0 0 0 1 1 1 1 0 1 1 1 0 1 1 1 1 0 0 1 0 0 0 1 0 1 1 0 1 0 1 1 1 0 0 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 1 0 1 0 0 1 1\r\n', 'output': ['39']}, {'input': '8 1\r\n1 0 1 1 0 0 1 0\r\n', 'output': ['4']}, {'input': '99 38\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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': ['25']}, {'input': '5 2\r\n0 0 0 1 0\r\n', 'output': ['1']}] | [{'input': '99 38\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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': ['24']}, {'input': '99 70\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 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': ['9']}, {'input': '100 38\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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n', 'output': ['3']}, {'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': ['100']}, {'input': '19 10\r\n0 1 1 0 1 0 0 1 1 0 0 1 0 1 0 0 1 0 1\r\n', 'output': ['4']}] | [{'input': '6 3\r\n1 1 1 0 1 0\r\n', 'output': ['3']}, {'input': '1 1\r\n0\r\n', 'output': ['0']}, {'input': '100 60\r\n1 1 1 1 1 1 0 1 0 0 1 1 0 1 1 1 1 1 0 0 1 1 0 0 0 0 0 1 0 1 1 0 1 0 1 0 1 0 1 1 0 0 0 0 0 1 1 1 0 1 1 0 0 0 1 0 0 0 1 1 1 0 1 0 0 1 1 1 0 1 1 1 0 0 1 1 0 1 0 0 0 1 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 1 0 0\r\n', 'output': ['27']}, {'input': '20 17\r\n1 1 0 1 1 1 1 0 1 0 1 1 1 0 1 1 0 0 0 0\r\n', 'output': ['10']}, {'input': '98 70\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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n', 'output': ['41']}] | [{'input': '100 38\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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n', 'output': ['1']}, {'input': '100 1\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n', 'output': ['0']}, {'input': '99 38\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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': ['24']}, {'input': '5 2\r\n0 0 0 1 0\r\n', 'output': ['1']}, {'input': '100 38\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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n', 'output': ['3']}] | [{'input': '19 10\r\n0 1 1 0 1 0 0 1 1 0 0 1 0 1 0 0 1 0 1\r\n', 'output': ['4']}, {'input': '99 38\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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': ['24']}, {'input': '11 11\r\n0 1 0 0 1 1 1 0 0 0 0\r\n', 'output': ['4']}, {'input': '99 70\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 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': ['9']}, {'input': '99 38\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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': ['24']}] | 100 | 100 | 100 | 100 | 100 | 93.75 | 100 | 93.75 | 93.75 | 100 | 83.33 | 100 | 95.83 | 83.33 | 95.83 | 1 | 100 | 96.25 | 91.664 |
["9 7 3 8", "2 7 3 7", "30 6 17 19"] | The only line contains four integer numbers $$$n$$$, $$$m$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n, m \le 10^{12}$$$, $$$1 \le a, b \le 100$$$), where $$$n$$$ is the initial number of the commentary boxes, $$$m$$$ is the number of delegations to come, $$$a$$$ is the fee to build a box and $$$b$$$ is the fee to demolish a box. | c05d753b35545176ad468b99ff13aa39 | #include<stdio.h>
int main()
{
long long int c,a,n,m,b,d,e,f;
scanf("%lld%lld%lld%lld",&n,&m,&a,&b);
c=n%m;
d=m-n%m;
b=b*c;
a=a*d;
if(a>b)
printf("%lld\n",b);
else
printf("%lld\n",a);
return 0;
}
| ["15", "14", "0"] | C | NoteIn the first example organizers can build $$$5$$$ boxes to make the total of $$$14$$$ paying $$$3$$$ burles for the each of them.In the second example organizers can demolish $$$2$$$ boxes to make the total of $$$0$$$ paying $$$7$$$ burles for the each of them.In the third example organizers are already able to distribute all the boxes equally among the delegations, each one get $$$5$$$ boxes. | Output the minimal amount of burles organizers should pay to satisfy all the delegations (i.e. to make the number of the boxes be divisible by $$$m$$$). It is allowed that the final number of the boxes is equal to $$$0$$$. | Berland Football Cup starts really soon! Commentators from all over the world come to the event.Organizers have already built $$$n$$$ commentary boxes. $$$m$$$ regional delegations will come to the Cup. Every delegation should get the same number of the commentary boxes. If any box is left unoccupied then the delegations will be upset. So each box should be occupied by exactly one delegation.If $$$n$$$ is not divisible by $$$m$$$, it is impossible to distribute the boxes to the delegations at the moment.Organizers can build a new commentary box paying $$$a$$$ burles and demolish a commentary box paying $$$b$$$ burles. They can both build and demolish boxes arbitrary number of times (each time paying a corresponding fee). It is allowed to demolish all the existing boxes.What is the minimal amount of burles organizers should pay to satisfy all the delegations (i.e. to make the number of the boxes be divisible by $$$m$$$)? | [{"input": "9 7 3 8\r\n", "output": ["15"]}, {"input": "2 7 3 7\r\n", "output": ["14"]}, {"input": "30 6 17 19\r\n", "output": ["0"]}, {"input": "500000000001 1000000000000 100 100\r\n", "output": ["49999999999900"]}, {"input": "1000000000000 750000000001 10 100\r\n", "output": ["5000000000020"]}, {"input": "1000000000000 750000000001 100 10\r\n", "output": ["2499999999990"]}, {"input": "42 1 1 1\r\n", "output": ["0"]}, {"input": "1 1000000000000 1 100\r\n", "output": ["100"]}, {"input": "7 2 3 7\r\n", "output": ["3"]}, {"input": "999999999 2 1 1\r\n", "output": ["1"]}, {"input": "999999999999 10000000007 100 100\r\n", "output": ["70100"]}, {"input": "10000000001 2 1 1\r\n", "output": ["1"]}, {"input": "29 6 1 2\r\n", "output": ["1"]}, {"input": "99999999999 6 100 100\r\n", "output": ["300"]}, {"input": "1000000000000 7 3 8\r\n", "output": ["8"]}, {"input": "99999999999 2 1 1\r\n", "output": ["1"]}, {"input": "1 2 1 1\r\n", "output": ["1"]}, {"input": "999999999999 2 1 1\r\n", "output": ["1"]}, {"input": "9 2 1 1\r\n", "output": ["1"]}, {"input": "17 4 5 5\r\n", "output": ["5"]}, {"input": "100000000000 3 1 1\r\n", "output": ["1"]}, {"input": "100 7 1 1\r\n", "output": ["2"]}, {"input": "1000000000000 3 100 100\r\n", "output": ["100"]}, {"input": "70 3 10 10\r\n", "output": ["10"]}, {"input": "1 2 5 1\r\n", "output": ["1"]}, {"input": "1000000000000 3 1 1\r\n", "output": ["1"]}, {"input": "804289377 846930887 78 16\r\n", "output": ["3326037780"]}, {"input": "1000000000000 9 55 55\r\n", "output": ["55"]}, {"input": "957747787 424238336 87 93\r\n", "output": ["10162213695"]}, {"input": "25 6 1 2\r\n", "output": ["2"]}, {"input": "22 7 3 8\r\n", "output": ["8"]}, {"input": "10000000000 1 1 1\r\n", "output": ["0"]}, {"input": "999999999999 2 10 10\r\n", "output": ["10"]}, {"input": "999999999999 2 100 100\r\n", "output": ["100"]}, {"input": "100 3 3 8\r\n", "output": ["6"]}, {"input": "99999 2 1 1\r\n", "output": ["1"]}, {"input": "100 3 2 5\r\n", "output": ["4"]}, {"input": "1000000000000 13 10 17\r\n", "output": ["17"]}, {"input": "7 2 1 2\r\n", "output": ["1"]}, {"input": "10 3 1 2\r\n", "output": ["2"]}, {"input": "5 2 2 2\r\n", "output": ["2"]}, {"input": "100 3 5 2\r\n", "output": ["2"]}, {"input": "7 2 1 1\r\n", "output": ["1"]}, {"input": "70 4 1 1\r\n", "output": ["2"]}, {"input": "10 4 1 1\r\n", "output": ["2"]}, {"input": "6 7 41 42\r\n", "output": ["41"]}, {"input": "10 3 10 1\r\n", "output": ["1"]}, {"input": "5 5 2 3\r\n", "output": ["0"]}, {"input": "1000000000000 3 99 99\r\n", "output": ["99"]}, {"input": "7 3 100 1\r\n", "output": ["1"]}, {"input": "7 2 100 5\r\n", "output": ["5"]}, {"input": "1000000000000 1 23 33\r\n", "output": ["0"]}, {"input": "30 7 1 1\r\n", "output": ["2"]}, {"input": "100 3 1 1\r\n", "output": ["1"]}, {"input": "90001 300 100 1\r\n", "output": ["1"]}, {"input": "13 4 1 2\r\n", "output": ["2"]}, {"input": "1000000000000 6 1 3\r\n", "output": ["2"]}, {"input": "50 4 5 100\r\n", "output": ["10"]}, {"input": "999 2 1 1\r\n", "output": ["1"]}, {"input": "5 2 5 5\r\n", "output": ["5"]}, {"input": "20 3 3 3\r\n", "output": ["3"]}, {"input": "3982258181 1589052704 87 20\r\n", "output": ["16083055460"]}, {"input": "100 3 1 3\r\n", "output": ["2"]}, {"input": "7 3 1 1\r\n", "output": ["1"]}, {"input": "19 10 100 100\r\n", "output": ["100"]}, {"input": "23 3 100 1\r\n", "output": ["2"]}, {"input": "25 7 100 1\r\n", "output": ["4"]}, {"input": "100 9 1 2\r\n", "output": ["2"]}, {"input": "9999999999 2 1 100\r\n", "output": ["1"]}, {"input": "1000000000000 2 1 1\r\n", "output": ["0"]}, {"input": "10000 3 1 1\r\n", "output": ["1"]}, {"input": "22 7 1 6\r\n", "output": ["6"]}, {"input": "100000000000 1 1 1\r\n", "output": ["0"]}, {"input": "18 7 100 1\r\n", "output": ["4"]}, {"input": "10003 4 1 100\r\n", "output": ["1"]}, {"input": "3205261341 718648876 58 11\r\n", "output": ["3637324207"]}, {"input": "8 3 100 1\r\n", "output": ["2"]}, {"input": "15 7 1 1\r\n", "output": ["1"]}, {"input": "1000000000000 1 20 20\r\n", "output": ["0"]}, {"input": "16 7 3 2\r\n", "output": ["4"]}, {"input": "1000000000000 1 1 1\r\n", "output": ["0"]}, {"input": "7 3 1 100\r\n", "output": ["2"]}, {"input": "16 3 1 100\r\n", "output": ["2"]}, {"input": "13 4 1 10\r\n", "output": ["3"]}, {"input": "10 4 5 5\r\n", "output": ["10"]}, {"input": "14 3 1 100\r\n", "output": ["1"]}, {"input": "100 33 100 1\r\n", "output": ["1"]}, {"input": "22 7 1 8\r\n", "output": ["6"]}, {"input": "10 4 2 1\r\n", "output": ["2"]}, {"input": "6 4 2 2\r\n", "output": ["4"]}, {"input": "17 4 2 1\r\n", "output": ["1"]}, {"input": "7 3 100 10\r\n", "output": ["10"]}, {"input": "702 7 3 2\r\n", "output": ["4"]}, {"input": "8 3 1 5\r\n", "output": ["1"]}, {"input": "3 2 5 2\r\n", "output": ["2"]}, {"input": "99 19 1 7\r\n", "output": ["15"]}, {"input": "16 3 100 1\r\n", "output": ["1"]}, {"input": "100 34 1 100\r\n", "output": ["2"]}, {"input": "100 33 1 1\r\n", "output": ["1"]}, {"input": "2 3 4 3\r\n", "output": ["4"]}, {"input": "15 4 4 10\r\n", "output": ["4"]}, {"input": "1144108931 470211273 45 79\r\n", "output": ["11993619960"]}, {"input": "2 3 3 4\r\n", "output": ["3"]}, {"input": "29 5 4 9\r\n", "output": ["4"]}, {"input": "15 7 1 5\r\n", "output": ["5"]}, {"input": "1 1 1 1\r\n", "output": ["0"]}, {"input": "1 1 3 4\r\n", "output": ["0"]}, {"input": "10 12 2 1\r\n", "output": ["4"]}, {"input": "1 2 3 4\r\n", "output": ["3"]}] | 100 | 100 | 100 | [{'input': '7 3 100 1\r\n', 'output': ['1']}, {'input': '7 2 1 2\r\n', 'output': ['1']}, {'input': '100000000000 3 1 1\r\n', 'output': ['1']}, {'input': '957747787 424238336 87 93\r\n', 'output': ['10162213695']}, {'input': '10 12 2 1\r\n', 'output': ['4']}] | [{'input': '1 1 1 1\r\n', 'output': ['0']}, {'input': '100 3 2 5\r\n', 'output': ['4']}, {'input': '10000000001 2 1 1\r\n', 'output': ['1']}, {'input': '5 5 2 3\r\n', 'output': ['0']}, {'input': '30 6 17 19\r\n', 'output': ['0']}] | [{'input': '100 7 1 1\r\n', 'output': ['2']}, {'input': '29 5 4 9\r\n', 'output': ['4']}, {'input': '25 7 100 1\r\n', 'output': ['4']}, {'input': '100 3 5 2\r\n', 'output': ['2']}, {'input': '70 4 1 1\r\n', 'output': ['2']}] | [{'input': '7 2 100 5\r\n', 'output': ['5']}, {'input': '7 3 100 1\r\n', 'output': ['1']}, {'input': '70 4 1 1\r\n', 'output': ['2']}, {'input': '100 7 1 1\r\n', 'output': ['2']}, {'input': '999999999999 10000000007 100 100\r\n', 'output': ['70100']}] | [{'input': '1000000000000 3 99 99\r\n', 'output': ['99']}, {'input': '15 4 4 10\r\n', 'output': ['4']}, {'input': '1000000000000 2 1 1\r\n', 'output': ['0']}, {'input': '3205261341 718648876 58 11\r\n', 'output': ['3637324207']}, {'input': '10000000001 2 1 1\r\n', 'output': ['1']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 2 | 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<stdio.h>
int main()
{
long long int i,j,n,l,a,k;
scanf("%lld",&n);
k=2520;
a=n/k;
printf("%lld\n",a);
return 0;
} | ["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': '2520\r\n', 'output': ['1']}, {'input': '3628800\r\n', 'output': ['1440']}, {'input': '2519\r\n', 'output': ['0']}, {'input': '718281828459045235\r\n', 'output': ['285032471610732']}] | [{'input': '3000\r\n', 'output': ['1']}, {'input': '2519\r\n', 'output': ['0']}, {'input': '987654321234567890\r\n', 'output': ['391926317950225']}, {'input': '1\r\n', 'output': ['0']}, {'input': '1000000000000000000\r\n', 'output': ['396825396825396']}] | [{'input': '504000000000000000\r\n', 'output': ['200000000000000']}, {'input': '2521\r\n', 'output': ['1']}, {'input': '3000\r\n', 'output': ['1']}, {'input': '1\r\n', 'output': ['0']}, {'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': '718281828459045235\r\n', 'output': ['285032471610732']}, {'input': '314159265\r\n', 'output': ['124666']}] | [{'input': '2520\r\n', 'output': ['1']}, {'input': '1000000000000000000\r\n', 'output': ['396825396825396']}, {'input': '1\r\n', 'output': ['0']}, {'input': '3000\r\n', 'output': ['1']}, {'input': '3628800\r\n', 'output': ['1440']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 3 | 100 | 100 | 100 |
["2 6 2 2", "1 9 1 2"] | The first line of the input contains four integers d, L, v1, v2 (1ββ€βd,βL,βv1,βv2ββ€β10β000,βdβ<βL)Β β Luke's width, the initial position of the second press and the speed of the first and second presses, respectively. | f34f3f974a21144b9f6e8615c41830f5 | #include<stdio.h>
main(){
double d,l,v1,v2;
scanf("%lf %lf %lf %lf",&d,&l,&v1,&v2);
printf("%0.10lf",(l-d)/(v1+v2));
}
| ["1.00000000000000000000", "2.66666666666666650000"] | C | NoteIn the first sample Luke should stay exactly in the middle of the segment, that is at coordinates [2;4], as the presses move with the same speed.In the second sample he needs to occupy the position . In this case both presses move to his edges at the same time. | Print a single real valueΒ β the maximum period of time Luke can stay alive for. Your answer will be considered correct if its absolute or relative error does not exceed 10β-β6. Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if . | Luke Skywalker got locked up in a rubbish shredder between two presses. R2D2 is already working on his rescue, but Luke needs to stay alive as long as possible. For simplicity we will assume that everything happens on a straight line, the presses are initially at coordinates 0 and L, and they move towards each other with speed v1 and v2, respectively. Luke has width d and is able to choose any position between the presses. Luke dies as soon as the distance between the presses is less than his width. Your task is to determine for how long Luke can stay alive. | [{"input": "2 6 2 2\r\n", "output": ["1.0000000", "1.000000", "1.0", "1.00000000000000000000", "1.0000000000"]}, {"input": "1 9 1 2\r\n", "output": ["2.66666666666666666674", "2.66666666667", "2.6666666666666665", "2.6666667", "2.66666666666666650000", "2.666667", "2.6666666667", "2.66666666666666651864"]}, {"input": "1 10000 1 1\r\n", "output": ["4999.50000000000000000000", "4999.500000", "4999.5", "4999.5000000", "4999.5000000000"]}, {"input": "9999 10000 10000 10000\r\n", "output": ["0.000050", "0.0000500000", "0.00005000000000000000", "0.0000500", "5.0E-5", "5e-05"]}, {"input": "1023 2340 1029 3021\r\n", "output": ["0.32518518518518518823", "0.3251852", "0.32518518518518519000", "0.325185", "0.32518518518518518519", "0.325185185185", "0.3251851852", "0.3251851851851852"]}, {"input": "2173 2176 10000 9989\r\n", "output": ["0.00015008254539996998", "0.0001500825454", "0.0001500825", "0.0001501", "1.5008254539996998E-4", "0.000150"]}, {"input": "1 2 123 1\r\n", "output": ["0.00806451612903225784", "0.00806451612903225780", "0.00806451612903225806", "0.0080645", "0.008064516129032258", "0.008065", "0.00806451612903", "0.0080645161"]}, {"input": "123 1242 12 312\r\n", "output": ["3.4537037037037037", "3.45370370370370370367", "3.453704", "3.45370370370370370000", "3.4537037037", "3.45370370370370372015", "3.4537037"]}, {"input": "2 9997 3 12\r\n", "output": ["666.3333333333334", "666.33333333333337000000", "666.333333", "666.33333333333333331483", "666.333333333", "666.33333333333337122895", "666.3333333333", "666.3333333"]}, {"input": "1 10000 10000 10000\r\n", "output": ["0.49995000000000001000", "0.4999500000", "0.49995000000000000551", "0.49995", "0.49995000000000000000", "0.4999500", "0.499950"]}, {"input": "3274 4728 888 4578\r\n", "output": ["0.2660080", "0.26600804976216613", "0.2660080498", "0.26600804976216613218", "0.266008049762", "0.26600804976216611781", "0.266008", "0.26600804976216613000"]}, {"input": "4600 9696 5634 8248\r\n", "output": ["0.36709407866301685000", "0.3670941", "0.367094", "0.36709407866301685397", "0.3670940787", "0.36709407866301685635", "0.367094078663", "0.36709407866301685"]}, {"input": "2255 7902 8891 429\r\n", "output": ["0.60590128755364806867", "0.60590128755364803000", "0.6059013", "0.605901", "0.605901287554", "0.60590128755364802693", "0.6059012876", "0.605901287553648"]}, {"input": "6745 9881 2149 9907\r\n", "output": ["0.260119442601", "0.2601194426011944", "0.2601194", "0.26011944260119442601", "0.26011944260119440608", "0.26011944260119441000", "0.2601194426", "0.260119"]}, {"input": "4400 8021 6895 2089\r\n", "output": ["0.403049866429", "0.40304986642920748000", "0.40304986642920748174", "0.4030498664292075", "0.40304986642920747995", "0.403050", "0.4030498664", "0.4030499"]}, {"input": "5726 9082 7448 3054\r\n", "output": ["0.319558179394", "0.3195582", "0.3195581794", "0.319558", "0.31955817939440107000", "0.31955817939440106648", "0.31955817939440106512", "0.31955817939440107"]}, {"input": "3381 9769 4898 2532\r\n", "output": ["0.859757738896", "0.8597577", "0.8597577389", "0.8597577388963661", "0.85975773889636609000", "0.85975773889636608605", "0.859758", "0.85975773889636608344"]}, {"input": "1036 6259 5451 4713\r\n", "output": ["0.51387249114521838000", "0.513872", "0.5138724911", "0.5138724911452184", "0.51387249114521837967", "0.51387249114521841794", "0.513872491145", "0.5138725"]}, {"input": "5526 6455 197 4191\r\n", "output": ["0.2117137648131267", "0.21171376481312670359", "0.2117137648", "0.211713764813", "0.2117138", "0.21171376481312670000", "0.211714", "0.21171376481312670920"]}, {"input": "1196 4082 4071 9971\r\n", "output": ["0.2055263", "0.20552627830793335217", "0.20552627830793334282", "0.2055262783", "0.205526278308", "0.20552627830793335000", "0.205526", "0.20552627830793335"]}, {"input": "8850 9921 8816 9449\r\n", "output": ["0.0586367", "0.05863673692855187517", "0.05863673692855187608", "0.0586367369", "0.0586367369286", "0.058637", "0.05863673692855187600", "0.058636736928551876"]}, {"input": "3341 7299 2074 8927\r\n", "output": ["0.35978547404781386000", "0.3597854740", "0.359785474048", "0.35978547404781383511", "0.35978547404781385799", "0.35978547404781386", "0.3597855", "0.359785"]}, {"input": "7831 8609 6820 2596\r\n", "output": ["0.082625", "0.08262531860662701784", "0.0826253186", "0.08262531860662701566", "0.08262531860662702", "0.08262531860662701600", "0.0826253186066", "0.0826253"]}, {"input": "2322 7212 77 4778\r\n", "output": ["1.00720906282183316166", "1.007209062821833", "1.00720906282183308988", "1.00720906282183310000", "1.00720906282", "1.0072091", "1.007209", "1.0072090628"]}, {"input": "9976 9996 4823 4255\r\n", "output": ["0.0022031284", "0.00220312844239", "0.00220312844238819110", "0.002203128442388191", "0.002203", "0.00220312844238819113", "0.0022031", "0.00220312844238819123"]}, {"input": "7631 9769 5377 6437\r\n", "output": ["0.18097172845776196559", "0.1809717285", "0.180971728458", "0.18097172845776197000", "0.1809717", "0.18097172845776197731", "0.180972", "0.18097172845776197"]}, {"input": "8957 9525 8634 107\r\n", "output": ["0.064981", "0.0649811", "0.06498112344125385", "0.06498112344125385464", "0.06498112344125385500", "0.06498112344125386112", "0.0649811234", "0.0649811234413"]}, {"input": "6612 9565 3380 2288\r\n", "output": ["0.52099505998588567399", "0.52099505998588568900", "0.520995", "0.5209950599858857", "0.520995059986", "0.5209951", "0.5209950600", "0.52099505998588569000"]}, {"input": "1103 6256 3934 9062\r\n", "output": ["0.39650661742074483", "0.39650661742074484457", "0.39650661742074483351", "0.3965066", "0.396506617421", "0.39650661742074483000", "0.3965066174", "0.396507"]}, {"input": "1854 3280 1481 2140\r\n", "output": ["0.393814", "0.3938139", "0.39381386357359843000", "0.393813863574", "0.39381386357359843", "0.39381386357359845346", "0.3938138636", "0.39381386357359843275"]}, {"input": "2 6 2 2\r\n", "output": ["1.0", "1", "1.000000", "1.0000000000"]}, {"input": "1 9 1 2\r\n", "output": ["2.6666666667", "2.6666666666666665", "2.666667"]}, {"input": "1 10000 1 1\r\n", "output": ["4999.5", "4999.500000", "4999.5000000000"]}, {"input": "9999 10000 10000 10000\r\n", "output": ["0.000050", "0.0000500000", "5.0E-5", "5e-005"]}, {"input": "1023 2340 1029 3021\r\n", "output": ["0.325185", "0.3251852", "0.3251851852", "0.3251851851851852"]}, {"input": "2173 2176 10000 9989\r\n", "output": ["0.0001500825", "1.5008254539996998E-4", "0.000150"]}, {"input": "1 2 123 1\r\n", "output": ["0.0080645161", "0.008064516129032258", "0.008064516", "0.008065"]}, {"input": "123 1242 12 312\r\n", "output": ["3.453704", "3.4537037037037037", "3.4537037037"]}, {"input": "2 9997 3 12\r\n", "output": ["666.3333333333", "666.333333", "666.3333", "666.3333333333334"]}, {"input": "1 10000 10000 10000\r\n", "output": ["0.49995", "0.4999500000", "0.499950"]}, {"input": "3274 4728 888 4578\r\n", "output": ["0.26600804976216613", "0.2660080498", "0.266008"]}, {"input": "4600 9696 5634 8248\r\n", "output": ["0.367094", "0.36709407866301685", "0.3670941", "0.3670940787"]}, {"input": "2255 7902 8891 429\r\n", "output": ["0.605901", "0.6059012876", "0.605901287553648", "0.6059013"]}, {"input": "6745 9881 2149 9907\r\n", "output": ["0.2601194426011944", "0.2601194426", "0.2601194", "0.260119"]}, {"input": "4400 8021 6895 2089\r\n", "output": ["0.4030499", "0.4030498664", "0.4030498664292075", "0.403050"]}, {"input": "5726 9082 7448 3054\r\n", "output": ["0.31955817939440107", "0.319558", "0.3195581794", "0.3195582"]}, {"input": "3381 9769 4898 2532\r\n", "output": ["0.8597577388963661", "0.8597577", "0.8597577389", "0.859758"]}, {"input": "1036 6259 5451 4713\r\n", "output": ["0.5138724911452184", "0.5138724911", "0.5138725", "0.513872"]}, {"input": "5526 6455 197 4191\r\n", "output": ["0.2117137648", "0.211714", "0.2117138", "0.2117137648131267"]}, {"input": "1196 4082 4071 9971\r\n", "output": ["0.205526", "0.2055263", "0.2055262783", "0.20552627830793335"]}, {"input": "8850 9921 8816 9449\r\n", "output": ["0.058637", "0.05863674", "0.0586367369", "0.058636736928551876"]}, {"input": "3341 7299 2074 8927\r\n", "output": ["0.359785", "0.3597854740", "0.35978547404781386", "0.3597855"]}, {"input": "7831 8609 6820 2596\r\n", "output": ["0.082625", "0.08262532", "0.0826253186", "0.08262531860662702"]}, {"input": "2322 7212 77 4778\r\n", "output": ["1.007209", "1.0072090628", "1.007209062821833"]}, {"input": "9976 9996 4823 4255\r\n", "output": ["0.002203128442388191", "0.002203", "0.0022031284", "0.002203128"]}, {"input": "7631 9769 5377 6437\r\n", "output": ["0.1809717", "0.18097172845776197", "0.1809717285", "0.180972"]}, {"input": "8957 9525 8634 107\r\n", "output": ["0.06498112344125385", "0.06498112", "0.064981", "0.0649811234"]}, {"input": "6612 9565 3380 2288\r\n", "output": ["0.520995", "0.5209951", "0.5209950599858857", "0.5209950600"]}, {"input": "1103 6256 3934 9062\r\n", "output": ["0.39650661742074483", "0.3965066", "0.3965066174", "0.396507"]}, {"input": "1854 3280 1481 2140\r\n", "output": ["0.393814", "0.3938139", "0.3938138636", "0.39381386357359843"]}] | 100 | 100 | 100 | [{'input': '6612 9565 3380 2288\r\n', 'output': ['0.52099505998588567399', '0.52099505998588568900', '0.520995', '0.5209950599858857', '0.520995059986', '0.5209951', '0.5209950600', '0.52099505998588569000']}, {'input': '2255 7902 8891 429\r\n', 'output': ['0.605901', '0.6059012876', '0.605901287553648', '0.6059013']}, {'input': '2 6 2 2\r\n', 'output': ['1.0', '1', '1.000000', '1.0000000000']}, {'input': '7831 8609 6820 2596\r\n', 'output': ['0.082625', '0.08262531860662701784', '0.0826253186', '0.08262531860662701566', '0.08262531860662702', '0.08262531860662701600', '0.0826253186066', '0.0826253']}, {'input': '1 2 123 1\r\n', 'output': ['0.0080645161', '0.008064516129032258', '0.008064516', '0.008065']}] | [{'input': '1854 3280 1481 2140\r\n', 'output': ['0.393814', '0.3938139', '0.39381386357359843000', '0.393813863574', '0.39381386357359843', '0.39381386357359845346', '0.3938138636', '0.39381386357359843275']}, {'input': '4600 9696 5634 8248\r\n', 'output': ['0.36709407866301685000', '0.3670941', '0.367094', '0.36709407866301685397', '0.3670940787', '0.36709407866301685635', '0.367094078663', '0.36709407866301685']}, {'input': '1 10000 1 1\r\n', 'output': ['4999.50000000000000000000', '4999.500000', '4999.5', '4999.5000000', '4999.5000000000']}, {'input': '1 9 1 2\r\n', 'output': ['2.6666666667', '2.6666666666666665', '2.666667']}, {'input': '2 6 2 2\r\n', 'output': ['1.0000000', '1.000000', '1.0', '1.00000000000000000000', '1.0000000000']}] | [{'input': '6745 9881 2149 9907\r\n', 'output': ['0.2601194426011944', '0.2601194426', '0.2601194', '0.260119']}, {'input': '5526 6455 197 4191\r\n', 'output': ['0.2117137648131267', '0.21171376481312670359', '0.2117137648', '0.211713764813', '0.2117138', '0.21171376481312670000', '0.211714', '0.21171376481312670920']}, {'input': '8957 9525 8634 107\r\n', 'output': ['0.06498112344125385', '0.06498112', '0.064981', '0.0649811234']}, {'input': '3274 4728 888 4578\r\n', 'output': ['0.26600804976216613', '0.2660080498', '0.266008']}, {'input': '3381 9769 4898 2532\r\n', 'output': ['0.859757738896', '0.8597577', '0.8597577389', '0.8597577388963661', '0.85975773889636609000', '0.85975773889636608605', '0.859758', '0.85975773889636608344']}] | [{'input': '4400 8021 6895 2089\r\n', 'output': ['0.403049866429', '0.40304986642920748000', '0.40304986642920748174', '0.4030498664292075', '0.40304986642920747995', '0.403050', '0.4030498664', '0.4030499']}, {'input': '8957 9525 8634 107\r\n', 'output': ['0.064981', '0.0649811', '0.06498112344125385', '0.06498112344125385464', '0.06498112344125385500', '0.06498112344125386112', '0.0649811234', '0.0649811234413']}, {'input': '1 9 1 2\r\n', 'output': ['2.6666666667', '2.6666666666666665', '2.666667']}, {'input': '9999 10000 10000 10000\r\n', 'output': ['0.000050', '0.0000500000', '0.00005000000000000000', '0.0000500', '5.0E-5', '5e-05']}, {'input': '3274 4728 888 4578\r\n', 'output': ['0.2660080', '0.26600804976216613', '0.2660080498', '0.26600804976216613218', '0.266008049762', '0.26600804976216611781', '0.266008', '0.26600804976216613000']}] | [{'input': '1 10000 1 1\r\n', 'output': ['4999.50000000000000000000', '4999.500000', '4999.5', '4999.5000000', '4999.5000000000']}, {'input': '1 9 1 2\r\n', 'output': ['2.66666666666666666674', '2.66666666667', '2.6666666666666665', '2.6666667', '2.66666666666666650000', '2.666667', '2.6666666667', '2.66666666666666651864']}, {'input': '5526 6455 197 4191\r\n', 'output': ['0.2117137648131267', '0.21171376481312670359', '0.2117137648', '0.211713764813', '0.2117138', '0.21171376481312670000', '0.211714', '0.21171376481312670920']}, {'input': '5726 9082 7448 3054\r\n', 'output': ['0.31955817939440107', '0.319558', '0.3195581794', '0.3195582']}, {'input': '1036 6259 5451 4713\r\n', 'output': ['0.51387249114521838000', '0.513872', '0.5138724911', '0.5138724911452184', '0.51387249114521837967', '0.51387249114521841794', '0.513872491145', '0.5138725']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 4 | 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 <stdio.h>
#include <math.h>
int main(){
int i;
scanf("%d",&i);
printf("25");
return 0;
}
| ["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': '7\r\n', 'output': ['25']}, {'input': '2000000000000000000\r\n', 'output': ['25']}, {'input': '987654321012345678\r\n', 'output': ['25']}, {'input': '2\r\n', 'output': ['25']}, {'input': '1000000000000000000\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': '2\r\n', 'output': ['25']}] | [{'input': '1000000000000000000\r\n', 'output': ['25']}, {'input': '2000000000000000000\r\n', 'output': ['25']}, {'input': '2\r\n', 'output': ['25']}, {'input': '987654321012345678\r\n', 'output': ['25']}, {'input': '7\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']}, {'input': '2\r\n', 'output': ['25']}] | [{'input': '987654321012345678\r\n', 'output': ['25']}, {'input': '7\r\n', 'output': ['25']}, {'input': '2\r\n', 'output': ['25']}, {'input': '2000000000000000000\r\n', 'output': ['25']}, {'input': '1000000000000000000\r\n', 'output': ['25']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 5 | 100 | 100 | 100 |
["5\n()))()", "3\n(()", "2\n((("] | The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) β the half-length of the resulting regular bracket sequences (the resulting sequences must have length equal to $$$2n$$$). The second line of the input contains one string $$$s$$$ ($$$1 \le |s| \le 200$$$) β the string $$$s$$$ that should be a substring in each of the resulting regular bracket sequences ($$$|s|$$$ is the length of $$$s$$$). | 590a49a7af0eb83376ed911ed488d7e5 | #include <stdio.h>
#include <string.h>
enum { BIG = 1000000007 };
int n;
char s[240];
int slen;
int dp[201][101];
int next[201][2];
int fail[201];
void nextstep(int eo) {
int i, j;
for (i = 0; i <= slen; i++) {
int lp = next[i][0];
int rp = next[i][1];
for (j = eo; j <= n; j+=2) {
int now = dp[i][j];
if (j < n) {
int add = dp[lp][j+1] + now;
dp[lp][j+1] = add < BIG ? add : add - BIG;
}
if (j > 0) {
int add = dp[rp][j-1] + now;
dp[rp][j-1] = add < BIG ? add : add - BIG;
}
}
}
for (i = 0; i <= slen; i++) {
for (j = eo; j <= n; j+=2) {
dp[i][j] = 0;
}
}
/*for (i=0;i<=slen;i++){
for (j=0;j<=n;j++){
printf("%3d,",dp[i][j]);
}
puts("");
}
puts("");*/
}
int main() {
scanf("%d", &n);
scanf(" %202s", s);
slen = strlen(s);
int i;
// build state machine
fail[0] = fail[1] = 0;
if (s[0] == '(') {
next[0][0] = 1;
next[0][1] = 0;
}
else {
next[0][0] = 0;
next[0][1] = 1;
}
for (i = 1; i < slen; i++) {
int r = s[i] == ')';
int f = fail[i];
next[i][r] = i+1;
next[i][1-r] = next[f][1-r];
fail[i+1] = next[f][r];
}
next[slen][0] = next[slen][1] = slen;
dp[0][0] = 1;
for (i = 0; i < n; i++) {
nextstep(0);
nextstep(1);
}
printf("%d\n", dp[slen][0]);
return 0;
}
| ["5", "4", "0"] | C | NoteAll regular bracket sequences satisfying the conditions above for the first example: "(((()))())"; "((()()))()"; "((()))()()"; "(()(()))()"; "()((()))()". All regular bracket sequences satisfying the conditions above for the second example: "((()))"; "(()())"; "(())()"; "()(())". And there is no regular bracket sequences of length $$$4$$$ containing "(((" as a substring in the third example. | Print only one integer β the number of regular bracket sequences containing the given bracket sequence $$$s$$$ as a substring. Since this number can be huge, print it modulo $$$10^9+7$$$ ($$$1000000007$$$). | You are given a bracket sequence $$$s$$$ (not necessarily a regular one). A bracket sequence is a string containing only characters '(' and ')'.A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters '1' and '+' between the original characters of the sequence. For example, bracket sequences "()()" and "(())" are regular (the resulting expressions are: "(1)+(1)" and "((1+1)+1)"), and ")(", "(" and ")" are not.Your problem is to calculate the number of regular bracket sequences of length $$$2n$$$ containing the given bracket sequence $$$s$$$ as a substring (consecutive sequence of characters) modulo $$$10^9+7$$$ ($$$1000000007$$$). | [{"input": "5\r\n()))()\r\n", "output": ["5"]}, {"input": "3\r\n(()\r\n", "output": ["4"]}, {"input": "2\r\n(((\r\n", "output": ["0"]}, {"input": "100\r\n()(()))))(()((((()())()))(()))()()))(((()))))))))(\r\n", "output": ["979898526"]}, {"input": "100\r\n()(()(()((()(()(()()()(()((()))())())))()))())()()\r\n", "output": ["711757760"]}, {"input": "100\r\n(()))(()())()()((())(()((()()))(())()(((((()(((()()))())))))(())((((()()()()()))(()))(())(())(()))((\r\n", "output": ["599470552"]}, {"input": "100\r\n(()(()()()()(()(()()(((()((()(((()(((()(()()((()())))))()()()))))()()())))()()))()))()()()()())()())\r\n", "output": ["812513651"]}, {"input": "100\r\n(()))()())((())))((((())()((())(()(())))(()()(((()()())())()()(())))())((((()())(())())((((()((()((()()(())))(())))))()(()))))())()()))))()(()(()())((\r\n", "output": ["657505568"]}, {"input": "100\r\n()()()(((((()(()((((()((((((()()()((()()(()()()(((()()((()()((()()()))()()()))()))))())()())()()()())()()()())())())))())()())())))())()))))()()()()()\r\n", "output": ["264738339"]}, {"input": "100\r\n()()))(()()))))((()()))))(()()(()())()))))()())()()((((()(()()((())))((()()())())(())((()((()))(((()(()))))))())))((((()())))(()(()(())))(()))()()())((())()((())(()(((()((())))())))()()()((()))()()())\r\n", "output": ["0"]}, {"input": "100\r\n(()(()()()((()((((((()(()()((((()()((((()((()()((()((()()(()(((()((()()()()(()((()()(((()()(()((()()))())()))())()()()()())))())())()))()))()()))))()))()))))))())())()())))())))())))()()()())()())()()\r\n", "output": ["1"]}, {"input": "100\r\n()\r\n", "output": ["558488487"]}, {"input": "100\r\n()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()\r\n", "output": ["1"]}, {"input": "100\r\n(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))\r\n", "output": ["1"]}, {"input": "100\r\n()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()\r\n", "output": ["2"]}, {"input": "100\r\n((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))\r\n", "output": ["3"]}, {"input": "100\r\n)\r\n", "output": ["558488487"]}, {"input": "100\r\n))\r\n", "output": ["558488486"]}, {"input": "100\r\n))())())()))()())())()(((((((()()))())()())()(((()()))(())()((((()()()())()((()()()())()(((((()()()(()(()()((((()())))()))()(())(())))))))))((()((()())())(()((())((())()(()(()\r\n", "output": ["325"]}, {"input": "100\r\n()())(((()((())))((())((()(())))(((((((()))))))()(()((()()(((())))())()((((())()(())))(((((()))())(()))))((()))((())()(((())((()())(()(()))((()()()())())())))(()()()))()))))())))))))()(\r\n", "output": ["1820"]}, {"input": "100\r\n()(()())()(())))()())()(())((()(()()((()((((((())()))(()(()()))(()()())((()())))())())))())))(())(()()))(((())))(((((())(())(()))((())(())))())))()))()((())()()())()))(()())(()(()))(()(())))\r\n", "output": ["1"]}, {"input": "12\r\n()()()\r\n", "output": ["62316"]}, {"input": "20\r\n()(()()())\r\n", "output": ["296672330"]}, {"input": "32\r\n()((()()()())())\r\n", "output": ["468509380"]}, {"input": "50\r\n(\r\n", "output": ["265470434"]}, {"input": "10\r\n)()))())))())(())(()(((())(()))))))(()())))))))(((\r\n", "output": ["0"]}, {"input": "20\r\n))()))(()()))(())()))()(((((((((()((())((((((())(())(()())))(()()((())(()()()()(()())()()))))))())((\r\n", "output": ["0"]}, {"input": "1\r\n(\r\n", "output": ["1"]}, {"input": "2\r\n)\r\n", "output": ["2"]}, {"input": "3\r\n)\r\n", "output": ["5"]}, {"input": "4\r\n(\r\n", "output": ["14"]}, {"input": "5\r\n(\r\n", "output": ["42"]}, {"input": "6\r\n)\r\n", "output": ["132"]}, {"input": "7\r\n)\r\n", "output": ["429"]}, {"input": "8\r\n(\r\n", "output": ["1430"]}, {"input": "9\r\n(\r\n", "output": ["4862"]}, {"input": "10\r\n)\r\n", "output": ["16796"]}, {"input": "11\r\n(\r\n", "output": ["58786"]}, {"input": "12\r\n(\r\n", "output": ["208012"]}, {"input": "13\r\n)\r\n", "output": ["742900"]}, {"input": "14\r\n)\r\n", "output": ["2674440"]}, {"input": "15\r\n(\r\n", "output": ["9694845"]}, {"input": "16\r\n(\r\n", "output": ["35357670"]}, {"input": "17\r\n)\r\n", "output": ["129644790"]}, {"input": "18\r\n)\r\n", "output": ["477638700"]}, {"input": "19\r\n(\r\n", "output": ["767263183"]}, {"input": "20\r\n)\r\n", "output": ["564120378"]}, {"input": "21\r\n(\r\n", "output": ["466266852"]}, {"input": "22\r\n(\r\n", "output": ["482563003"]}, {"input": "23\r\n)\r\n", "output": ["59611249"]}, {"input": "1\r\n(((\r\n", "output": ["0"]}, {"input": "100\r\n((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((\r\n", "output": ["0"]}] | 100 | 100 | 100 | [{'input': '20\r\n()(()()())\r\n', 'output': ['296672330']}, {'input': '100\r\n()()()(((((()(()((((()((((((()()()((()()(()()()(((()()((()()((()()()))()()()))()))))())()())()()()())()()()())())())))())()())())))())()))))()()()()()\r\n', 'output': ['264738339']}, {'input': '100\r\n()(()())()(())))()())()(())((()(()()((()((((((())()))(()(()()))(()()())((()())))())())))())))(())(()()))(((())))(((((())(())(()))((())(())))())))()))()((())()()())()))(()())(()(()))(()(())))\r\n', 'output': ['1']}, {'input': '1\r\n(\r\n', 'output': ['1']}, {'input': '22\r\n(\r\n', 'output': ['482563003']}] | [{'input': '100\r\n(()))(()())()()((())(()((()()))(())()(((((()(((()()))())))))(())((((()()()()()))(()))(())(())(()))((\r\n', 'output': ['599470552']}, {'input': '20\r\n()(()()())\r\n', 'output': ['296672330']}, {'input': '1\r\n(((\r\n', 'output': ['0']}, {'input': '8\r\n(\r\n', 'output': ['1430']}, {'input': '100\r\n()(()(()((()(()(()()()(()((()))())())))()))())()()\r\n', 'output': ['711757760']}] | [{'input': '18\r\n)\r\n', 'output': ['477638700']}, {'input': '2\r\n)\r\n', 'output': ['2']}, {'input': '20\r\n()(()()())\r\n', 'output': ['296672330']}, {'input': '14\r\n)\r\n', 'output': ['2674440']}, {'input': '15\r\n(\r\n', 'output': ['9694845']}] | [{'input': '100\r\n))\r\n', 'output': ['558488486']}, {'input': '100\r\n()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()\r\n', 'output': ['1']}, {'input': '100\r\n()(()))))(()((((()())()))(()))()()))(((()))))))))(\r\n', 'output': ['979898526']}, {'input': '2\r\n(((\r\n', 'output': ['0']}, {'input': '100\r\n()()))(()()))))((()()))))(()()(()())()))))()())()()((((()(()()((())))((()()())())(())((()((()))(((()(()))))))())))((((()())))(()(()(())))(()))()()())((())()((())(()(((()((())))())))()()()((()))()()())\r\n', 'output': ['0']}] | [{'input': '100\r\n()(()(()((()(()(()()()(()((()))())())))()))())()()\r\n', 'output': ['711757760']}, {'input': '32\r\n()((()()()())())\r\n', 'output': ['468509380']}, {'input': '100\r\n((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((\r\n', 'output': ['0']}, {'input': '3\r\n)\r\n', 'output': ['5']}, {'input': '10\r\n)\r\n', 'output': ['16796']}] | 100 | 100 | 100 | 100 | 100 | 94.87 | 94.87 | 100 | 100 | 100 | 95.45 | 95.45 | 100 | 100 | 100 | 6 | 100 | 97.948 | 98.18 |
["8 1 1", "8 1 10"] | The only line contains three integers n, x and y (1ββ€βnββ€β107, 1ββ€βx,βyββ€β109) β the number of letters 'a' in the input file and the parameters from the problem statement. | 0f270af00be2a523515d5e7bd66800f6 | #include<stdio.h>
#include<stdlib.h>
int main()
{
unsigned long long n, x, y;
unsigned long nl, xl, yl;
fscanf(stdin, "%ld %ld %ld", &nl, &xl, &yl);
n = (unsigned long long)nl;
x = (unsigned long long)xl;
y = (unsigned long long)yl;
unsigned long long* f = malloc(10000001*sizeof(unsigned long long));
f[1] = x;
f[2] = x < y? x + f[1] : y + f[1];
unsigned long long k;
for (unsigned long long m = 3; m < n+1; m++)
{
k = (m+1)/2;
if (m % 2 == 1)
f[2*k-1] = f[k]+y+x < f[2*k-2]+x ? f[k]+y+x : f[2*k-2]+x;
else
f[2*k] = f[k]+y < f[2*k-2]+2*x ? f[k]+y : f[2*k-2]+2*x;
}
unsigned long pref = f[n] / 1000000000Lu;
unsigned long rest = f[n] % 1000000000Lu;
int digs = 9;
int pow10 = 100000000Lu;
while (digs > 1)
{
if (rest >= pow10)
break;
pow10 /= 10;
digs = digs-1;
}
if (pref > 0)
{
if (9-digs == 0)
printf("%lu%lu\n", pref, rest);
else
{
char* zeros = malloc((9-digs+1)*sizeof(char));
for (int i = 0; i < 9-digs; i++) zeros[i] = '0';
zeros[9-digs] = 0;
printf("%lu%s%lu\n", pref, zeros, rest);
}
}
else
printf("%lu\n", rest);
}
| ["4", "8"] | C | null | Print the only integer t β the minimum amount of time needed to generate the input file. | zscoder wants to generate an input file for some programming competition problem.His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.Initially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.zscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input. | [{"input": "8 1 1\r\n", "output": ["4"]}, {"input": "8 1 10\r\n", "output": ["8"]}, {"input": "10 62 99\r\n", "output": ["384"]}, {"input": "88 417 591\r\n", "output": ["4623"]}, {"input": "57 5289 8444\r\n", "output": ["60221"]}, {"input": "382 81437847 324871127\r\n", "output": ["2519291691"]}, {"input": "244 575154303 436759189\r\n", "output": ["5219536421"]}, {"input": "85 902510038 553915152\r\n", "output": ["6933531064"]}, {"input": "1926 84641582 820814219\r\n", "output": ["7184606427"]}, {"input": "3768 561740421 232937477\r\n", "output": ["5042211408"]}, {"input": "2313 184063453 204869248\r\n", "output": ["2969009745"]}, {"input": "35896 278270961 253614967\r\n", "output": ["5195579310"]}, {"input": "483867 138842067 556741142\r\n", "output": ["10712805143"]}, {"input": "4528217 187553422 956731625\r\n", "output": ["21178755627"]}, {"input": "10000000 1000000000 1\r\n", "output": ["8000000023"]}, {"input": "10000000 1 100\r\n", "output": ["1757"]}, {"input": "10000000 1 1000000000\r\n", "output": ["10000000"]}, {"input": "10000000 1 1000\r\n", "output": ["14224"]}, {"input": "10000000 1 10\r\n", "output": ["214"]}, {"input": "1 1 1\r\n", "output": ["1"]}, {"input": "10000000 998 998\r\n", "output": ["30938"]}, {"input": "9999999 987654321 123456789\r\n", "output": ["11728395036"]}, {"input": "9999999 1 2\r\n", "output": ["54"]}, {"input": "10000000 1 1\r\n", "output": ["31"]}, {"input": "11478 29358 26962\r\n", "output": ["556012"]}, {"input": "4314870 1000000000 1\r\n", "output": ["7000000022"]}, {"input": "7186329 608148870 290497442\r\n", "output": ["12762929866"]}, {"input": "9917781 1 1\r\n", "output": ["35"]}, {"input": "7789084 807239576 813643932\r\n", "output": ["25165322688"]}, {"input": "58087 1 100000000\r\n", "output": ["58087"]}, {"input": "9999991 2 3\r\n", "output": ["88"]}] | 100 | 100 | 100 | [{'input': '11478 29358 26962\r\n', 'output': ['556012']}, {'input': '57 5289 8444\r\n', 'output': ['60221']}, {'input': '382 81437847 324871127\r\n', 'output': ['2519291691']}, {'input': '10000000 1 100\r\n', 'output': ['1757']}, {'input': '10000000 998 998\r\n', 'output': ['30938']}] | [{'input': '9917781 1 1\r\n', 'output': ['35']}, {'input': '382 81437847 324871127\r\n', 'output': ['2519291691']}, {'input': '85 902510038 553915152\r\n', 'output': ['6933531064']}, {'input': '8 1 10\r\n', 'output': ['8']}, {'input': '10000000 1 1000000000\r\n', 'output': ['10000000']}] | [{'input': '7186329 608148870 290497442\r\n', 'output': ['12762929866']}, {'input': '4528217 187553422 956731625\r\n', 'output': ['21178755627']}, {'input': '9999999 1 2\r\n', 'output': ['54']}, {'input': '88 417 591\r\n', 'output': ['4623']}, {'input': '1926 84641582 820814219\r\n', 'output': ['7184606427']}] | [{'input': '483867 138842067 556741142\r\n', 'output': ['10712805143']}, {'input': '8 1 10\r\n', 'output': ['8']}, {'input': '10000000 1 1000\r\n', 'output': ['14224']}, {'input': '4314870 1000000000 1\r\n', 'output': ['7000000022']}, {'input': '9917781 1 1\r\n', 'output': ['35']}] | [{'input': '483867 138842067 556741142\r\n', 'output': ['10712805143']}, {'input': '10000000 1 10\r\n', 'output': ['214']}, {'input': '85 902510038 553915152\r\n', 'output': ['6933531064']}, {'input': '3768 561740421 232937477\r\n', 'output': ['5042211408']}, {'input': '10000000 1 1\r\n', 'output': ['31']}] | 100 | 100 | 100 | 100 | 100 | 86.67 | 86.67 | 86.67 | 100 | 100 | 75 | 81.25 | 75 | 100 | 93.75 | 7 | 100 | 92.002 | 85 |
["047", "16", "472747"] | The single line contains a non-empty string s whose length can range from 1 to 50, inclusive. The string only contains digits. The string can contain leading zeroes. | 639b8b8d0dc42df46b139f0aeb3a7a0a | #include <stdio.h>
# include <string.h>
int main()
{
char ch[100];
scanf("%s",&ch);
int i,c1=0,c2=0;
for(i=0;i<strlen(ch);i++)
{
if(ch[i]==4+48)
c1++;
else if(ch[i]==7+48)
c2++;
}
if(c1==0 && c2==0)
printf("-1\n");
else if(c1>=c2)
printf("4\n");
else
printf("7\n");
return 0;
} | ["4", "-1", "7"] | C | NoteThe lexicographical comparison of strings is performed by the < operator in the modern programming languages. String x is lexicographically less than string y either if x is a prefix of y, or exists such i (1ββ€βiββ€βmin(|x|,β|y|)), that xiβ<βyi and for any j (1ββ€βjβ<βi) xjβ=βyj. Here |a| denotes the length of string a.In the first sample three conditions are fulfilled for strings "4", "7" and "47". The lexicographically minimum one is "4".In the second sample s has no substrings which are lucky numbers.In the third sample the three conditions are only fulfilled for string "7". | In the only line print the answer to Petya's problem. If the sought string does not exist, print "-1" (without 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.One day Petya was delivered a string s, containing only digits. He needs to find a string that represents a lucky number without leading zeroes, is not empty, is contained in s as a substring the maximum number of times.Among all the strings for which the three conditions given above are fulfilled, Petya only needs the lexicographically minimum one. Find this string for Petya. | [{"input": "047\r\n", "output": ["4"]}, {"input": "16\r\n", "output": ["-1"]}, {"input": "472747\r\n", "output": ["7"]}, {"input": "1925\r\n", "output": ["-1"]}, {"input": "5486846414848445484\r\n", "output": ["4"]}, {"input": "516160414\r\n", "output": ["4"]}, {"input": "9458569865994896\r\n", "output": ["4"]}, {"input": "94894948577777777884888\r\n", "output": ["7"]}, {"input": "00000\r\n", "output": ["-1"]}, {"input": "9589\r\n", "output": ["-1"]}, {"input": "7665711\r\n", "output": ["7"]}, {"input": "538772857\r\n", "output": ["7"]}, {"input": "8679647744\r\n", "output": ["4"]}, {"input": "23607019991994\r\n", "output": ["4"]}, {"input": "86145305734278927901987281894864719533015270066521\r\n", "output": ["7"]}, {"input": "22438808523154336905543301642540261833729318191\r\n", "output": ["4"]}, {"input": "290732082244359495795943967215788554387079\r\n", "output": ["7"]}, {"input": "6363333480463521971676988087733137609715\r\n", "output": ["7"]}, {"input": "637789221789855555993957058\r\n", "output": ["7"]}, {"input": "11536708648794535307468278326553811\r\n", "output": ["7"]}, {"input": "619433861636130069773\r\n", "output": ["7"]}, {"input": "7\r\n", "output": ["7"]}, {"input": "00000000000000000000000000000000000000000000000000\r\n", "output": ["-1"]}, {"input": "0000000000000000000000000000000000000047\r\n", "output": ["4"]}, {"input": "8175012266795100056032281135654854227489558885698\r\n", "output": ["4"]}, {"input": "8862708665262955384044574268728167940741129\r\n", "output": ["4"]}, {"input": "538772857\r\n", "output": ["7"]}, {"input": "94872076199824813574576121510803\r\n", "output": ["7"]}, {"input": "44101164480392494025995467\r\n", "output": ["4"]}, {"input": "0445460407410702955646485\r\n", "output": ["4"]}, {"input": "91076008557028243309\r\n", "output": ["7"]}, {"input": "33120039\r\n", "output": ["-1"]}, {"input": "4\r\n", "output": ["4"]}, {"input": "74747474747474747474747474747474747474747474747474\r\n", "output": ["4"]}, {"input": "74747474747474747474747774747474747474747474747474\r\n", "output": ["7"]}, {"input": "74747474747474747474747474747474744474747474747474\r\n", "output": ["4"]}, {"input": "47474747474747474747474747474747474747474747474747\r\n", "output": ["4"]}, {"input": "40\r\n", "output": ["4"]}, {"input": "07\r\n", "output": ["7"]}, {"input": "007\r\n", "output": ["7"]}, {"input": "44\r\n", "output": ["4"]}, {"input": "74\r\n", "output": ["4"]}] | 100 | 100 | 100 | [{'input': '74747474747474747474747474747474747474747474747474\r\n', 'output': ['4']}, {'input': '290732082244359495795943967215788554387079\r\n', 'output': ['7']}, {'input': '0000000000000000000000000000000000000047\r\n', 'output': ['4']}, {'input': '00000000000000000000000000000000000000000000000000\r\n', 'output': ['-1']}, {'input': '91076008557028243309\r\n', 'output': ['7']}] | [{'input': '40\r\n', 'output': ['4']}, {'input': '047\r\n', 'output': ['4']}, {'input': '637789221789855555993957058\r\n', 'output': ['7']}, {'input': '44\r\n', 'output': ['4']}, {'input': '0445460407410702955646485\r\n', 'output': ['4']}] | [{'input': '9589\r\n', 'output': ['-1']}, {'input': '74747474747474747474747474747474747474747474747474\r\n', 'output': ['4']}, {'input': '44101164480392494025995467\r\n', 'output': ['4']}, {'input': '0445460407410702955646485\r\n', 'output': ['4']}, {'input': '5486846414848445484\r\n', 'output': ['4']}] | [{'input': '0445460407410702955646485\r\n', 'output': ['4']}, {'input': '538772857\r\n', 'output': ['7']}, {'input': '472747\r\n', 'output': ['7']}, {'input': '11536708648794535307468278326553811\r\n', 'output': ['7']}, {'input': '637789221789855555993957058\r\n', 'output': ['7']}] | [{'input': '07\r\n', 'output': ['7']}, {'input': '538772857\r\n', 'output': ['7']}, {'input': '74\r\n', 'output': ['4']}, {'input': '637789221789855555993957058\r\n', 'output': ['7']}, {'input': '23607019991994\r\n', 'output': ['4']}] | 100 | 100 | 100 | 100 | 100 | 100 | 92.86 | 92.86 | 92.86 | 92.86 | 91.67 | 91.67 | 83.33 | 91.67 | 91.67 | 8 | 100 | 94.288 | 90.002 |
["2 2\nRU", "1 2\nRU", "-1 1000000000\nLRRLU", "0 0\nD"] | The first line contains two integers a and b, (β-β109ββ€βa,βbββ€β109). The second line contains a string s (1ββ€β|s|ββ€β100, s only contains characters 'U', 'D', 'L', 'R') β the command. | 5d6212e28c7942e9ff4d096938b782bf | #include <stdio.h>
#include <string.h>
int a,b,l;
int x,y,xl,yl;
char s[105];
int w[105][2];
int al,bl;
int p(int a1,int b1,int x1,int y1)
{
if ((a1<0&&x1>0)||(a1>0&&x1<0))return 0;
if ((b1<0&&y1>0)||(b1>0&&y1<0))return 0;
return 1;
}
int main()
{
int i,j;
scanf ("%d%d",&a,&b);
scanf ("%s",s);l=strlen(s);
if (a==0&&b==0){printf ("Yes\n");return 0;}
for (i=0;i<l;i++) {
if (s[i]=='U'){w[i+1][0]=0;w[i+1][1]=1;}
if (s[i]=='D'){w[i+1][0]=0;w[i+1][1]=-1;}
if (s[i]=='L'){w[i+1][0]=-1;w[i+1][1]=0;}
if (s[i]=='R'){w[i+1][0]=1;w[i+1][1]=0;}
}
for (i=0;i<=l;i++) {
xl+=w[i][0];yl+=w[i][1];
}
//printf ("{{%d %d}}\n",xl,yl);
for (i=0;i<=l;i++) {
x+=w[i][0];y+=w[i][1];
al=a-x;bl=b-y;//printf ("(%d %d)<%d,%d>\n",al,bl,x,y);
if (!p(al,bl,xl,yl))continue;
if (al==0&&bl==0) {printf ("Yes\n");return 0;}
if (al==0) {if (xl==0&&yl!=0&&bl%yl==0) {printf ("Yes\n");return 0;}else continue;}
if (bl==0) {if (yl==0&&xl!=0&&al%xl==0) {printf ("Yes\n");return 0;}else continue;}
if (xl!=0&&yl!=0&&al%xl==0&&bl%yl==0&&al/xl==bl/yl){printf ("Yes\n");return 0;}
}
printf ("No\n");
return 0;
}
| ["Yes", "No", "Yes", "Yes"] | C | NoteIn the first and second test case, command string is "RU", so the robot will go right, then go up, then right, and then up and so on.The locations of its moves are (0, 0) βββ (1, 0) βββ (1, 1) βββ (2, 1) βββ (2, 2) βββ ...So it can reach (2, 2) but not (1, 2). | Print "Yes" if the robot will be located at (a,βb), and "No" otherwise. | Fox Ciel has a robot on a 2D plane. Initially it is located in (0, 0). Fox Ciel code a command to it. The command was represented by string s. Each character of s is one move operation. There are four move operations at all: 'U': go up, (x, y) βββ (x, y+1); 'D': go down, (x, y) βββ (x, y-1); 'L': go left, (x, y) βββ (x-1, y); 'R': go right, (x, y) βββ (x+1, y). The robot will do the operations in s from left to right, and repeat it infinite times. Help Fox Ciel to determine if after some steps the robot will located in (a,βb). | [{"input": "2 2\r\nRU\r\n", "output": ["Yes"]}, {"input": "1 2\r\nRU\r\n", "output": ["No"]}, {"input": "-1 1000000000\r\nLRRLU\r\n", "output": ["Yes"]}, {"input": "0 0\r\nD\r\n", "output": ["Yes"]}, {"input": "0 0\r\nUURRDL\r\n", "output": ["Yes"]}, {"input": "987654321 987654321\r\nUURRDL\r\n", "output": ["Yes"]}, {"input": "4 2\r\nUURRDL\r\n", "output": ["No"]}, {"input": "4 3\r\nUURRDL\r\n", "output": ["Yes"]}, {"input": "4 4\r\nUURRDL\r\n", "output": ["Yes"]}, {"input": "4 6\r\nUURRDL\r\n", "output": ["Yes"]}, {"input": "4 7\r\nUURRDL\r\n", "output": ["No"]}, {"input": "1000000000 1000000000\r\nUURRDL\r\n", "output": ["Yes"]}, {"input": "-1 -1\r\nUR\r\n", "output": ["No"]}, {"input": "1 1\r\nUURRDDLL\r\n", "output": ["No"]}, {"input": "987654321 2\r\nUURDD\r\n", "output": ["Yes"]}, {"input": "0 123456789\r\nRRULL\r\n", "output": ["Yes"]}, {"input": "4 4\r\nUUUURRRRDDDDLLLL\r\n", "output": ["Yes"]}, {"input": "-491226083 -49122610\r\nUDRLDURLDLLLDUDURLRDUUDDUUULUDRDRDUULURDRLLDDDLUDUURLUUDLLDULLLLDDLDDUU\r\n", "output": ["Yes"]}, {"input": "-261597957 418556728\r\nLLLDLUDUULLRDDULLRRUDRDLULRLRLLRRUUDRRLRUDLRRLUDRDLLUUDUULRURLDLULUUULDDUURLRUDURRL\r\n", "output": ["Yes"]}, {"input": "-771928144 -3\r\nRUDULULDRDLLLULDDUDDDDUDULRULRUULDDDURUDLUURULLLDLLDDRDDRLRURUULRUURRUDLDLDDRLLULRRDRRLLUULUDRUUDRRD\r\n", "output": ["Yes"]}, {"input": "397346346 1\r\nDDURRUURLDLRRLULD\r\n", "output": ["Yes"]}, {"input": "-528551525 0\r\nUDRLRRLDLDLURRRRULDLRLRLURUUDDLRLLDRRULLUDLURDLUUULLLRUUUDRRURLDUDULDDRDDDRDL\r\n", "output": ["Yes"]}, {"input": "311692421 -129871846\r\nLLLDURULDDDDUDDURRLUUDRLDDRDURDDRUDUURLUDUDLDRUDDDUUURDRRUDRDRDURLLDURUUDRLDLDURRRRRRDULURDRU\r\n", "output": ["Yes"]}, {"input": "485940814 728911221\r\nURURU\r\n", "output": ["Yes"]}, {"input": "-843450986 632588242\r\nLURLULULRUDUDULRDDLUL\r\n", "output": ["Yes"]}, {"input": "647999516 -809999401\r\nUDLDDLLULUDDLLDUULRRRDLUDDLDDLRLRRDRURURDRRDRULUDRDULRULLRRLLDDRLRRUDRURDUULUDLRRLRDR\r\n", "output": ["Yes"]}, {"input": "352820537 -764444491\r\nRDDUDLUDDUDLRRRDRRRDRRDUDUDDURLRRLDRLLRLLLLUULUDRURRDRLDDLLDRDURDUDRUDDLUDRLURUDRURDRDDLDRLDLDLLU\r\n", "output": ["Yes"]}, {"input": "-284973644 -1\r\nDLULLDLRUUDRR\r\n", "output": ["Yes"]}, {"input": "356922591 -2\r\nRRLDLDUDRUUUULUUDDULDDUDD\r\n", "output": ["No"]}, {"input": "27033101 54066203\r\nUDDDRDLLLRUUDDLRDLDRLRUDDULRLLRULR\r\n", "output": ["No"]}, {"input": "-199335150 39867031\r\nLLURRDUULRUDDRDUUULDLDRDDLURDRLDRLLLRRRRRULRRRUUDD\r\n", "output": ["No"]}, {"input": "609504072 609504074\r\nULRLUDLDDR\r\n", "output": ["No"]}, {"input": "497684357 829473929\r\nRRLDUUURULURRLLRRLRLURRLDU\r\n", "output": ["Yes"]}, {"input": "551922835 183974295\r\nDUDUUULDRLRURRDULRRUDDLRLLUULLRLRDRDRR\r\n", "output": ["No"]}, {"input": "825368095 -825368096\r\nRD\r\n", "output": ["No"]}, {"input": "-458990423 -229495204\r\nDLLDDRLUDLRLUL\r\n", "output": ["No"]}, {"input": "285102789 570205594\r\nRRDULRULULRRDUURRLURUDDULLRDUL\r\n", "output": ["No"]}, {"input": "109928480 219856920\r\nLRURLRLURDRDLDRDLRDDUUDDLULDRRUUURRUDLLUULUUUR\r\n", "output": ["No"]}, {"input": "-532674020 532674026\r\nUURLLL\r\n", "output": ["No"]}, {"input": "999999999 0\r\nRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\r\n", "output": ["Yes"]}, {"input": "0 0\r\nUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLR\r\n", "output": ["Yes"]}, {"input": "1 1\r\nUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLR\r\n", "output": ["No"]}, {"input": "-1000000000 -1000000000\r\nDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDL\r\n", "output": ["Yes"]}, {"input": "3 3\r\nUURR\r\n", "output": ["No"]}, {"input": "-2 -2\r\nUR\r\n", "output": ["No"]}, {"input": "5 5\r\nUDLR\r\n", "output": ["No"]}, {"input": "0 -1\r\nU\r\n", "output": ["No"]}, {"input": "-1 0\r\nR\r\n", "output": ["No"]}, {"input": "1000000000 1000000000\r\nURURURUR\r\n", "output": ["Yes"]}, {"input": "-1 -1\r\nRU\r\n", "output": ["No"]}, {"input": "1 1\r\nLD\r\n", "output": ["No"]}, {"input": "-2 -2\r\nUURR\r\n", "output": ["No"]}, {"input": "1000000000 0\r\nRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\r\n", "output": ["Yes"]}, {"input": "2 6\r\nRUUUURLDDDL\r\n", "output": ["Yes"]}, {"input": "0 1\r\nLUUR\r\n", "output": ["No"]}, {"input": "1 1\r\nURDLDL\r\n", "output": ["Yes"]}, {"input": "-10 -10\r\nRU\r\n", "output": ["No"]}, {"input": "1000000000 1000000000\r\nRURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURU\r\n", "output": ["Yes"]}, {"input": "-1000000000 -500000000\r\nURR\r\n", "output": ["No"]}, {"input": "-2 0\r\nULLLDDRRRR\r\n", "output": ["Yes"]}, {"input": "999999999 -999999999\r\nRRRRRRRRRRRRRRRRRRRRRRRRRDDDDDDDDDDDDDDDDDDDDDDDDDLLLLLLLLLLLLLLLLLLLLLLLUUUUUUUUUUUUUUUUUUUUUUU\r\n", "output": ["Yes"]}, {"input": "-100 -100\r\nRU\r\n", "output": ["No"]}, {"input": "100 100\r\nRUL\r\n", "output": ["No"]}, {"input": "0 1\r\nUDLR\r\n", "output": ["Yes"]}, {"input": "0 1\r\nD\r\n", "output": ["No"]}, {"input": "0 -3\r\nRDDL\r\n", "output": ["No"]}] | 100 | 100 | 100 | [{'input': '485940814 728911221\r\nURURU\r\n', 'output': ['Yes']}, {'input': '1000000000 1000000000\r\nUURRDL\r\n', 'output': ['Yes']}, {'input': '-261597957 418556728\r\nLLLDLUDUULLRDDULLRRUDRDLULRLRLLRRUUDRRLRUDLRRLUDRDLLUUDUULRURLDLULUUULDDUURLRUDURRL\r\n', 'output': ['Yes']}, {'input': '-1000000000 -1000000000\r\nDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDL\r\n', 'output': ['Yes']}, {'input': '-100 -100\r\nRU\r\n', 'output': ['No']}] | [{'input': '4 7\r\nUURRDL\r\n', 'output': ['No']}, {'input': '999999999 -999999999\r\nRRRRRRRRRRRRRRRRRRRRRRRRRDDDDDDDDDDDDDDDDDDDDDDDDDLLLLLLLLLLLLLLLLLLLLLLLUUUUUUUUUUUUUUUUUUUUUUU\r\n', 'output': ['Yes']}, {'input': '4 4\r\nUURRDL\r\n', 'output': ['Yes']}, {'input': '1 1\r\nURDLDL\r\n', 'output': ['Yes']}, {'input': '1000000000 1000000000\r\nRURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURU\r\n', 'output': ['Yes']}] | [{'input': '0 1\r\nUDLR\r\n', 'output': ['Yes']}, {'input': '-261597957 418556728\r\nLLLDLUDUULLRDDULLRRUDRDLULRLRLLRRUUDRRLRUDLRRLUDRDLLUUDUULRURLDLULUUULDDUURLRUDURRL\r\n', 'output': ['Yes']}, {'input': '-2 -2\r\nUURR\r\n', 'output': ['No']}, {'input': '987654321 987654321\r\nUURRDL\r\n', 'output': ['Yes']}, {'input': '1 2\r\nRU\r\n', 'output': ['No']}] | [{'input': '-843450986 632588242\r\nLURLULULRUDUDULRDDLUL\r\n', 'output': ['Yes']}, {'input': '-100 -100\r\nRU\r\n', 'output': ['No']}, {'input': '4 6\r\nUURRDL\r\n', 'output': ['Yes']}, {'input': '3 3\r\nUURR\r\n', 'output': ['No']}, {'input': '-2 -2\r\nUURR\r\n', 'output': ['No']}] | [{'input': '999999999 0\r\nRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\r\n', 'output': ['Yes']}, {'input': '-1 0\r\nR\r\n', 'output': ['No']}, {'input': '100 100\r\nRUL\r\n', 'output': ['No']}, {'input': '-1 1000000000\r\nLRRLU\r\n', 'output': ['Yes']}, {'input': '999999999 -999999999\r\nRRRRRRRRRRRRRRRRRRRRRRRRRDDDDDDDDDDDDDDDDDDDDDDDDDLLLLLLLLLLLLLLLLLLLLLLLUUUUUUUUUUUUUUUUUUUUUUU\r\n', 'output': ['Yes']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 59.09 | 62.12 | 71.21 | 57.58 | 80.3 | 9 | 100 | 100 | 66.06 |
["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 <stdio.h>
int main(){
int n,x,i,t;
scanf("%d %d", &n,&x);
int ans = x;
for(i = 0; i < n; i++){
scanf("%d", &t);
if(t < x) ans--;
else if(t==x)ans++;
}
printf("%d\n", ans);
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': '5 5\r\n1 2 3 4 5\r\n', 'output': ['2']}, {'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': '5 2\r\n1 2 3 4 5\r\n', 'output': ['2']}, {'input': '5 3\r\n0 4 5 6 7\r\n', 'output': ['2']}, {'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 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': '2 2\r\n0 2\r\n', 'output': ['2']}, {'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': '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': '1 100\r\n100\r\n', 'output': ['101']}] | [{'input': '5 2\r\n1 2 3 4 5\r\n', 'output': ['2']}, {'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': '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': '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': '2 100\r\n0 100\r\n', 'output': ['100']}] | [{'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': '5 5\r\n1 2 3 4 5\r\n', 'output': ['2']}, {'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': '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': '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': '1 0\r\n100\r\n', 'output': ['0']}, {'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': '5 3\r\n0 4 5 6 7\r\n', 'output': ['2']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 10 | 100 | 100 | 100 |
["1\n2\n1\n1\n10", "1\n2\n1\n1\n8"] | The input data contains integers vp,βvd,βt,βf and c, one per line (1ββ€βvp,βvdββ€β100, 1ββ€βt,βfββ€β10, 1ββ€βcββ€β1000). | c9c03666278acec35f0e273691fe0fff | #include<stdio.h>
int main(){
float vp,vd,t,f,c;
float phm,d=0,time=0;
int bijous=0;
scanf("%f%f%f%f%f",&vp,&vd,&t,&f,&c);
for(phm=t*vp;;){
//printf("%f\n",phm);
if(vd<=vp)
break;
phm+=phm*vp/(vd-vp);
if(phm>=c)
break;
else{
phm+=f*vp+(phm/vd)*vp;
bijous++;
}
}
printf("%d",bijous);
return 0;
}
| ["2", "1"] | C | NoteIn the first case one hour after the escape the dragon will discover it, and the princess will be 1 mile away from the cave. In two hours the dragon will overtake the princess 2 miles away from the cave, and she will need to drop the first bijou. Return to the cave and fixing the treasury will take the dragon two more hours; meanwhile the princess will be 4 miles away from the cave. Next time the dragon will overtake the princess 8 miles away from the cave, and she will need the second bijou, but after this she will reach the castle without any further trouble.The second case is similar to the first one, but the second time the dragon overtakes the princess when she has reached the castle, and she won't need the second bijou. | Output the minimal number of bijous required for the escape to succeed. | The princess is going to escape the dragon's cave, and she needs to plan it carefully.The princess runs at vp miles per hour, and the dragon flies at vd miles per hour. The dragon will discover the escape after t hours and will chase the princess immediately. Looks like there's no chance to success, but the princess noticed that the dragon is very greedy and not too smart. To delay him, the princess decides to borrow a couple of bijous from his treasury. Once the dragon overtakes the princess, she will drop one bijou to distract him. In this case he will stop, pick up the item, return to the cave and spend f hours to straighten the things out in the treasury. Only after this will he resume the chase again from the very beginning.The princess is going to run on the straight. The distance between the cave and the king's castle she's aiming for is c miles. How many bijous will she need to take from the treasury to be able to reach the castle? If the dragon overtakes the princess at exactly the same moment she has reached the castle, we assume that she reached the castle before the dragon reached her, and doesn't need an extra bijou to hold him off. | [{"input": "1\r\n2\r\n1\r\n1\r\n10\r\n", "output": ["2"]}, {"input": "1\r\n2\r\n1\r\n1\r\n8\r\n", "output": ["1"]}, {"input": "5\r\n8\r\n1\r\n2\r\n100\r\n", "output": ["2"]}, {"input": "2\r\n100\r\n10\r\n10\r\n739\r\n", "output": ["22"]}, {"input": "17\r\n99\r\n2\r\n3\r\n293\r\n", "output": ["3"]}, {"input": "5\r\n5\r\n1\r\n1\r\n1000\r\n", "output": ["0"]}, {"input": "100\r\n99\r\n1\r\n1\r\n1000\r\n", "output": ["0"]}, {"input": "1\r\n100\r\n1\r\n1\r\n1\r\n", "output": ["0"]}, {"input": "1\r\n100\r\n1\r\n1\r\n1000\r\n", "output": ["152"]}, {"input": "10\r\n1\r\n10\r\n1\r\n11\r\n", "output": ["0"]}, {"input": "98\r\n94\r\n4\r\n3\r\n437\r\n", "output": ["0"]}, {"input": "58\r\n4\r\n1\r\n10\r\n392\r\n", "output": ["0"]}, {"input": "74\r\n11\r\n8\r\n7\r\n835\r\n", "output": ["0"]}, {"input": "86\r\n21\r\n7\r\n2\r\n982\r\n", "output": ["0"]}, {"input": "2\r\n27\r\n4\r\n9\r\n937\r\n", "output": ["15"]}, {"input": "62\r\n89\r\n8\r\n1\r\n83\r\n", "output": ["0"]}, {"input": "78\r\n7\r\n7\r\n6\r\n38\r\n", "output": ["0"]}, {"input": "94\r\n14\r\n2\r\n3\r\n481\r\n", "output": ["0"]}, {"input": "6\r\n24\r\n9\r\n8\r\n628\r\n", "output": ["3"]}, {"input": "59\r\n7\r\n8\r\n10\r\n357\r\n", "output": ["0"]}, {"input": "75\r\n26\r\n4\r\n3\r\n504\r\n", "output": ["0"]}, {"input": "87\r\n32\r\n3\r\n8\r\n754\r\n", "output": ["0"]}, {"input": "51\r\n42\r\n10\r\n4\r\n901\r\n", "output": ["0"]}, {"input": "63\r\n4\r\n7\r\n1\r\n48\r\n", "output": ["0"]}, {"input": "79\r\n10\r\n4\r\n6\r\n3\r\n", "output": ["0"]}, {"input": "95\r\n20\r\n9\r\n3\r\n149\r\n", "output": ["0"]}, {"input": "55\r\n35\r\n5\r\n10\r\n592\r\n", "output": ["0"]}, {"input": "71\r\n45\r\n2\r\n6\r\n547\r\n", "output": ["0"]}, {"input": "83\r\n7\r\n7\r\n7\r\n46\r\n", "output": ["0"]}, {"input": "100\r\n32\r\n1\r\n8\r\n537\r\n", "output": ["0"]}, {"input": "17\r\n42\r\n10\r\n5\r\n684\r\n", "output": ["1"]}, {"input": "77\r\n1\r\n6\r\n8\r\n831\r\n", "output": ["0"]}, {"input": "93\r\n19\r\n3\r\n3\r\n82\r\n", "output": ["0"]}, {"input": "5\r\n25\r\n8\r\n9\r\n228\r\n", "output": ["2"]}, {"input": "21\r\n35\r\n5\r\n6\r\n535\r\n", "output": ["1"]}, {"input": "85\r\n45\r\n2\r\n1\r\n682\r\n", "output": ["0"]}, {"input": "97\r\n4\r\n8\r\n8\r\n829\r\n", "output": ["0"]}, {"input": "13\r\n14\r\n3\r\n3\r\n79\r\n", "output": ["0"]}, {"input": "25\r\n28\r\n4\r\n9\r\n226\r\n", "output": ["0"]}, {"input": "34\r\n9\r\n6\r\n6\r\n70\r\n", "output": ["0"]}, {"input": "50\r\n15\r\n1\r\n3\r\n216\r\n", "output": ["0"]}, {"input": "10\r\n25\r\n9\r\n8\r\n363\r\n", "output": ["1"]}, {"input": "26\r\n36\r\n4\r\n7\r\n318\r\n", "output": ["0"]}, {"input": "38\r\n50\r\n1\r\n8\r\n761\r\n", "output": ["1"]}, {"input": "2\r\n12\r\n6\r\n4\r\n907\r\n", "output": ["10"]}, {"input": "14\r\n18\r\n5\r\n9\r\n862\r\n", "output": ["1"]}, {"input": "30\r\n28\r\n4\r\n6\r\n9\r\n", "output": ["0"]}, {"input": "46\r\n39\r\n8\r\n3\r\n964\r\n", "output": ["0"]}, {"input": "6\r\n45\r\n7\r\n8\r\n407\r\n", "output": ["4"]}, {"input": "67\r\n34\r\n7\r\n4\r\n954\r\n", "output": ["0"]}, {"input": "31\r\n40\r\n6\r\n1\r\n397\r\n", "output": ["0"]}, {"input": "43\r\n50\r\n1\r\n8\r\n544\r\n", "output": ["1"]}, {"input": "59\r\n9\r\n7\r\n3\r\n498\r\n", "output": ["0"]}, {"input": "71\r\n19\r\n2\r\n10\r\n645\r\n", "output": ["0"]}, {"input": "35\r\n37\r\n9\r\n5\r\n792\r\n", "output": ["0"]}, {"input": "47\r\n43\r\n10\r\n9\r\n43\r\n", "output": ["0"]}, {"input": "63\r\n53\r\n5\r\n4\r\n189\r\n", "output": ["0"]}, {"input": "79\r\n11\r\n2\r\n1\r\n144\r\n", "output": ["0"]}, {"input": "39\r\n22\r\n8\r\n6\r\n291\r\n", "output": ["0"]}, {"input": "49\r\n7\r\n2\r\n5\r\n326\r\n", "output": ["0"]}, {"input": "2\r\n1\r\n1\r\n1\r\n1000\r\n", "output": ["0"]}, {"input": "100\r\n1\r\n1\r\n1\r\n1000\r\n", "output": ["0"]}, {"input": "2\r\n1\r\n1\r\n1\r\n100\r\n", "output": ["0"]}, {"input": "2\r\n1\r\n1\r\n1\r\n10\r\n", "output": ["0"]}, {"input": "5\r\n3\r\n3\r\n3\r\n999\r\n", "output": ["0"]}] | 100 | 100 | 100 | [{'input': '30\r\n28\r\n4\r\n6\r\n9\r\n', 'output': ['0']}, {'input': '5\r\n8\r\n1\r\n2\r\n100\r\n', 'output': ['2']}, {'input': '49\r\n7\r\n2\r\n5\r\n326\r\n', 'output': ['0']}, {'input': '2\r\n100\r\n10\r\n10\r\n739\r\n', 'output': ['22']}, {'input': '87\r\n32\r\n3\r\n8\r\n754\r\n', 'output': ['0']}] | [{'input': '50\r\n15\r\n1\r\n3\r\n216\r\n', 'output': ['0']}, {'input': '13\r\n14\r\n3\r\n3\r\n79\r\n', 'output': ['0']}, {'input': '85\r\n45\r\n2\r\n1\r\n682\r\n', 'output': ['0']}, {'input': '35\r\n37\r\n9\r\n5\r\n792\r\n', 'output': ['0']}, {'input': '2\r\n1\r\n1\r\n1\r\n1000\r\n', 'output': ['0']}] | [{'input': '2\r\n1\r\n1\r\n1\r\n1000\r\n', 'output': ['0']}, {'input': '2\r\n1\r\n1\r\n1\r\n100\r\n', 'output': ['0']}, {'input': '13\r\n14\r\n3\r\n3\r\n79\r\n', 'output': ['0']}, {'input': '63\r\n4\r\n7\r\n1\r\n48\r\n', 'output': ['0']}, {'input': '2\r\n12\r\n6\r\n4\r\n907\r\n', 'output': ['10']}] | [{'input': '93\r\n19\r\n3\r\n3\r\n82\r\n', 'output': ['0']}, {'input': '1\r\n2\r\n1\r\n1\r\n8\r\n', 'output': ['1']}, {'input': '31\r\n40\r\n6\r\n1\r\n397\r\n', 'output': ['0']}, {'input': '51\r\n42\r\n10\r\n4\r\n901\r\n', 'output': ['0']}, {'input': '50\r\n15\r\n1\r\n3\r\n216\r\n', 'output': ['0']}] | [{'input': '38\r\n50\r\n1\r\n8\r\n761\r\n', 'output': ['1']}, {'input': '67\r\n34\r\n7\r\n4\r\n954\r\n', 'output': ['0']}, {'input': '79\r\n11\r\n2\r\n1\r\n144\r\n', 'output': ['0']}, {'input': '1\r\n100\r\n1\r\n1\r\n1000\r\n', 'output': ['152']}, {'input': '79\r\n10\r\n4\r\n6\r\n3\r\n', 'output': ['0']}] | 100 | 100 | 100 | 100 | 100 | 100 | 85.71 | 100 | 100 | 100 | 100 | 75 | 100 | 100 | 100 | 11 | 100 | 97.142 | 95 |
["3 2 8", "1 2 -18", "2 2 -1"] | The first line contains three space-separated integers: a,βb,βc (1ββ€βaββ€β5;Β 1ββ€βbββ€β10000;Β β-β10000ββ€βcββ€β10000). | e477185b94f93006d7ae84c8f0817009 | #include <stdio.h>
#include <math.h>
int chk(long long x)
{
int ret = 0;
while(x)
{
ret += (x%10);
x/=10;
}
return ret;
}
long long po(long long int a,long long x)
{
if(x == 0)
return 1;
long long temp;
temp = po(a,x/2);
temp *= temp;
if(x%2)
temp *= a;
return temp;
}
int main()
{
long long int a,b,c;
scanf("%lld %lld %lld",&a,&b,&c);
long long int i;
int cnt = 0;
long long ans[100];
for(i=1;i<=81;i++)
{
long long temp = b*(po(i,a)) + c;
if(temp <= 1000000000 && temp >=0 && chk(temp) == i)
ans[cnt++] = temp;
}
printf("%d\n",cnt );
for(i=0;i<cnt;i++)
printf("%d ",ans[i] );
return 0;
} | ["3\n10 2008 13726", "0", "4\n1 31 337 967"] | C | null | Print integer n β the number of the solutions that you've found. Next print n integers in the increasing order β the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 109. | Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0β<βxβ<β109) of the equation:xβ=βbΒ·s(x)aβ+βc,β where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits in the decimal representation of number x.The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. | [{"input": "3 2 8\r\n", "output": ["3\r\n10 2008 13726"]}, {"input": "1 2 -18\r\n", "output": ["0"]}, {"input": "2 2 -1\r\n", "output": ["4\r\n1 31 337 967"]}, {"input": "1 1 0\r\n", "output": ["9\r\n1 2 3 4 5 6 7 8 9"]}, {"input": "1 37 963\r\n", "output": ["16\r\n1000 1111 1222 1333 1370 1407 1444 1481 1518 1555 1592 1629 1666 1777 1888 1999"]}, {"input": "1 298 -1665\r\n", "output": ["17\r\n123 421 1017 1315 1613 1911 2209 2507 2805 4295 4593 4891 5189 5487 5785 6679 6977"]}, {"input": "1 3034 -9234\r\n", "output": ["23\r\n12004 21106 24140 30208 33242 39310 42344 48412 51446 54480 57514 60548 63582 66616 69650 72684 75718 78752 81786 87854 90888 96956 99990"]}, {"input": "5 9998 9998\r\n", "output": ["0"]}, {"input": "5 10000 10000\r\n", "output": ["0"]}, {"input": "5 65 352\r\n", "output": ["1\r\n208000352"]}, {"input": "5 9999 9999\r\n", "output": ["0"]}, {"input": "4 2099 -38\r\n", "output": ["0"]}, {"input": "1 1 -6708\r\n", "output": ["0"]}, {"input": "5 36 -46\r\n", "output": ["0"]}, {"input": "5 8975 -4\r\n", "output": ["0"]}, {"input": "3 2794 -3354\r\n", "output": ["5\r\n165733932 308990694 392855398 415958984 999999980"]}, {"input": "5 1 4473\r\n", "output": ["11\r\n1424330 14353380 17214841 52526348 60470649 69348430 164920697 184532598 205967449 418199966 459169497"]}, {"input": "5 1 -9999\r\n", "output": ["6\r\n90001 2466100 17200369 52511876 60456177 205952977"]}, {"input": "4 4 6\r\n", "output": ["13\r\n10 1030 40006 114250 202506 262150 521290 937030 1562506 2458630 3694090 4743690 7496650"]}, {"input": "5 19 -666\r\n", "output": ["0"]}, {"input": "5 5 -865\r\n", "output": ["0"]}, {"input": "2 8468 -3666\r\n", "output": ["2\r\n7117922 14933886"]}, {"input": "4 9359 -3039\r\n", "output": ["0"]}, {"input": "5 5706 -1856\r\n", "output": ["0"]}, {"input": "2 6828 -39\r\n", "output": ["2\r\n7435653 17759589"]}, {"input": "5 3903 -9847\r\n", "output": ["0"]}, {"input": "3 1727 4771\r\n", "output": ["1\r\n42124574"]}, {"input": "4 1870 9912\r\n", "output": ["0"]}, {"input": "3 6300 7035\r\n", "output": ["1\r\n466761435"]}, {"input": "5 8704 -6190\r\n", "output": ["0"]}, {"input": "2 68 3\r\n", "output": ["1\r\n45971"]}, {"input": "5 6 -95\r\n", "output": ["1\r\n416063647"]}, {"input": "2 28 12\r\n", "output": ["2\r\n4044 7180"]}, {"input": "3 37 -70\r\n", "output": ["0"]}, {"input": "5 3 53\r\n", "output": ["1\r\n100663349"]}, {"input": "3 2570 4109\r\n", "output": ["2\r\n427587859 999777799"]}, {"input": "3 1139 6335\r\n", "output": ["2\r\n12134407 499999999"]}, {"input": "3 2278 -1329\r\n", "output": ["3\r\n61504671 145790671 999985999"]}, {"input": "4 30 719\r\n", "output": ["2\r\n21219149 899597999"]}, {"input": "4 9023 312\r\n", "output": ["0"]}, {"input": "5 10000 9\r\n", "output": ["0"]}, {"input": "5 7698 5337\r\n", "output": ["0"]}, {"input": "5 1 0\r\n", "output": ["5\r\n1 17210368 52521875 60466176 205962976"]}, {"input": "5 12 3\r\n", "output": ["0"]}, {"input": "5 3903 153\r\n", "output": ["0"]}, {"input": "5 10000 0\r\n", "output": ["1\r\n10000"]}, {"input": "3 2570 -6691\r\n", "output": ["1\r\n999766999"]}, {"input": "5 5 13\r\n", "output": ["1\r\n579281018"]}] | 100 | 100 | 100 | [{'input': '1 1 -6708\r\n', 'output': ['0']}, {'input': '5 7698 5337\r\n', 'output': ['0']}, {'input': '2 28 12\r\n', 'output': ['2\r\n4044 7180']}, {'input': '1 1 0\r\n', 'output': ['9\r\n1 2 3 4 5 6 7 8 9']}, {'input': '3 1727 4771\r\n', 'output': ['1\r\n42124574']}] | [{'input': '4 1870 9912\r\n', 'output': ['0']}, {'input': '2 6828 -39\r\n', 'output': ['2\r\n7435653 17759589']}, {'input': '5 65 352\r\n', 'output': ['1\r\n208000352']}, {'input': '2 28 12\r\n', 'output': ['2\r\n4044 7180']}, {'input': '5 7698 5337\r\n', 'output': ['0']}] | [{'input': '3 1727 4771\r\n', 'output': ['1\r\n42124574']}, {'input': '5 3903 -9847\r\n', 'output': ['0']}, {'input': '1 37 963\r\n', 'output': ['16\r\n1000 1111 1222 1333 1370 1407 1444 1481 1518 1555 1592 1629 1666 1777 1888 1999']}, {'input': '5 5 -865\r\n', 'output': ['0']}, {'input': '2 8468 -3666\r\n', 'output': ['2\r\n7117922 14933886']}] | [{'input': '5 36 -46\r\n', 'output': ['0']}, {'input': '4 1870 9912\r\n', 'output': ['0']}, {'input': '5 10000 10000\r\n', 'output': ['0']}, {'input': '4 9359 -3039\r\n', 'output': ['0']}, {'input': '5 5 13\r\n', 'output': ['1\r\n579281018']}] | [{'input': '3 1139 6335\r\n', 'output': ['2\r\n12134407 499999999']}, {'input': '2 6828 -39\r\n', 'output': ['2\r\n7435653 17759589']}, {'input': '5 5 -865\r\n', 'output': ['0']}, {'input': '1 2 -18\r\n', 'output': ['0']}, {'input': '3 1727 4771\r\n', 'output': ['1\r\n42124574']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 93.75 | 100 | 100 | 100 | 12 | 100 | 100 | 98.75 |
["1 6 1 2 1 6", "6 5 4 3 2 1", "10 10 1 1 10 10"] | The first line contains six integers n, m, x1, y1, x2, y2 β the board sizes and the coordinates of the first and second chips, correspondingly (1ββ€βn,βmββ€β100; 2ββ€βnβΓβm; 1ββ€βx1,βx2ββ€βn; 1ββ€βy1,βy2ββ€βm). The numbers in the line are separated by single spaces. It is guaranteed that the chips are located in different squares. | 41f6f90b7307d2383495441114fa8ea2 | #include <stdio.h>
#include <stdlib.h>
int main()
{
int i, j, n, m, x1, y1, x2, y2;
scanf("%d %d %d %d %d %d", &n, &m, &x1, &y1, &x2, &y2);
i = abs(x1 - x2);
j = abs(y1 - y2);
if (i > j) {
int aux = i;
i = j;
j = aux;
}
if ((i <= 2 && j <= 4) || (i == 3 && j == 3)) {
puts("First");
} else {
puts("Second");
}
return 0;
}
| ["First", "First", "Second"] | C | null | If the first player wins, print "First" without the quotes. Otherwise, print "Second" without the quotes. | Two players play a game. The game is played on a rectangular board with nβΓβm squares. At the beginning of the game two different squares of the board have two chips. The first player's goal is to shift the chips to the same square. The second player aims to stop the first one with a tube of superglue.We'll describe the rules of the game in more detail.The players move in turns. The first player begins.With every move the first player chooses one of his unglued chips, and shifts it one square to the left, to the right, up or down. It is not allowed to move a chip beyond the board edge. At the beginning of a turn some squares of the board may be covered with a glue. The first player can move the chip to such square, in this case the chip gets tightly glued and cannot move any longer.At each move the second player selects one of the free squares (which do not contain a chip or a glue) and covers it with superglue. The glue dries long and squares covered with it remain sticky up to the end of the game.If, after some move of the first player both chips are in the same square, then the first player wins. If the first player cannot make a move (both of his chips are glued), then the second player wins. Note that the situation where the second player cannot make a move is impossible β he can always spread the glue on the square from which the first player has just moved the chip.We will further clarify the case where both chips are glued and are in the same square. In this case the first player wins as the game ends as soon as both chips are in the same square, and the condition of the loss (the inability to move) does not arise.You know the board sizes and the positions of the two chips on it. At the beginning of the game all board squares are glue-free. Find out who wins if the players play optimally. | [{"input": "1 6 1 2 1 6\r\n", "output": ["First"]}, {"input": "6 5 4 3 2 1\r\n", "output": ["First"]}, {"input": "10 10 1 1 10 10\r\n", "output": ["Second"]}, {"input": "1 2 1 1 1 2\r\n", "output": ["First"]}, {"input": "4 4 1 4 4 1\r\n", "output": ["First"]}, {"input": "25 32 17 18 20 19\r\n", "output": ["First"]}, {"input": "30 1 10 1 20 1\r\n", "output": ["Second"]}, {"input": "28 17 20 10 27 2\r\n", "output": ["Second"]}, {"input": "5 5 1 1 5 5\r\n", "output": ["Second"]}, {"input": "5 4 1 4 5 1\r\n", "output": ["Second"]}, {"input": "95 28 50 12 50 13\r\n", "output": ["First"]}, {"input": "7 41 3 5 3 6\r\n", "output": ["First"]}, {"input": "45 62 28 48 28 50\r\n", "output": ["First"]}, {"input": "57 17 12 7 12 10\r\n", "output": ["First"]}, {"input": "73 88 30 58 30 62\r\n", "output": ["First"]}, {"input": "33 13 12 1 12 6\r\n", "output": ["Second"]}, {"input": "49 34 38 19 38 25\r\n", "output": ["Second"]}, {"input": "61 39 14 30 14 37\r\n", "output": ["Second"]}, {"input": "100 32 71 12 71 22\r\n", "output": ["Second"]}, {"input": "96 54 9 30 9 47\r\n", "output": ["Second"]}, {"input": "57 85 29 40 29 69\r\n", "output": ["Second"]}, {"input": "64 96 4 2 4 80\r\n", "output": ["Second"]}, {"input": "99 100 24 1 24 100\r\n", "output": ["Second"]}, {"input": "18 72 2 71 3 71\r\n", "output": ["First"]}, {"input": "24 68 19 14 18 15\r\n", "output": ["First"]}, {"input": "24 32 6 2 7 4\r\n", "output": ["First"]}, {"input": "28 14 21 2 20 5\r\n", "output": ["First"]}, {"input": "30 85 9 45 8 49\r\n", "output": ["First"]}, {"input": "34 55 7 25 8 30\r\n", "output": ["Second"]}, {"input": "34 39 18 1 17 7\r\n", "output": ["Second"]}, {"input": "21 18 16 6 15 17\r\n", "output": ["Second"]}, {"input": "37 100 33 13 32 30\r\n", "output": ["Second"]}, {"input": "11 97 2 29 1 76\r\n", "output": ["Second"]}, {"input": "89 100 54 1 55 100\r\n", "output": ["Second"]}, {"input": "80 97 70 13 68 13\r\n", "output": ["First"]}, {"input": "24 97 21 54 19 55\r\n", "output": ["First"]}, {"input": "76 7 24 4 26 6\r\n", "output": ["First"]}, {"input": "20 77 5 49 3 52\r\n", "output": ["First"]}, {"input": "18 18 11 12 13 16\r\n", "output": ["First"]}, {"input": "60 100 28 80 26 85\r\n", "output": ["Second"]}, {"input": "14 96 3 80 1 86\r\n", "output": ["Second"]}, {"input": "40 43 40 9 38 28\r\n", "output": ["Second"]}, {"input": "44 99 10 5 8 92\r\n", "output": ["Second"]}, {"input": "52 70 26 65 23 65\r\n", "output": ["First"]}, {"input": "13 25 4 2 7 3\r\n", "output": ["First"]}, {"input": "36 76 36 49 33 51\r\n", "output": ["First"]}, {"input": "64 91 52 64 49 67\r\n", "output": ["First"]}, {"input": "87 15 56 8 59 12\r\n", "output": ["Second"]}, {"input": "48 53 24 37 21 42\r\n", "output": ["Second"]}, {"input": "71 85 10 14 13 20\r\n", "output": ["Second"]}, {"input": "23 90 6 31 9 88\r\n", "output": ["Second"]}, {"input": "47 95 27 70 23 70\r\n", "output": ["First"]}, {"input": "63 54 19 22 23 23\r\n", "output": ["First"]}, {"input": "47 91 36 61 32 63\r\n", "output": ["First"]}, {"input": "63 22 54 16 58 19\r\n", "output": ["Second"]}, {"input": "15 11 12 5 8 9\r\n", "output": ["Second"]}, {"input": "31 80 28 70 24 75\r\n", "output": ["Second"]}, {"input": "15 48 6 42 10 48\r\n", "output": ["Second"]}, {"input": "21 68 2 13 6 57\r\n", "output": ["Second"]}, {"input": "73 64 63 32 68 32\r\n", "output": ["Second"]}, {"input": "89 81 33 18 28 19\r\n", "output": ["Second"]}, {"input": "13 62 10 13 5 15\r\n", "output": ["Second"]}, {"input": "35 19 4 8 9 11\r\n", "output": ["Second"]}, {"input": "51 8 24 3 19 7\r\n", "output": ["Second"]}, {"input": "73 27 40 8 45 13\r\n", "output": ["Second"]}, {"input": "51 76 50 5 45 76\r\n", "output": ["Second"]}, {"input": "74 88 33 20 39 20\r\n", "output": ["Second"]}, {"input": "28 7 17 5 11 6\r\n", "output": ["Second"]}, {"input": "8 33 2 21 8 23\r\n", "output": ["Second"]}, {"input": "30 47 9 32 3 35\r\n", "output": ["Second"]}, {"input": "10 5 10 1 4 5\r\n", "output": ["Second"]}, {"input": "84 43 71 6 77 26\r\n", "output": ["Second"]}, {"input": "87 13 77 7 70 7\r\n", "output": ["Second"]}, {"input": "41 34 27 7 20 8\r\n", "output": ["Second"]}, {"input": "73 79 17 42 10 67\r\n", "output": ["Second"]}, {"input": "48 86 31 36 23 36\r\n", "output": ["Second"]}, {"input": "16 97 7 4 15 94\r\n", "output": ["Second"]}, {"input": "48 11 33 8 24 8\r\n", "output": ["Second"]}, {"input": "39 46 21 22 30 35\r\n", "output": ["Second"]}, {"input": "96 75 15 10 6 65\r\n", "output": ["Second"]}, {"input": "25 68 3 39 20 41\r\n", "output": ["Second"]}, {"input": "41 64 10 21 29 50\r\n", "output": ["Second"]}, {"input": "24 65 23 18 3 64\r\n", "output": ["Second"]}, {"input": "40 100 4 1 30 100\r\n", "output": ["Second"]}, {"input": "73 95 58 11 11 24\r\n", "output": ["Second"]}, {"input": "89 51 76 1 25 51\r\n", "output": ["Second"]}, {"input": "77 99 56 1 3 99\r\n", "output": ["Second"]}, {"input": "97 94 96 2 7 93\r\n", "output": ["Second"]}, {"input": "100 100 1 1 100 100\r\n", "output": ["Second"]}, {"input": "100 94 1 30 100 30\r\n", "output": ["Second"]}, {"input": "10 10 1 1 4 5\r\n", "output": ["Second"]}, {"input": "5 5 1 1 4 5\r\n", "output": ["Second"]}, {"input": "100 100 1 1 5 4\r\n", "output": ["Second"]}, {"input": "100 100 10 10 13 14\r\n", "output": ["Second"]}, {"input": "10 10 1 1 5 4\r\n", "output": ["Second"]}, {"input": "10 10 1 1 1 6\r\n", "output": ["Second"]}, {"input": "100 100 1 1 4 5\r\n", "output": ["Second"]}, {"input": "100 100 1 1 3 5\r\n", "output": ["First"]}, {"input": "4 5 1 1 4 5\r\n", "output": ["Second"]}, {"input": "5 5 1 1 3 5\r\n", "output": ["First"]}, {"input": "50 50 1 1 5 4\r\n", "output": ["Second"]}, {"input": "5 5 1 5 4 1\r\n", "output": ["Second"]}, {"input": "100 100 1 1 2 6\r\n", "output": ["Second"]}, {"input": "50 50 1 1 4 5\r\n", "output": ["Second"]}, {"input": "5 5 1 1 5 4\r\n", "output": ["Second"]}, {"input": "10 10 1 1 3 5\r\n", "output": ["First"]}, {"input": "6 6 1 1 6 1\r\n", "output": ["Second"]}, {"input": "5 4 1 1 5 4\r\n", "output": ["Second"]}, {"input": "6 2 6 1 1 2\r\n", "output": ["Second"]}, {"input": "10 10 3 4 3 5\r\n", "output": ["First"]}, {"input": "10 10 1 1 5 3\r\n", "output": ["First"]}, {"input": "10 10 6 1 1 1\r\n", "output": ["Second"]}, {"input": "10 10 1 1 6 2\r\n", "output": ["Second"]}, {"input": "50 50 1 1 5 2\r\n", "output": ["First"]}, {"input": "3 5 1 1 3 5\r\n", "output": ["First"]}, {"input": "5 5 1 1 5 3\r\n", "output": ["First"]}, {"input": "10 10 7 7 3 4\r\n", "output": ["Second"]}, {"input": "100 100 1 1 5 1\r\n", "output": ["First"]}, {"input": "6 6 1 1 1 6\r\n", "output": ["Second"]}] | 100 | 100 | 100 | [{'input': '10 10 1 1 10 10\r\n', 'output': ['Second']}, {'input': '13 62 10 13 5 15\r\n', 'output': ['Second']}, {'input': '48 53 24 37 21 42\r\n', 'output': ['Second']}, {'input': '64 91 52 64 49 67\r\n', 'output': ['First']}, {'input': '25 68 3 39 20 41\r\n', 'output': ['Second']}] | [{'input': '1 2 1 1 1 2\r\n', 'output': ['First']}, {'input': '60 100 28 80 26 85\r\n', 'output': ['Second']}, {'input': '89 100 54 1 55 100\r\n', 'output': ['Second']}, {'input': '73 27 40 8 45 13\r\n', 'output': ['Second']}, {'input': '3 5 1 1 3 5\r\n', 'output': ['First']}] | [{'input': '50 50 1 1 5 4\r\n', 'output': ['Second']}, {'input': '16 97 7 4 15 94\r\n', 'output': ['Second']}, {'input': '10 10 1 1 1 6\r\n', 'output': ['Second']}, {'input': '63 22 54 16 58 19\r\n', 'output': ['Second']}, {'input': '48 53 24 37 21 42\r\n', 'output': ['Second']}] | [{'input': '5 5 1 1 4 5\r\n', 'output': ['Second']}, {'input': '47 91 36 61 32 63\r\n', 'output': ['First']}, {'input': '95 28 50 12 50 13\r\n', 'output': ['First']}, {'input': '10 10 1 1 6 2\r\n', 'output': ['Second']}, {'input': '100 100 1 1 3 5\r\n', 'output': ['First']}] | [{'input': '7 41 3 5 3 6\r\n', 'output': ['First']}, {'input': '61 39 14 30 14 37\r\n', 'output': ['Second']}, {'input': '47 95 27 70 23 70\r\n', 'output': ['First']}, {'input': '4 4 1 4 4 1\r\n', 'output': ['First']}, {'input': '100 100 1 1 3 5\r\n', 'output': ['First']}] | 100 | 100 | 100 | 100 | 100 | 100 | 75 | 91.67 | 100 | 100 | 90 | 60 | 80 | 90 | 90 | 13 | 100 | 93.334 | 82 |
["2 3", "8 2"] | The first line of the input contains two integers, given in the decimal notation, n and m (1ββ€βn,βmββ€β109)Β β the number of hours in one day and the number of minutes in one hour, respectively. | 0930c75f57dd88a858ba7bb0f11f1b1c | #include <stdlib.h>
#include <stdio.h>
int main() {
int n, m, d;
scanf("%d%d", &n, &m);
int dn = 1, dm = 1;
for(int k = 7 ; k < n ; k *= 7) dn++;
for(int k = 7 ; k < m ; k *= 7) dm++;
d = dn + dm;
if(d > 7) {
printf("0\n");
return 0;
}
int r = 0;
for(int i=0 ; i<n ; i++) {
for(int j=0 ; j<m ; j++) {
int u[7] = {0};
int a = i, b = j;
for(int k=0 ; k<dn ; k++) {
u[a%7]++;
a /= 7;
}
for(int k=0 ; k<dm ; k++) {
u[b%7]++;
b /= 7;
}
r++;
for(int k=0 ; k<7 ; k++) {
if(u[k] > 1) {
r--;
break;
}
}
}
}
printf("%d\n", r);
return 0;
} | ["4", "5"] | C | NoteIn the first sample, possible pairs are: (0:β1), (0:β2), (1:β0), (1:β2).In the second sample, possible pairs are: (02:β1), (03:β1), (04:β1), (05:β1), (06:β1). | Print one integer in decimal notationΒ β the number of different pairs of hour and minute, such that all digits displayed on the watches are distinct. | Robbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of catching them even harder, they use their own watches.First, as they know that kingdom police is bad at math, robbers use the positional numeral system with base 7. Second, they divide one day in n hours, and each hour in m minutes. Personal watches of each robber are divided in two parts: first of them has the smallest possible number of places that is necessary to display any integer from 0 to nβ-β1, while the second has the smallest possible number of places that is necessary to display any integer from 0 to mβ-β1. Finally, if some value of hours or minutes can be displayed using less number of places in base 7 than this watches have, the required number of zeroes is added at the beginning of notation.Note that to display number 0 section of the watches is required to have at least one place.Little robber wants to know the number of moments of time (particular values of hours and minutes), such that all digits displayed on the watches are distinct. Help her calculate this number. | [{"input": "2 3\r\n", "output": ["4"]}, {"input": "8 2\r\n", "output": ["5"]}, {"input": "1 1\r\n", "output": ["0"]}, {"input": "1 2\r\n", "output": ["1"]}, {"input": "8 8\r\n", "output": ["0"]}, {"input": "50 50\r\n", "output": ["0"]}, {"input": "344 344\r\n", "output": ["0"]}, {"input": "282475250 282475250\r\n", "output": ["0"]}, {"input": "8 282475250\r\n", "output": ["0"]}, {"input": "1000000000 1000000000\r\n", "output": ["0"]}, {"input": "16808 7\r\n", "output": ["720"]}, {"input": "2402 50\r\n", "output": ["0"]}, {"input": "343 2401\r\n", "output": ["5040"]}, {"input": "1582 301\r\n", "output": ["2874"]}, {"input": "421414245 4768815\r\n", "output": ["0"]}, {"input": "2401 343\r\n", "output": ["5040"]}, {"input": "2 1\r\n", "output": ["1"]}, {"input": "282475250 8\r\n", "output": ["0"]}, {"input": "8 7\r\n", "output": ["35"]}, {"input": "50 7\r\n", "output": ["120"]}, {"input": "16808 8\r\n", "output": ["0"]}, {"input": "2402 49\r\n", "output": ["720"]}, {"input": "123 123\r\n", "output": ["360"]}, {"input": "123 456\r\n", "output": ["150"]}, {"input": "1 9\r\n", "output": ["0"]}, {"input": "1 10\r\n", "output": ["1"]}, {"input": "50 67\r\n", "output": ["6"]}, {"input": "7 117649\r\n", "output": ["5040"]}, {"input": "2400 342\r\n", "output": ["5040"]}, {"input": "2400 227\r\n", "output": ["3360"]}, {"input": "117648 5\r\n", "output": ["3600"]}, {"input": "16808 41\r\n", "output": ["0"]}, {"input": "3 16808\r\n", "output": ["240"]}, {"input": "823542 3\r\n", "output": ["0"]}, {"input": "3 823544\r\n", "output": ["0"]}, {"input": "117650 5\r\n", "output": ["0"]}, {"input": "50 50\r\n", "output": ["0"]}, {"input": "50 3\r\n", "output": ["40"]}, {"input": "2402 343\r\n", "output": ["0"]}] | 100 | 100 | 100 | [{'input': '2402 50\r\n', 'output': ['0']}, {'input': '3 16808\r\n', 'output': ['240']}, {'input': '50 7\r\n', 'output': ['120']}, {'input': '16808 41\r\n', 'output': ['0']}, {'input': '8 282475250\r\n', 'output': ['0']}] | [{'input': '8 8\r\n', 'output': ['0']}, {'input': '50 7\r\n', 'output': ['120']}, {'input': '2402 49\r\n', 'output': ['720']}, {'input': '1 1\r\n', 'output': ['0']}, {'input': '2 3\r\n', 'output': ['4']}] | [{'input': '3 823544\r\n', 'output': ['0']}, {'input': '282475250 282475250\r\n', 'output': ['0']}, {'input': '8 8\r\n', 'output': ['0']}, {'input': '2402 343\r\n', 'output': ['0']}, {'input': '1 2\r\n', 'output': ['1']}] | [{'input': '8 2\r\n', 'output': ['5']}, {'input': '8 8\r\n', 'output': ['0']}, {'input': '2402 49\r\n', 'output': ['720']}, {'input': '117650 5\r\n', 'output': ['0']}, {'input': '343 2401\r\n', 'output': ['5040']}] | [{'input': '7 117649\r\n', 'output': ['5040']}, {'input': '282475250 8\r\n', 'output': ['0']}, {'input': '343 2401\r\n', 'output': ['5040']}, {'input': '50 7\r\n', 'output': ['120']}, {'input': '344 344\r\n', 'output': ['0']}] | 100 | 100 | 100 | 100 | 100 | 100 | 92.59 | 100 | 100 | 100 | 100 | 94.44 | 100 | 100 | 100 | 14 | 100 | 98.518 | 98.888 |
["500 1000 20 30", "1000 1000 1 1", "1500 1000 176 177"] | The first line contains four integers a, b, c, d (250ββ€βa,βbββ€β3500, 0ββ€βc,βdββ€β180). It is guaranteed that numbers a and b are divisible by 250 (just like on any real Codeforces round). | 95b19d7569d6b70bd97d46a8541060d0 | #include <stdio.h>
int max(int a, int b){
int maxim;
return maxim=(a>=b)?a:b;
}
int main(void)
{
int a,b,c,d, misha, vasya;
scanf("%d %d %d %d", &a,&b,&c,&d);
misha = max((3*a)/10 ,a- ((a*c)/250));
vasya = max((3*b)/10 ,b-((b*d)/250));
if(misha>vasya) printf("Misha");
else if(misha<vasya) printf("Vasya");
else printf("Tie");
return 0;
}
| ["Vasya", "Tie", "Misha"] | C | null | Output on a single line: "Misha" (without the quotes), if Misha got more points than Vasya. "Vasya" (without the quotes), if Vasya got more points than Misha. "Tie" (without the quotes), if both of them got the same number of points. | Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully submitted it at the first attempt. Misha solved the problem that costs a points and Vasya solved the problem that costs b points. Besides, Misha submitted the problem c minutes after the contest started and Vasya submitted the problem d minutes after the contest started. As you know, on Codeforces the cost of a problem reduces as a round continues. That is, if you submit a problem that costs p points t minutes after the contest started, you get points. Misha and Vasya are having an argument trying to find out who got more points. Help them to find out the truth. | [{"input": "500 1000 20 30\r\n", "output": ["Vasya"]}, {"input": "1000 1000 1 1\r\n", "output": ["Tie"]}, {"input": "1500 1000 176 177\r\n", "output": ["Misha"]}, {"input": "1500 1000 74 177\r\n", "output": ["Misha"]}, {"input": "750 2500 175 178\r\n", "output": ["Vasya"]}, {"input": "750 1000 54 103\r\n", "output": ["Tie"]}, {"input": "2000 1250 176 130\r\n", "output": ["Tie"]}, {"input": "1250 1750 145 179\r\n", "output": ["Tie"]}, {"input": "2000 2000 176 179\r\n", "output": ["Tie"]}, {"input": "1500 1500 148 148\r\n", "output": ["Tie"]}, {"input": "2750 1750 134 147\r\n", "output": ["Misha"]}, {"input": "3250 250 175 173\r\n", "output": ["Misha"]}, {"input": "500 500 170 176\r\n", "output": ["Misha"]}, {"input": "250 1000 179 178\r\n", "output": ["Vasya"]}, {"input": "3250 1000 160 138\r\n", "output": ["Misha"]}, {"input": "3000 2000 162 118\r\n", "output": ["Tie"]}, {"input": "1500 1250 180 160\r\n", "output": ["Tie"]}, {"input": "1250 2500 100 176\r\n", "output": ["Tie"]}, {"input": "3500 3500 177 178\r\n", "output": ["Tie"]}, {"input": "3000 3250 16 34\r\n", "output": ["Tie"]}, {"input": "1750 3000 137 49\r\n", "output": ["Vasya"]}, {"input": "500 1500 179 71\r\n", "output": ["Vasya"]}, {"input": "1250 2000 101 180\r\n", "output": ["Misha"]}, {"input": "250 750 180 176\r\n", "output": ["Vasya"]}, {"input": "2250 2250 163 145\r\n", "output": ["Vasya"]}, {"input": "3000 3000 176 78\r\n", "output": ["Vasya"]}, {"input": "250 3500 8 178\r\n", "output": ["Vasya"]}, {"input": "1750 1250 179 180\r\n", "output": ["Misha"]}, {"input": "2750 1750 13 164\r\n", "output": ["Misha"]}, {"input": "1750 2250 178 53\r\n", "output": ["Vasya"]}, {"input": "2500 2750 73 179\r\n", "output": ["Misha"]}, {"input": "1000 3500 178 175\r\n", "output": ["Vasya"]}, {"input": "1000 500 7 162\r\n", "output": ["Misha"]}, {"input": "1000 250 175 48\r\n", "output": ["Misha"]}, {"input": "1750 500 166 177\r\n", "output": ["Misha"]}, {"input": "250 250 0 0\r\n", "output": ["Tie"]}, {"input": "250 3500 0 0\r\n", "output": ["Vasya"]}, {"input": "250 3500 0 180\r\n", "output": ["Vasya"]}, {"input": "3500 3500 180 180\r\n", "output": ["Tie"]}, {"input": "3500 250 0 180\r\n", "output": ["Misha"]}] | 100 | 100 | 100 | [{'input': '500 500 170 176\r\n', 'output': ['Misha']}, {'input': '1250 2000 101 180\r\n', 'output': ['Misha']}, {'input': '750 2500 175 178\r\n', 'output': ['Vasya']}, {'input': '1000 1000 1 1\r\n', 'output': ['Tie']}, {'input': '750 1000 54 103\r\n', 'output': ['Tie']}] | [{'input': '1750 500 166 177\r\n', 'output': ['Misha']}, {'input': '1000 500 7 162\r\n', 'output': ['Misha']}, {'input': '2750 1750 134 147\r\n', 'output': ['Misha']}, {'input': '1500 1250 180 160\r\n', 'output': ['Tie']}, {'input': '2000 1250 176 130\r\n', 'output': ['Tie']}] | [{'input': '250 3500 0 0\r\n', 'output': ['Vasya']}, {'input': '2750 1750 134 147\r\n', 'output': ['Misha']}, {'input': '500 1500 179 71\r\n', 'output': ['Vasya']}, {'input': '1250 2000 101 180\r\n', 'output': ['Misha']}, {'input': '1750 1250 179 180\r\n', 'output': ['Misha']}] | [{'input': '1000 1000 1 1\r\n', 'output': ['Tie']}, {'input': '750 1000 54 103\r\n', 'output': ['Tie']}, {'input': '3000 3000 176 78\r\n', 'output': ['Vasya']}, {'input': '500 1500 179 71\r\n', 'output': ['Vasya']}, {'input': '2000 2000 176 179\r\n', 'output': ['Tie']}] | [{'input': '500 1000 20 30\r\n', 'output': ['Vasya']}, {'input': '250 3500 0 180\r\n', 'output': ['Vasya']}, {'input': '250 250 0 0\r\n', 'output': ['Tie']}, {'input': '1000 3500 178 175\r\n', 'output': ['Vasya']}, {'input': '2750 1750 134 147\r\n', 'output': ['Misha']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 90 | 100 | 100 | 100 | 75 | 75 | 75 | 100 | 15 | 100 | 98 | 85 |
["4 2 4\n3 4\n1 1", "5 4 0\n1 2\n3 1"] | The first line contains three integers s, x1 and x2 (2ββ€βsββ€β1000, 0ββ€βx1,βx2ββ€βs, x1ββ βx2)Β β the maximum coordinate of the point to which the tram goes, the point Igor is at, and the point he should come to. The second line contains two integers t1 and t2 (1ββ€βt1,βt2ββ€β1000)Β β the time in seconds in which the tram passes 1 meter and the time in seconds in which Igor passes 1 meter. The third line contains two integers p and d (1ββ€βpββ€βsβ-β1, d is either 1 or )Β β the position of the tram in the moment Igor came to the point x1 and the direction of the tram at this moment. If , the tram goes in the direction from the point s to the point 0. If dβ=β1, the tram goes in the direction from the point 0 to the point s. | fb3aca6eba3a952e9d5736c5d8566821 | #include<stdio.h>
int t,T1,T2,s,f,x1,x2,p,d,t1,t2,i;///T2 οΏ½οΏ½ T1 οΏ½οΏ½
int main()
{
scanf("%d %d %d %d %d %d %d",&s,&x1,&x2,&t1,&t2,&p,&d);
if(x2-x1>0) f=1;
else f=-1;
T2=(x2-x1)*t2*f;
if(t1<t2){
if((x1<x2&&x2<=p&&d<0)||(x1<=p&&p<=x2&&d<0)||(p<=x1&&x1<x2)||(x1<=p&&x1>x2&&d<0)){
t=(f*x1-d*p)*t1*t2/(t2-t1);
}
else
t=(2*s+x1*f-d*p)*t1*t2/(t2-t1);
}
else
{
printf("%d",T2);
return 0;
}
if(t<T2){
if((x1<x2&&x2<=p&&d<0)||(x1<=p&&p<=x2&&d<0)||(p<=x1&&x1<x2)||(x1<=p&&x1>x2&&d<0)){
t=(f*x2-d*p)*t1;
}
else
t=(2*s+x2*f-d*p)*t1;
printf("%d",t);
}
else
printf("%d",T2);
return 0;
}
| ["8", "7"] | C | NoteIn the first example it is profitable for Igor to go by foot and not to wait the tram. Thus, he has to pass 2 meters and it takes 8 seconds in total, because he passes 1 meter per 4 seconds. In the second example Igor can, for example, go towards the point x2 and get to the point 1 in 6 seconds (because he has to pass 3 meters, but he passes 1 meters per 2 seconds). At that moment the tram will be at the point 1, so Igor can enter the tram and pass 1 meter in 1 second. Thus, Igor will reach the point x2 in 7 seconds in total. | Print the minimum time in seconds which Igor needs to get from the point x1 to the point x2. | The tram in Berland goes along a straight line from the point 0 to the point s and back, passing 1 meter per t1 seconds in both directions. It means that the tram is always in the state of uniform rectilinear motion, instantly turning around at points xβ=β0 and xβ=βs.Igor is at the point x1. He should reach the point x2. Igor passes 1 meter per t2 seconds. Your task is to determine the minimum time Igor needs to get from the point x1 to the point x2, if it is known where the tram is and in what direction it goes at the moment Igor comes to the point x1.Igor can enter the tram unlimited number of times at any moment when his and the tram's positions coincide. It is not obligatory that points in which Igor enter and exit the tram are integers. Assume that any boarding and unboarding happens instantly. Igor can move arbitrary along the line (but not faster than 1 meter per t2 seconds). He can also stand at some point for some time. | [{"input": "4 2 4\r\n3 4\r\n1 1\r\n", "output": ["8"]}, {"input": "5 4 0\r\n1 2\r\n3 1\r\n", "output": ["7"]}, {"input": "5 4 0\r\n5 14\r\n1 -1\r\n", "output": ["55"]}, {"input": "10 7 2\r\n7 9\r\n9 -1\r\n", "output": ["45"]}, {"input": "20 5 19\r\n163 174\r\n4 1\r\n", "output": ["2436"]}, {"input": "1000 610 733\r\n226 690\r\n357 1\r\n", "output": ["84870"]}, {"input": "40 31 14\r\n628 1000\r\n36 1\r\n", "output": ["17000"]}, {"input": "100 20 83\r\n186 434\r\n64 -1\r\n", "output": ["27342"]}, {"input": "200 179 81\r\n126 457\r\n37 -1\r\n", "output": ["44786"]}, {"input": "400 30 81\r\n193 1000\r\n338 1\r\n", "output": ["51000"]}, {"input": "500 397 440\r\n202 1000\r\n75 1\r\n", "output": ["43000"]}, {"input": "600 443 587\r\n260 1000\r\n548 -1\r\n", "output": ["144000"]}, {"input": "799 254 294\r\n539 1000\r\n284 -1\r\n", "output": ["40000"]}, {"input": "801 489 351\r\n86 702\r\n125 1\r\n", "output": ["96836"]}, {"input": "999 951 297\r\n62 106\r\n574 1\r\n", "output": ["69324"]}, {"input": "1000 711 437\r\n42 126\r\n745 1\r\n", "output": ["34356"]}, {"input": "1000 812 761\r\n230 1000\r\n696 -1\r\n", "output": ["51000"]}, {"input": "1000 913 474\r\n34 162\r\n566 -1\r\n", "output": ["71118"]}, {"input": "1000 394 798\r\n155 673\r\n954 -1\r\n", "output": ["271560"]}, {"input": "1000 876 884\r\n299 1000\r\n825 1\r\n", "output": ["8000"]}, {"input": "2 0 2\r\n1 1\r\n1 1\r\n", "output": ["2"]}, {"input": "5 4 2\r\n1 2\r\n3 1\r\n", "output": ["4"]}, {"input": "4 2 4\r\n3 4\r\n2 1\r\n", "output": ["6"]}, {"input": "200 10 100\r\n1 100\r\n20 1\r\n", "output": ["480"]}, {"input": "6 4 2\r\n1 2\r\n3 1\r\n", "output": ["4"]}, {"input": "3 1 3\r\n1 2\r\n1 1\r\n", "output": ["2"]}, {"input": "10 3 6\r\n1 2\r\n3 1\r\n", "output": ["3"]}, {"input": "1000 50 51\r\n1 3\r\n50 1\r\n", "output": ["1"]}, {"input": "100 1 2\r\n1 100\r\n1 1\r\n", "output": ["1"]}, {"input": "5 1 4\r\n1 100\r\n1 1\r\n", "output": ["3"]}, {"input": "10 0 5\r\n1 100\r\n7 1\r\n", "output": ["18"]}, {"input": "5 4 1\r\n1 100\r\n4 -1\r\n", "output": ["3"]}, {"input": "10 6 9\r\n3 100\r\n5 1\r\n", "output": ["12"]}, {"input": "50 10 30\r\n1 50\r\n10 1\r\n", "output": ["20"]}, {"input": "4 1 4\r\n1 100\r\n2 1\r\n", "output": ["10"]}, {"input": "10 5 9\r\n1 10\r\n5 1\r\n", "output": ["4"]}, {"input": "20 15 10\r\n5 2\r\n3 1\r\n", "output": ["10"]}, {"input": "2 2 0\r\n7 3\r\n1 1\r\n", "output": ["6"]}, {"input": "10 1 9\r\n1 10\r\n1 1\r\n", "output": ["8"]}, {"input": "1000 2 902\r\n1 1000\r\n2 1\r\n", "output": ["900"]}, {"input": "100 9 6\r\n3 100\r\n5 1\r\n", "output": ["300"]}, {"input": "10 1 6\r\n1 10\r\n3 -1\r\n", "output": ["9"]}, {"input": "1000 902 2\r\n1 1000\r\n902 -1\r\n", "output": ["900"]}, {"input": "100 50 25\r\n1 1000\r\n10 1\r\n", "output": ["165"]}, {"input": "5 3 0\r\n1 2\r\n4 -1\r\n", "output": ["4"]}, {"input": "4 1 2\r\n1 10\r\n3 1\r\n", "output": ["7"]}, {"input": "10 4 8\r\n1 5\r\n4 -1\r\n", "output": ["12"]}] | 100 | 100 | 100 | [{'input': '10 3 6\r\n1 2\r\n3 1\r\n', 'output': ['3']}, {'input': '100 9 6\r\n3 100\r\n5 1\r\n', 'output': ['300']}, {'input': '1000 876 884\r\n299 1000\r\n825 1\r\n', 'output': ['8000']}, {'input': '10 7 2\r\n7 9\r\n9 -1\r\n', 'output': ['45']}, {'input': '1000 812 761\r\n230 1000\r\n696 -1\r\n', 'output': ['51000']}] | [{'input': '10 0 5\r\n1 100\r\n7 1\r\n', 'output': ['18']}, {'input': '5 3 0\r\n1 2\r\n4 -1\r\n', 'output': ['4']}, {'input': '200 10 100\r\n1 100\r\n20 1\r\n', 'output': ['480']}, {'input': '20 15 10\r\n5 2\r\n3 1\r\n', 'output': ['10']}, {'input': '500 397 440\r\n202 1000\r\n75 1\r\n', 'output': ['43000']}] | [{'input': '5 4 0\r\n5 14\r\n1 -1\r\n', 'output': ['55']}, {'input': '2 2 0\r\n7 3\r\n1 1\r\n', 'output': ['6']}, {'input': '3 1 3\r\n1 2\r\n1 1\r\n', 'output': ['2']}, {'input': '500 397 440\r\n202 1000\r\n75 1\r\n', 'output': ['43000']}, {'input': '999 951 297\r\n62 106\r\n574 1\r\n', 'output': ['69324']}] | [{'input': '999 951 297\r\n62 106\r\n574 1\r\n', 'output': ['69324']}, {'input': '40 31 14\r\n628 1000\r\n36 1\r\n', 'output': ['17000']}, {'input': '600 443 587\r\n260 1000\r\n548 -1\r\n', 'output': ['144000']}, {'input': '100 20 83\r\n186 434\r\n64 -1\r\n', 'output': ['27342']}, {'input': '200 10 100\r\n1 100\r\n20 1\r\n', 'output': ['480']}] | [{'input': '5 4 0\r\n5 14\r\n1 -1\r\n', 'output': ['55']}, {'input': '10 1 9\r\n1 10\r\n1 1\r\n', 'output': ['8']}, {'input': '1000 711 437\r\n42 126\r\n745 1\r\n', 'output': ['34356']}, {'input': '5 3 0\r\n1 2\r\n4 -1\r\n', 'output': ['4']}, {'input': '100 9 6\r\n3 100\r\n5 1\r\n', 'output': ['300']}] | 100 | 100 | 100 | 100 | 100 | 83.33 | 100 | 100 | 83.33 | 88.89 | 56 | 74 | 56 | 60 | 78 | 16 | 100 | 91.11 | 64.8 |
["4\n1 3\n2 3\n1 4\n5 3", "5\n1 2\n2 3\n3 4\n4 5\n5 1"] | The first line contains an integer m (0ββ€βmββ€β10), which is the number of relations of acquaintances among the five friends of Igor's. Each of the following m lines contains two integers ai and bi (1ββ€βai,βbiββ€β5;aiββ βbi), where (ai,βbi) is a pair of acquainted people. It is guaranteed that each pair of the acquaintances is described exactly once. The acquaintance relation is symmetrical, i.e. if x is acquainted with y, then y is also acquainted with x. | 2bc18799c85ecaba87564a86a94e0322 | #include<stdio.h>
int main()
{
int i,j,k,a[100][100],n,x,y,flag=0;
scanf("%d",&n);
for(i=0;i<=5;i++)
for(j=0;j<=5;j++)
a[i][j]=0;
for(i=0;i<n;i++)
{
scanf("%d%d",&x,&y);
a[x][y]=1;
a[y][x]=1;
}
for(i=1;i<=5;i++)
for(j=i+1;j<=5;j++)
for(k=j+1;k<=5;k++)
{
if(a[i][j]==1 && a[i][k]==1 && a[j][k]==1) flag=1;
else if(a[i][j]!=1 && a[i][k]!=1 && a[j][k]!=1) flag=1;
}
if(flag==1) printf("WIN\n");
else printf("FAIL\n");
return 0;
}
| ["WIN", "FAIL"] | C | null | Print "FAIL", if among those five people there are no either three pairwise acquainted or three pairwise unacquainted people. Otherwise print "WIN". | One day Igor K. stopped programming and took up math. One late autumn evening he was sitting at a table reading a book and thinking about something. The following statement caught his attention: "Among any six people there are either three pairwise acquainted people or three pairwise unacquainted people"Igor just couldn't get why the required minimum is 6 people. "Well, that's the same for five people, too!" β he kept on repeating in his mind. β "Let's take, say, Max, Ilya, Vova β here, they all know each other! And now let's add Dima and Oleg to Vova β none of them is acquainted with each other! Now, that math is just rubbish!"Igor K. took 5 friends of his and wrote down who of them is friends with whom. Now he wants to check whether it is true for the five people that among them there are either three pairwise acquainted or three pairwise not acquainted people. | [{"input": "4\r\n1 3\r\n2 3\r\n1 4\r\n5 3\r\n", "output": ["WIN"]}, {"input": "5\r\n1 2\r\n2 3\r\n3 4\r\n4 5\r\n5 1\r\n", "output": ["FAIL"]}, {"input": "1\r\n4 3\r\n", "output": ["WIN"]}, {"input": "6\r\n1 3\r\n2 3\r\n1 2\r\n5 3\r\n4 2\r\n4 5\r\n", "output": ["WIN"]}, {"input": "2\r\n1 3\r\n2 5\r\n", "output": ["WIN"]}, {"input": "3\r\n5 3\r\n4 3\r\n4 5\r\n", "output": ["WIN"]}, {"input": "5\r\n1 3\r\n3 2\r\n2 4\r\n5 4\r\n1 5\r\n", "output": ["FAIL"]}, {"input": "7\r\n1 3\r\n5 1\r\n1 4\r\n2 1\r\n5 3\r\n4 5\r\n2 5\r\n", "output": ["WIN"]}, {"input": "5\r\n5 1\r\n4 1\r\n2 3\r\n4 5\r\n3 1\r\n", "output": ["WIN"]}, {"input": "0\r\n", "output": ["WIN"]}, {"input": "10\r\n1 2\r\n1 3\r\n1 4\r\n1 5\r\n2 3\r\n2 4\r\n2 5\r\n3 4\r\n3 5\r\n4 5\r\n", "output": ["WIN"]}, {"input": "4\r\n1 2\r\n2 3\r\n3 4\r\n4 1\r\n", "output": ["WIN"]}, {"input": "1\r\n3 5\r\n", "output": ["WIN"]}, {"input": "1\r\n5 4\r\n", "output": ["WIN"]}, {"input": "2\r\n5 3\r\n1 3\r\n", "output": ["WIN"]}, {"input": "2\r\n3 4\r\n1 4\r\n", "output": ["WIN"]}, {"input": "2\r\n3 1\r\n2 3\r\n", "output": ["WIN"]}, {"input": "2\r\n4 5\r\n5 3\r\n", "output": ["WIN"]}, {"input": "3\r\n2 4\r\n1 4\r\n4 5\r\n", "output": ["WIN"]}, {"input": "3\r\n5 1\r\n4 1\r\n3 4\r\n", "output": ["WIN"]}, {"input": "3\r\n1 3\r\n5 3\r\n4 5\r\n", "output": ["WIN"]}, {"input": "3\r\n4 1\r\n1 5\r\n2 5\r\n", "output": ["WIN"]}, {"input": "3\r\n2 1\r\n3 1\r\n4 3\r\n", "output": ["WIN"]}, {"input": "3\r\n5 1\r\n3 1\r\n1 2\r\n", "output": ["WIN"]}, {"input": "4\r\n4 1\r\n4 2\r\n4 5\r\n3 5\r\n", "output": ["WIN"]}, {"input": "4\r\n5 1\r\n4 2\r\n1 2\r\n3 4\r\n", "output": ["WIN"]}, {"input": "4\r\n4 5\r\n3 5\r\n1 2\r\n4 2\r\n", "output": ["WIN"]}, {"input": "4\r\n5 3\r\n2 5\r\n3 1\r\n1 2\r\n", "output": ["WIN"]}, {"input": "4\r\n3 4\r\n5 4\r\n2 4\r\n3 1\r\n", "output": ["WIN"]}, {"input": "4\r\n5 1\r\n3 2\r\n5 3\r\n2 5\r\n", "output": ["WIN"]}, {"input": "4\r\n2 5\r\n2 3\r\n3 5\r\n1 4\r\n", "output": ["WIN"]}, {"input": "4\r\n1 2\r\n5 2\r\n3 5\r\n1 5\r\n", "output": ["WIN"]}, {"input": "5\r\n2 4\r\n3 1\r\n4 5\r\n5 3\r\n1 2\r\n", "output": ["FAIL"]}, {"input": "5\r\n5 1\r\n3 5\r\n1 2\r\n2 4\r\n4 3\r\n", "output": ["FAIL"]}, {"input": "5\r\n1 2\r\n2 3\r\n5 1\r\n4 5\r\n3 4\r\n", "output": ["FAIL"]}, {"input": "5\r\n2 1\r\n4 3\r\n1 5\r\n5 4\r\n3 2\r\n", "output": ["FAIL"]}, {"input": "5\r\n3 2\r\n1 4\r\n4 5\r\n5 3\r\n2 1\r\n", "output": ["FAIL"]}, {"input": "5\r\n1 3\r\n4 2\r\n3 4\r\n2 5\r\n5 1\r\n", "output": ["FAIL"]}, {"input": "5\r\n1 2\r\n2 5\r\n5 4\r\n4 3\r\n3 1\r\n", "output": ["FAIL"]}, {"input": "5\r\n1 4\r\n4 2\r\n2 5\r\n3 1\r\n5 3\r\n", "output": ["FAIL"]}, {"input": "5\r\n3 5\r\n2 4\r\n1 3\r\n5 2\r\n4 1\r\n", "output": ["FAIL"]}, {"input": "5\r\n1 2\r\n4 3\r\n5 1\r\n3 5\r\n2 4\r\n", "output": ["FAIL"]}, {"input": "5\r\n1 4\r\n5 4\r\n5 1\r\n3 4\r\n3 5\r\n", "output": ["WIN"]}, {"input": "5\r\n1 5\r\n3 4\r\n1 4\r\n5 4\r\n4 2\r\n", "output": ["WIN"]}, {"input": "5\r\n2 3\r\n4 3\r\n1 3\r\n5 2\r\n5 1\r\n", "output": ["WIN"]}, {"input": "5\r\n3 5\r\n4 5\r\n3 1\r\n1 5\r\n2 4\r\n", "output": ["WIN"]}, {"input": "5\r\n5 4\r\n3 4\r\n4 1\r\n3 5\r\n3 2\r\n", "output": ["WIN"]}, {"input": "5\r\n3 2\r\n5 4\r\n2 1\r\n1 5\r\n3 1\r\n", "output": ["WIN"]}, {"input": "5\r\n4 5\r\n5 3\r\n2 3\r\n3 1\r\n5 1\r\n", "output": ["WIN"]}, {"input": "5\r\n2 4\r\n1 3\r\n5 3\r\n3 2\r\n4 3\r\n", "output": ["WIN"]}, {"input": "5\r\n3 5\r\n4 2\r\n1 4\r\n3 4\r\n5 2\r\n", "output": ["WIN"]}, {"input": "5\r\n1 3\r\n1 4\r\n2 1\r\n4 3\r\n1 5\r\n", "output": ["WIN"]}, {"input": "5\r\n4 2\r\n5 2\r\n2 3\r\n1 3\r\n4 1\r\n", "output": ["WIN"]}, {"input": "5\r\n3 2\r\n5 3\r\n2 5\r\n1 4\r\n3 4\r\n", "output": ["WIN"]}, {"input": "5\r\n2 5\r\n1 3\r\n4 3\r\n2 1\r\n2 3\r\n", "output": ["WIN"]}, {"input": "5\r\n1 4\r\n4 2\r\n1 3\r\n3 4\r\n1 2\r\n", "output": ["WIN"]}, {"input": "5\r\n4 1\r\n5 2\r\n3 1\r\n4 3\r\n3 5\r\n", "output": ["WIN"]}, {"input": "5\r\n4 1\r\n5 1\r\n2 3\r\n2 5\r\n1 2\r\n", "output": ["WIN"]}, {"input": "5\r\n3 2\r\n3 1\r\n2 5\r\n1 5\r\n4 3\r\n", "output": ["WIN"]}, {"input": "5\r\n5 1\r\n5 3\r\n3 2\r\n4 5\r\n3 4\r\n", "output": ["WIN"]}, {"input": "5\r\n1 5\r\n2 1\r\n5 2\r\n2 4\r\n4 3\r\n", "output": ["WIN"]}, {"input": "5\r\n2 3\r\n1 4\r\n3 5\r\n1 5\r\n5 4\r\n", "output": ["WIN"]}, {"input": "6\r\n5 4\r\n5 1\r\n3 1\r\n2 3\r\n3 5\r\n2 4\r\n", "output": ["WIN"]}, {"input": "6\r\n5 4\r\n1 4\r\n4 2\r\n3 2\r\n5 1\r\n3 1\r\n", "output": ["WIN"]}, {"input": "6\r\n1 4\r\n2 1\r\n5 2\r\n3 5\r\n3 2\r\n2 4\r\n", "output": ["WIN"]}, {"input": "6\r\n1 5\r\n4 2\r\n1 3\r\n4 5\r\n2 1\r\n1 4\r\n", "output": ["WIN"]}, {"input": "6\r\n3 1\r\n5 2\r\n1 2\r\n2 3\r\n3 4\r\n4 2\r\n", "output": ["WIN"]}, {"input": "6\r\n4 5\r\n3 4\r\n2 4\r\n1 3\r\n2 3\r\n4 1\r\n", "output": ["WIN"]}, {"input": "6\r\n5 1\r\n4 2\r\n2 1\r\n4 1\r\n3 4\r\n3 2\r\n", "output": ["WIN"]}, {"input": "6\r\n3 2\r\n2 1\r\n2 4\r\n2 5\r\n5 3\r\n1 4\r\n", "output": ["WIN"]}, {"input": "7\r\n4 2\r\n3 1\r\n4 5\r\n3 2\r\n5 2\r\n5 3\r\n1 5\r\n", "output": ["WIN"]}, {"input": "7\r\n3 1\r\n1 2\r\n4 1\r\n4 5\r\n4 2\r\n2 3\r\n1 5\r\n", "output": ["WIN"]}, {"input": "7\r\n1 5\r\n1 4\r\n5 4\r\n5 3\r\n1 2\r\n2 3\r\n5 2\r\n", "output": ["WIN"]}, {"input": "7\r\n2 3\r\n3 4\r\n2 5\r\n4 5\r\n5 3\r\n5 1\r\n2 4\r\n", "output": ["WIN"]}, {"input": "7\r\n2 3\r\n2 1\r\n4 5\r\n5 2\r\n3 4\r\n3 1\r\n4 1\r\n", "output": ["WIN"]}, {"input": "7\r\n2 5\r\n2 1\r\n3 5\r\n1 4\r\n3 4\r\n4 5\r\n4 2\r\n", "output": ["WIN"]}, {"input": "8\r\n5 1\r\n5 3\r\n4 5\r\n3 4\r\n2 4\r\n1 3\r\n2 5\r\n2 3\r\n", "output": ["WIN"]}, {"input": "8\r\n4 3\r\n1 5\r\n4 1\r\n2 4\r\n2 5\r\n5 3\r\n1 3\r\n4 5\r\n", "output": ["WIN"]}, {"input": "8\r\n3 2\r\n3 1\r\n4 1\r\n2 4\r\n3 5\r\n1 5\r\n3 4\r\n1 2\r\n", "output": ["WIN"]}, {"input": "8\r\n3 4\r\n4 2\r\n4 5\r\n2 3\r\n3 5\r\n2 1\r\n1 5\r\n3 1\r\n", "output": ["WIN"]}, {"input": "9\r\n3 2\r\n5 1\r\n5 2\r\n2 1\r\n1 4\r\n1 3\r\n2 4\r\n5 3\r\n5 4\r\n", "output": ["WIN"]}, {"input": "9\r\n2 4\r\n3 2\r\n2 5\r\n4 5\r\n3 5\r\n1 3\r\n5 1\r\n1 2\r\n4 3\r\n", "output": ["WIN"]}, {"input": "3\r\n3 4\r\n4 5\r\n5 3\r\n", "output": ["WIN"]}, {"input": "3\r\n1 2\r\n1 3\r\n4 5\r\n", "output": ["WIN"]}, {"input": "3\r\n2 3\r\n3 5\r\n2 5\r\n", "output": ["WIN"]}, {"input": "1\r\n2 1\r\n", "output": ["WIN"]}, {"input": "1\r\n2 5\r\n", "output": ["WIN"]}, {"input": "2\r\n2 1\r\n1 5\r\n", "output": ["WIN"]}, {"input": "2\r\n4 2\r\n1 5\r\n", "output": ["WIN"]}, {"input": "2\r\n3 4\r\n5 2\r\n", "output": ["WIN"]}, {"input": "2\r\n1 5\r\n4 3\r\n", "output": ["WIN"]}, {"input": "3\r\n4 1\r\n4 5\r\n2 1\r\n", "output": ["WIN"]}, {"input": "3\r\n5 1\r\n5 3\r\n2 5\r\n", "output": ["WIN"]}, {"input": "3\r\n1 2\r\n4 2\r\n1 3\r\n", "output": ["WIN"]}, {"input": "3\r\n3 2\r\n1 5\r\n5 3\r\n", "output": ["WIN"]}, {"input": "3\r\n1 2\r\n2 4\r\n3 2\r\n", "output": ["WIN"]}, {"input": "3\r\n2 1\r\n1 3\r\n5 4\r\n", "output": ["WIN"]}, {"input": "4\r\n4 2\r\n2 5\r\n1 4\r\n4 5\r\n", "output": ["WIN"]}, {"input": "4\r\n5 2\r\n2 4\r\n5 3\r\n1 5\r\n", "output": ["WIN"]}, {"input": "4\r\n2 5\r\n1 3\r\n4 3\r\n4 2\r\n", "output": ["WIN"]}, {"input": "4\r\n1 4\r\n3 1\r\n2 3\r\n1 2\r\n", "output": ["WIN"]}, {"input": "4\r\n5 4\r\n2 3\r\n1 5\r\n5 2\r\n", "output": ["WIN"]}, {"input": "4\r\n2 5\r\n5 4\r\n1 4\r\n5 3\r\n", "output": ["WIN"]}, {"input": "4\r\n2 1\r\n2 4\r\n5 1\r\n4 1\r\n", "output": ["WIN"]}, {"input": "4\r\n1 2\r\n1 5\r\n4 5\r\n2 3\r\n", "output": ["WIN"]}, {"input": "5\r\n4 1\r\n2 4\r\n3 2\r\n5 3\r\n1 5\r\n", "output": ["FAIL"]}, {"input": "5\r\n1 3\r\n4 1\r\n5 2\r\n2 4\r\n3 5\r\n", "output": ["FAIL"]}, {"input": "5\r\n3 5\r\n4 2\r\n1 3\r\n2 1\r\n5 4\r\n", "output": ["FAIL"]}, {"input": "5\r\n5 2\r\n1 3\r\n4 5\r\n2 1\r\n3 4\r\n", "output": ["FAIL"]}, {"input": "5\r\n2 3\r\n3 5\r\n1 2\r\n4 1\r\n5 4\r\n", "output": ["FAIL"]}, {"input": "5\r\n1 2\r\n4 5\r\n5 3\r\n3 1\r\n2 4\r\n", "output": ["FAIL"]}, {"input": "5\r\n5 3\r\n3 2\r\n2 4\r\n1 5\r\n4 1\r\n", "output": ["FAIL"]}, {"input": "5\r\n3 2\r\n4 1\r\n2 5\r\n1 3\r\n5 4\r\n", "output": ["FAIL"]}, {"input": "5\r\n3 5\r\n1 4\r\n5 1\r\n2 3\r\n4 2\r\n", "output": ["FAIL"]}, {"input": "5\r\n4 2\r\n5 3\r\n2 1\r\n3 4\r\n1 5\r\n", "output": ["FAIL"]}, {"input": "5\r\n3 1\r\n5 1\r\n4 5\r\n2 4\r\n5 3\r\n", "output": ["WIN"]}, {"input": "5\r\n5 4\r\n5 3\r\n3 1\r\n1 4\r\n2 3\r\n", "output": ["WIN"]}, {"input": "5\r\n4 1\r\n3 5\r\n3 4\r\n5 4\r\n5 2\r\n", "output": ["WIN"]}, {"input": "5\r\n4 1\r\n5 2\r\n3 1\r\n4 2\r\n5 1\r\n", "output": ["WIN"]}, {"input": "5\r\n2 3\r\n1 5\r\n5 3\r\n2 4\r\n1 4\r\n", "output": ["FAIL"]}, {"input": "5\r\n5 4\r\n5 3\r\n2 3\r\n5 2\r\n5 1\r\n", "output": ["WIN"]}, {"input": "5\r\n2 4\r\n3 4\r\n1 4\r\n2 1\r\n3 2\r\n", "output": ["WIN"]}, {"input": "5\r\n2 3\r\n3 4\r\n1 3\r\n4 1\r\n5 2\r\n", "output": ["WIN"]}, {"input": "5\r\n1 2\r\n2 5\r\n4 2\r\n4 3\r\n3 1\r\n", "output": ["WIN"]}, {"input": "5\r\n2 1\r\n2 5\r\n4 5\r\n2 3\r\n3 5\r\n", "output": ["WIN"]}, {"input": "5\r\n4 1\r\n5 1\r\n5 4\r\n4 3\r\n5 2\r\n", "output": ["WIN"]}, {"input": "5\r\n1 3\r\n2 4\r\n1 5\r\n5 2\r\n4 1\r\n", "output": ["WIN"]}, {"input": "5\r\n1 5\r\n3 5\r\n2 3\r\n4 1\r\n3 1\r\n", "output": ["WIN"]}, {"input": "5\r\n5 2\r\n3 2\r\n2 1\r\n4 3\r\n4 2\r\n", "output": ["WIN"]}, {"input": "5\r\n1 3\r\n4 5\r\n3 4\r\n3 5\r\n5 1\r\n", "output": ["WIN"]}, {"input": "5\r\n4 5\r\n2 5\r\n5 3\r\n4 2\r\n4 1\r\n", "output": ["WIN"]}, {"input": "5\r\n2 5\r\n1 5\r\n1 3\r\n3 5\r\n1 2\r\n", "output": ["WIN"]}, {"input": "5\r\n2 4\r\n1 2\r\n5 2\r\n5 3\r\n4 5\r\n", "output": ["WIN"]}, {"input": "5\r\n2 1\r\n4 5\r\n5 3\r\n1 5\r\n1 4\r\n", "output": ["WIN"]}, {"input": "5\r\n1 3\r\n2 5\r\n4 2\r\n3 4\r\n4 1\r\n", "output": ["WIN"]}, {"input": "6\r\n3 2\r\n2 4\r\n3 1\r\n3 5\r\n5 2\r\n1 2\r\n", "output": ["WIN"]}, {"input": "6\r\n2 1\r\n5 1\r\n5 4\r\n3 5\r\n3 4\r\n4 1\r\n", "output": ["WIN"]}, {"input": "6\r\n3 1\r\n1 4\r\n5 4\r\n2 1\r\n4 2\r\n1 5\r\n", "output": ["WIN"]}, {"input": "6\r\n5 1\r\n5 4\r\n3 4\r\n1 3\r\n1 4\r\n4 2\r\n", "output": ["WIN"]}, {"input": "6\r\n1 3\r\n5 4\r\n4 2\r\n2 1\r\n4 1\r\n2 3\r\n", "output": ["WIN"]}, {"input": "6\r\n4 3\r\n5 3\r\n4 1\r\n1 3\r\n1 2\r\n2 4\r\n", "output": ["WIN"]}, {"input": "6\r\n4 1\r\n3 5\r\n4 5\r\n3 1\r\n4 3\r\n5 2\r\n", "output": ["WIN"]}, {"input": "6\r\n2 1\r\n1 4\r\n4 5\r\n5 2\r\n1 3\r\n3 2\r\n", "output": ["WIN"]}, {"input": "7\r\n5 1\r\n3 5\r\n2 5\r\n4 5\r\n2 3\r\n3 1\r\n4 3\r\n", "output": ["WIN"]}, {"input": "7\r\n5 3\r\n5 1\r\n4 2\r\n4 5\r\n3 2\r\n3 4\r\n1 3\r\n", "output": ["WIN"]}, {"input": "7\r\n3 5\r\n1 4\r\n5 2\r\n1 5\r\n1 3\r\n4 2\r\n4 3\r\n", "output": ["WIN"]}, {"input": "7\r\n5 1\r\n5 4\r\n2 4\r\n2 3\r\n3 5\r\n2 5\r\n4 1\r\n", "output": ["WIN"]}, {"input": "7\r\n1 3\r\n2 5\r\n4 3\r\n2 1\r\n2 3\r\n4 5\r\n2 4\r\n", "output": ["WIN"]}, {"input": "7\r\n3 1\r\n4 5\r\n3 5\r\n5 1\r\n2 4\r\n1 2\r\n1 4\r\n", "output": ["WIN"]}, {"input": "8\r\n1 5\r\n3 1\r\n2 5\r\n4 2\r\n2 1\r\n4 5\r\n4 3\r\n4 1\r\n", "output": ["WIN"]}, {"input": "8\r\n4 2\r\n3 1\r\n4 3\r\n2 5\r\n3 2\r\n4 5\r\n1 2\r\n3 5\r\n", "output": ["WIN"]}, {"input": "8\r\n2 4\r\n3 2\r\n2 5\r\n3 4\r\n3 1\r\n5 1\r\n4 5\r\n5 3\r\n", "output": ["WIN"]}, {"input": "8\r\n2 3\r\n1 5\r\n1 3\r\n4 5\r\n2 4\r\n1 4\r\n3 5\r\n3 4\r\n", "output": ["WIN"]}, {"input": "9\r\n3 5\r\n3 2\r\n1 5\r\n4 3\r\n5 4\r\n1 4\r\n1 3\r\n4 2\r\n5 2\r\n", "output": ["WIN"]}, {"input": "9\r\n3 5\r\n2 5\r\n5 1\r\n4 5\r\n1 3\r\n3 2\r\n1 4\r\n4 3\r\n4 2\r\n", "output": ["WIN"]}] | 100 | 100 | 100 | [{'input': '7\r\n2 3\r\n2 1\r\n4 5\r\n5 2\r\n3 4\r\n3 1\r\n4 1\r\n', 'output': ['WIN']}, {'input': '4\r\n1 2\r\n5 2\r\n3 5\r\n1 5\r\n', 'output': ['WIN']}, {'input': '9\r\n3 2\r\n5 1\r\n5 2\r\n2 1\r\n1 4\r\n1 3\r\n2 4\r\n5 3\r\n5 4\r\n', 'output': ['WIN']}, {'input': '4\r\n4 2\r\n2 5\r\n1 4\r\n4 5\r\n', 'output': ['WIN']}, {'input': '6\r\n3 1\r\n5 2\r\n1 2\r\n2 3\r\n3 4\r\n4 2\r\n', 'output': ['WIN']}] | [{'input': '5\r\n1 2\r\n2 5\r\n5 4\r\n4 3\r\n3 1\r\n', 'output': ['FAIL']}, {'input': '1\r\n4 3\r\n', 'output': ['WIN']}, {'input': '5\r\n1 2\r\n2 5\r\n4 2\r\n4 3\r\n3 1\r\n', 'output': ['WIN']}, {'input': '3\r\n5 1\r\n5 3\r\n2 5\r\n', 'output': ['WIN']}, {'input': '6\r\n4 3\r\n5 3\r\n4 1\r\n1 3\r\n1 2\r\n2 4\r\n', 'output': ['WIN']}] | [{'input': '9\r\n2 4\r\n3 2\r\n2 5\r\n4 5\r\n3 5\r\n1 3\r\n5 1\r\n1 2\r\n4 3\r\n', 'output': ['WIN']}, {'input': '7\r\n3 1\r\n4 5\r\n3 5\r\n5 1\r\n2 4\r\n1 2\r\n1 4\r\n', 'output': ['WIN']}, {'input': '8\r\n1 5\r\n3 1\r\n2 5\r\n4 2\r\n2 1\r\n4 5\r\n4 3\r\n4 1\r\n', 'output': ['WIN']}, {'input': '5\r\n3 5\r\n4 2\r\n1 3\r\n2 1\r\n5 4\r\n', 'output': ['FAIL']}, {'input': '0\r\n', 'output': ['WIN']}] | [{'input': '5\r\n3 5\r\n4 2\r\n1 4\r\n3 4\r\n5 2\r\n', 'output': ['WIN']}, {'input': '6\r\n5 1\r\n5 4\r\n3 4\r\n1 3\r\n1 4\r\n4 2\r\n', 'output': ['WIN']}, {'input': '3\r\n5 1\r\n3 1\r\n1 2\r\n', 'output': ['WIN']}, {'input': '4\r\n5 4\r\n2 3\r\n1 5\r\n5 2\r\n', 'output': ['WIN']}, {'input': '4\r\n5 2\r\n2 4\r\n5 3\r\n1 5\r\n', 'output': ['WIN']}] | [{'input': '5\r\n1 4\r\n4 2\r\n2 5\r\n3 1\r\n5 3\r\n', 'output': ['FAIL']}, {'input': '6\r\n3 1\r\n1 4\r\n5 4\r\n2 1\r\n4 2\r\n1 5\r\n', 'output': ['WIN']}, {'input': '5\r\n3 5\r\n1 4\r\n5 1\r\n2 3\r\n4 2\r\n', 'output': ['FAIL']}, {'input': '5\r\n2 3\r\n1 4\r\n3 5\r\n1 5\r\n5 4\r\n', 'output': ['WIN']}, {'input': '5\r\n4 1\r\n2 4\r\n3 2\r\n5 3\r\n1 5\r\n', 'output': ['FAIL']}] | 100 | 100 | 100 | 100 | 100 | 94.44 | 100 | 100 | 94.44 | 100 | 96.15 | 100 | 100 | 96.15 | 100 | 17 | 100 | 97.776 | 98.46 |
["100\n15 20 20 15 10 30 45", "2\n1 0 0 0 0 0 0"] | The first input line contains the single integer n (1ββ€βnββ€β1000) β the number of pages in the book. The second line contains seven non-negative space-separated integers that do not exceed 1000 β those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero. | 007a779d966e2e9219789d6d9da7002c | #include<stdio.h>
int main()
{
int i,j,t,a,b,page, sum =0;
int day[8];
scanf ("%d",&page);
for(i=1; i<8; i++){
scanf("%d", &day[i]);
}
j = 0;
while(1){
j++;
sum = sum + day[j];
if(sum >= page){
printf("%d\n", j);
break;
}
else if(j==7){
j = 0;
}
}
}
| ["6", "1"] | C | NoteNote to the first sample:By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).Note to the second sample:On Monday of the first week Petr will read the first page. On Monday of the second week Petr will read the second page and will finish reading the book. | Print a single number β the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday. | One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book. | [{"input": "100\r\n15 20 20 15 10 30 45\r\n", "output": ["6"]}, {"input": "2\r\n1 0 0 0 0 0 0\r\n", "output": ["1"]}, {"input": "100\r\n100 200 100 200 300 400 500\r\n", "output": ["1"]}, {"input": "3\r\n1 1 1 1 1 1 1\r\n", "output": ["3"]}, {"input": "1\r\n1 1 1 1 1 1 1\r\n", "output": ["1"]}, {"input": "20\r\n5 3 7 2 1 6 4\r\n", "output": ["6"]}, {"input": "10\r\n5 1 1 1 1 1 5\r\n", "output": ["6"]}, {"input": "50\r\n10 1 10 1 10 1 10\r\n", "output": ["1"]}, {"input": "77\r\n11 11 11 11 11 11 10\r\n", "output": ["1"]}, {"input": "1\r\n1000 1000 1000 1000 1000 1000 1000\r\n", "output": ["1"]}, {"input": "1000\r\n100 100 100 100 100 100 100\r\n", "output": ["3"]}, {"input": "999\r\n10 20 10 20 30 20 10\r\n", "output": ["3"]}, {"input": "433\r\n109 58 77 10 39 125 15\r\n", "output": ["7"]}, {"input": "1\r\n0 0 0 0 0 0 1\r\n", "output": ["7"]}, {"input": "5\r\n1 0 1 0 1 0 1\r\n", "output": ["1"]}, {"input": "997\r\n1 1 0 0 1 0 1\r\n", "output": ["1"]}, {"input": "1000\r\n1 1 1 1 1 1 1\r\n", "output": ["6"]}, {"input": "1000\r\n1000 1000 1000 1000 1000 1000 1000\r\n", "output": ["1"]}, {"input": "1000\r\n1 0 0 0 0 0 0\r\n", "output": ["1"]}, {"input": "1000\r\n0 0 0 0 0 0 1\r\n", "output": ["7"]}, {"input": "1000\r\n1 0 0 1 0 0 1\r\n", "output": ["1"]}, {"input": "509\r\n105 23 98 0 7 0 155\r\n", "output": ["2"]}, {"input": "7\r\n1 1 1 1 1 1 1\r\n", "output": ["7"]}, {"input": "2\r\n1 1 0 0 0 0 0\r\n", "output": ["2"]}, {"input": "1\r\n0 0 0 0 0 1 0\r\n", "output": ["6"]}, {"input": "10\r\n0 0 0 0 0 0 1\r\n", "output": ["7"]}, {"input": "5\r\n0 0 0 0 0 6 0\r\n", "output": ["6"]}, {"input": "3\r\n0 1 0 0 0 0 0\r\n", "output": ["2"]}, {"input": "10\r\n0 0 0 0 0 0 10\r\n", "output": ["7"]}, {"input": "28\r\n1 2 3 4 5 6 7\r\n", "output": ["7"]}, {"input": "100\r\n5 5 5 5 5 5 5\r\n", "output": ["6"]}, {"input": "4\r\n1 0 0 0 0 0 1\r\n", "output": ["7"]}, {"input": "2\r\n0 0 0 0 0 0 1\r\n", "output": ["7"]}, {"input": "7\r\n0 0 0 0 0 0 7\r\n", "output": ["7"]}, {"input": "7\r\n2 1 1 1 1 1 0\r\n", "output": ["6"]}, {"input": "2\r\n0 0 1 1 0 0 0\r\n", "output": ["4"]}, {"input": "6\r\n1 1 1 1 1 1 0\r\n", "output": ["6"]}, {"input": "5\r\n1 1 1 0 0 1 1\r\n", "output": ["7"]}, {"input": "100\r\n10 20 30 10 10 10 10\r\n", "output": ["7"]}, {"input": "1\r\n0 0 0 1 0 0 0\r\n", "output": ["4"]}, {"input": "70\r\n10 10 10 10 10 10 10\r\n", "output": ["7"]}, {"input": "22\r\n1 2 3 4 5 6 10\r\n", "output": ["7"]}, {"input": "5\r\n0 0 0 1 0 0 0\r\n", "output": ["4"]}, {"input": "2\r\n0 0 0 1 0 0 0\r\n", "output": ["4"]}, {"input": "6\r\n1 0 0 0 0 0 2\r\n", "output": ["7"]}, {"input": "10\r\n1 2 2 1 2 1 1\r\n", "output": ["7"]}, {"input": "5\r\n0 0 0 0 0 0 10\r\n", "output": ["7"]}, {"input": "4\r\n0 1 1 0 0 0 0\r\n", "output": ["3"]}, {"input": "100\r\n0 0 0 0 0 1 0\r\n", "output": ["6"]}] | 100 | 100 | 100 | [{'input': '3\r\n0 1 0 0 0 0 0\r\n', 'output': ['2']}, {'input': '997\r\n1 1 0 0 1 0 1\r\n', 'output': ['1']}, {'input': '3\r\n1 1 1 1 1 1 1\r\n', 'output': ['3']}, {'input': '4\r\n0 1 1 0 0 0 0\r\n', 'output': ['3']}, {'input': '5\r\n1 0 1 0 1 0 1\r\n', 'output': ['1']}] | [{'input': '5\r\n0 0 0 0 0 0 10\r\n', 'output': ['7']}, {'input': '28\r\n1 2 3 4 5 6 7\r\n', 'output': ['7']}, {'input': '5\r\n1 1 1 0 0 1 1\r\n', 'output': ['7']}, {'input': '1\r\n1000 1000 1000 1000 1000 1000 1000\r\n', 'output': ['1']}, {'input': '10\r\n0 0 0 0 0 0 10\r\n', 'output': ['7']}] | [{'input': '5\r\n0 0 0 1 0 0 0\r\n', 'output': ['4']}, {'input': '6\r\n1 1 1 1 1 1 0\r\n', 'output': ['6']}, {'input': '2\r\n0 0 0 0 0 0 1\r\n', 'output': ['7']}, {'input': '70\r\n10 10 10 10 10 10 10\r\n', 'output': ['7']}, {'input': '1000\r\n1 1 1 1 1 1 1\r\n', 'output': ['6']}] | [{'input': '4\r\n1 0 0 0 0 0 1\r\n', 'output': ['7']}, {'input': '2\r\n0 0 1 1 0 0 0\r\n', 'output': ['4']}, {'input': '433\r\n109 58 77 10 39 125 15\r\n', 'output': ['7']}, {'input': '7\r\n1 1 1 1 1 1 1\r\n', 'output': ['7']}, {'input': '2\r\n1 0 0 0 0 0 0\r\n', 'output': ['1']}] | [{'input': '999\r\n10 20 10 20 30 20 10\r\n', 'output': ['3']}, {'input': '10\r\n0 0 0 0 0 0 1\r\n', 'output': ['7']}, {'input': '3\r\n0 1 0 0 0 0 0\r\n', 'output': ['2']}, {'input': '433\r\n109 58 77 10 39 125 15\r\n', 'output': ['7']}, {'input': '1000\r\n0 0 0 0 0 0 1\r\n', 'output': ['7']}] | 100 | 100 | 100 | 100 | 100 | 100 | 92.31 | 100 | 100 | 100 | 100 | 83.33 | 100 | 100 | 100 | 18 | 100 | 98.462 | 96.666 |
["2 2", "9 3"] | The single line contains two integers n and m (1ββ€βnββ€β100;Β 2ββ€βmββ€β100), separated by a space. | 42b25b7335ec01794fbb1d4086aa9dd0 | #include<stdio.h>
int main()
{
int n,m,sum,d;
scanf("%d %d",&n,&m);
sum=n;
rich:
d=n/m;
if(d>0)
{
sum=sum+d;
if(((n%m)+d)>=m)
{
n=(n%m)+d;
goto rich;
}
}
printf("%d",sum);
return 0;
}
| ["3", "13"] | C | NoteIn the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two.In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day. | Print a single integer β the answer to the problem. | Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m,β2m,β3m,β...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks? | [{"input": "2 2\r\n", "output": ["3"]}, {"input": "9 3\r\n", "output": ["13"]}, {"input": "1 2\r\n", "output": ["1"]}, {"input": "2 3\r\n", "output": ["2"]}, {"input": "1 99\r\n", "output": ["1"]}, {"input": "4 4\r\n", "output": ["5"]}, {"input": "10 2\r\n", "output": ["19"]}, {"input": "10 9\r\n", "output": ["11"]}, {"input": "100 100\r\n", "output": ["101"]}, {"input": "2 27\r\n", "output": ["2"]}, {"input": "99 100\r\n", "output": ["99"]}, {"input": "99 2\r\n", "output": ["197"]}, {"input": "100 3\r\n", "output": ["149"]}, {"input": "98 3\r\n", "output": ["146"]}, {"input": "100 2\r\n", "output": ["199"]}, {"input": "62 4\r\n", "output": ["82"]}, {"input": "99 10\r\n", "output": ["109"]}, {"input": "100 5\r\n", "output": ["124"]}, {"input": "80 80\r\n", "output": ["81"]}, {"input": "95 16\r\n", "output": ["101"]}, {"input": "75 16\r\n", "output": ["79"]}, {"input": "99 74\r\n", "output": ["100"]}, {"input": "20 21\r\n", "output": ["20"]}, {"input": "52 96\r\n", "output": ["52"]}, {"input": "24 5\r\n", "output": ["29"]}] | 100 | 100 | 100 | [{'input': '98 3\r\n', 'output': ['146']}, {'input': '62 4\r\n', 'output': ['82']}, {'input': '1 99\r\n', 'output': ['1']}, {'input': '99 100\r\n', 'output': ['99']}, {'input': '2 3\r\n', 'output': ['2']}] | [{'input': '99 2\r\n', 'output': ['197']}, {'input': '99 74\r\n', 'output': ['100']}, {'input': '2 2\r\n', 'output': ['3']}, {'input': '2 3\r\n', 'output': ['2']}, {'input': '100 2\r\n', 'output': ['199']}] | [{'input': '20 21\r\n', 'output': ['20']}, {'input': '99 10\r\n', 'output': ['109']}, {'input': '99 74\r\n', 'output': ['100']}, {'input': '10 2\r\n', 'output': ['19']}, {'input': '100 3\r\n', 'output': ['149']}] | [{'input': '62 4\r\n', 'output': ['82']}, {'input': '98 3\r\n', 'output': ['146']}, {'input': '1 2\r\n', 'output': ['1']}, {'input': '99 74\r\n', 'output': ['100']}, {'input': '100 100\r\n', 'output': ['101']}] | [{'input': '2 3\r\n', 'output': ['2']}, {'input': '100 2\r\n', 'output': ['199']}, {'input': '2 27\r\n', 'output': ['2']}, {'input': '75 16\r\n', 'output': ['79']}, {'input': '100 100\r\n', 'output': ['101']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 19 | 100 | 100 | 100 |
["0 1 1\n1 0 1\n1 1 0", "0 3 6\n5 0 5\n4 7 0"] | The first three lines of the input contain the Little Elephant's notes. The first line contains elements of the first row of the magic square. The second line contains the elements of the second row, the third line is for the third row. The main diagonal elements that have been forgotten by the Elephant are represented by zeroes. It is guaranteed that the notes contain exactly three zeroes and they are all located on the main diagonal. It is guaranteed that all positive numbers in the table do not exceed 105. | 0c42eafb73d1e30f168958a06a0f9bca | #include<stdio.h>
int main()
{
int x,y,z,i,j;
int a[3][3];
for(i=0;i<=2;i++)
for(j=0;j<=2;j++)
scanf("%d",&a[i][j]);
y=(a[2][0]+a[2][1]+a[0][1]+a[0][2]-a[1][0]-a[1][2])/2;
x=a[2][0]+a[2][1]-y;
z=a[1][0]+a[1][2]-x;
a[0][0]=x;
a[1][1]=y;
a[2][2]=z;
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
printf("%d ",a[i][j]);
printf("\n");
}
return 0;
} | ["1 1 1\n1 1 1\n1 1 1", "6 3 6\n5 5 5\n4 7 4"] | C | null | Print three lines, in each line print three integers β the Little Elephant's magic square. If there are multiple magic squares, you are allowed to print any of them. Note that all numbers you print must be positive and not exceed 105. It is guaranteed that there exists at least one magic square that meets the conditions. | Little Elephant loves magic squares very much.A magic square is a 3βΓβ3 table, each cell contains some positive integer. At that the sums of integers in all rows, columns and diagonals of the table are equal. The figure below shows the magic square, the sum of integers in all its rows, columns and diagonals equals 15. The Little Elephant remembered one magic square. He started writing this square on a piece of paper, but as he wrote, he forgot all three elements of the main diagonal of the magic square. Fortunately, the Little Elephant clearly remembered that all elements of the magic square did not exceed 105. Help the Little Elephant, restore the original magic square, given the Elephant's notes. | [{"input": "0 1 1\r\n1 0 1\r\n1 1 0\r\n", "output": ["1 1 1 \r\n1 1 1 \r\n1 1 1", "1 1 1\r\n 1 1 1\r\n 1 1 1", "1 1 1\r\n1 1 1\r\n1 1 1"]}, {"input": "0 3 6\r\n5 0 5\r\n4 7 0\r\n", "output": ["6 3 6\r\n 5 5 5\r\n 4 7 4", "6 3 6\r\n5 5 5\r\n4 7 4", "6 3 6 \r\n5 5 5 \r\n4 7 4"]}, {"input": "0 4 4\r\n4 0 4\r\n4 4 0\r\n", "output": ["4 4 4\r\n 4 4 4\r\n 4 4 4", "4 4 4 \r\n4 4 4 \r\n4 4 4", "4 4 4\r\n4 4 4\r\n4 4 4"]}, {"input": "0 54 48\r\n36 0 78\r\n66 60 0\r\n", "output": ["69 54 48 \r\n36 57 78 \r\n66 60 45", "69 54 48\r\n36 57 78\r\n66 60 45", "69 54 48\r\n 36 57 78\r\n 66 60 45"]}, {"input": "0 17 14\r\n15 0 15\r\n16 13 0\r\n", "output": ["14 17 14\r\n 15 15 15\r\n 16 13 16", "14 17 14\r\n15 15 15\r\n16 13 16", "14 17 14 \r\n15 15 15 \r\n16 13 16"]}, {"input": "0 97 56\r\n69 0 71\r\n84 43 0\r\n", "output": ["57 97 56\r\n69 70 71\r\n84 43 83", "57 97 56\r\n 69 70 71\r\n 84 43 83", "57 97 56 \r\n69 70 71 \r\n84 43 83"]}, {"input": "0 1099 1002\r\n1027 0 1049\r\n1074 977 0\r\n", "output": ["1013 1099 1002 \r\n1027 1038 1049 \r\n1074 977 1063", "1013 1099 1002\r\n1027 1038 1049\r\n1074 977 1063", "1013 1099 1002\r\n 1027 1038 1049\r\n 1074 977 1063"]}, {"input": "0 98721 99776\r\n99575 0 99123\r\n98922 99977 0\r\n", "output": ["99550 98721 99776\r\n99575 99349 99123\r\n98922 99977 99148", "99550 98721 99776\r\n 99575 99349 99123\r\n 98922 99977 99148", "99550 98721 99776 \r\n99575 99349 99123 \r\n98922 99977 99148"]}, {"input": "0 6361 2304\r\n1433 0 8103\r\n7232 3175 0\r\n", "output": ["5639 6361 2304 \r\n1433 4768 8103 \r\n7232 3175 3897", "5639 6361 2304\r\n1433 4768 8103\r\n7232 3175 3897", "5639 6361 2304\r\n 1433 4768 8103\r\n 7232 3175 3897"]}, {"input": "0 99626 99582\r\n99766 0 99258\r\n99442 99398 0\r\n", "output": ["99328 99626 99582 \r\n99766 99512 99258 \r\n99442 99398 99696", "99328 99626 99582\r\n99766 99512 99258\r\n99442 99398 99696", "99328 99626 99582\r\n 99766 99512 99258\r\n 99442 99398 99696"]}, {"input": "0 99978 99920\r\n99950 0 99918\r\n99948 99890 0\r\n", "output": ["99904 99978 99920\r\n99950 99934 99918\r\n99948 99890 99964", "99904 99978 99920\r\n 99950 99934 99918\r\n 99948 99890 99964", "99904 99978 99920 \r\n99950 99934 99918 \r\n99948 99890 99964"]}, {"input": "0 840 666\r\n612 0 948\r\n894 720 0\r\n", "output": ["834 840 666\r\n612 780 948\r\n894 720 726", "834 840 666\r\n 612 780 948\r\n 894 720 726", "834 840 666 \r\n612 780 948 \r\n894 720 726"]}, {"input": "0 28 10\r\n12 0 24\r\n26 8 0\r\n", "output": ["16 28 10 \r\n12 18 24 \r\n26 8 20", "16 28 10\r\n12 18 24\r\n26 8 20", "16 28 10\r\n 12 18 24\r\n 26 8 20"]}, {"input": "0 120 83\r\n98 0 90\r\n105 68 0\r\n", "output": ["79 120 83\r\n98 94 90\r\n105 68 109", "79 120 83\r\n 98 94 90\r\n 105 68 109", "79 120 83 \r\n98 94 90 \r\n105 68 109"]}, {"input": "0 86900 85807\r\n85836 0 86842\r\n86871 85778 0\r\n", "output": ["86310 86900 85807\r\n 85836 86339 86842\r\n 86871 85778 86368", "86310 86900 85807\r\n85836 86339 86842\r\n86871 85778 86368", "86310 86900 85807 \r\n85836 86339 86842 \r\n86871 85778 86368"]}, {"input": "0 74 78\r\n78 0 74\r\n74 78 0\r\n", "output": ["76 74 78 \r\n78 76 74 \r\n74 78 76", "76 74 78\r\n 78 76 74\r\n 74 78 76", "76 74 78\r\n78 76 74\r\n74 78 76"]}, {"input": "0 505 681\r\n605 0 657\r\n581 757 0\r\n", "output": ["707 505 681 \r\n605 631 657 \r\n581 757 555", "707 505 681\r\n 605 631 657\r\n 581 757 555", "707 505 681\r\n605 631 657\r\n581 757 555"]}, {"input": "0 662 918\r\n822 0 854\r\n758 1014 0\r\n", "output": ["934 662 918 \r\n822 838 854 \r\n758 1014 742", "934 662 918\r\n 822 838 854\r\n 758 1014 742", "934 662 918\r\n822 838 854\r\n758 1014 742"]}, {"input": "0 93 95\r\n93 0 97\r\n95 97 0\r\n", "output": ["97 93 95\r\n93 95 97\r\n95 97 93", "97 93 95 \r\n93 95 97 \r\n95 97 93", "97 93 95\r\n 93 95 97\r\n 95 97 93"]}, {"input": "0 709 712\r\n719 0 695\r\n702 705 0\r\n", "output": ["700 709 712\r\n 719 707 695\r\n 702 705 714", "700 709 712\r\n719 707 695\r\n702 705 714", "700 709 712 \r\n719 707 695 \r\n702 705 714"]}, {"input": "0 7 6\r\n9 0 1\r\n4 3 0\r\n", "output": ["2 7 6\r\n9 5 1\r\n4 3 8", "2 7 6 \r\n9 5 1 \r\n4 3 8", "2 7 6\r\n 9 5 1\r\n 4 3 8"]}, {"input": "0 9 2\r\n3 0 7\r\n8 1 0\r\n", "output": ["4 9 2 \r\n3 5 7 \r\n8 1 6", "4 9 2\r\n3 5 7\r\n8 1 6", "4 9 2\r\n 3 5 7\r\n 8 1 6"]}, {"input": "0 1 43\r\n13 0 61\r\n31 73 0\r\n", "output": ["67 1 43\r\n 13 37 61\r\n 31 73 7", "67 1 43\r\n13 37 61\r\n31 73 7", "67 1 43 \r\n13 37 61 \r\n31 73 7"]}, {"input": "0 100000 100000\r\n100000 0 100000\r\n100000 100000 0\r\n", "output": ["100000 100000 100000 \r\n100000 100000 100000 \r\n100000 100000 100000", "100000 100000 100000\r\n100000 100000 100000\r\n100000 100000 100000", "100000 100000 100000\r\n 100000 100000 100000\r\n 100000 100000 100000"]}] | 100 | 100 | 100 | [{'input': '0 9 2\r\n3 0 7\r\n8 1 0\r\n', 'output': ['4 9 2 \r\n3 5 7 \r\n8 1 6', '4 9 2\r\n3 5 7\r\n8 1 6', '4 9 2\r\n 3 5 7\r\n 8 1 6']}, {'input': '0 120 83\r\n98 0 90\r\n105 68 0\r\n', 'output': ['79 120 83\r\n98 94 90\r\n105 68 109', '79 120 83\r\n 98 94 90\r\n 105 68 109', '79 120 83 \r\n98 94 90 \r\n105 68 109']}, {'input': '0 98721 99776\r\n99575 0 99123\r\n98922 99977 0\r\n', 'output': ['99550 98721 99776\r\n99575 99349 99123\r\n98922 99977 99148', '99550 98721 99776\r\n 99575 99349 99123\r\n 98922 99977 99148', '99550 98721 99776 \r\n99575 99349 99123 \r\n98922 99977 99148']}, {'input': '0 505 681\r\n605 0 657\r\n581 757 0\r\n', 'output': ['707 505 681 \r\n605 631 657 \r\n581 757 555', '707 505 681\r\n 605 631 657\r\n 581 757 555', '707 505 681\r\n605 631 657\r\n581 757 555']}, {'input': '0 1099 1002\r\n1027 0 1049\r\n1074 977 0\r\n', 'output': ['1013 1099 1002 \r\n1027 1038 1049 \r\n1074 977 1063', '1013 1099 1002\r\n1027 1038 1049\r\n1074 977 1063', '1013 1099 1002\r\n 1027 1038 1049\r\n 1074 977 1063']}] | [{'input': '0 99978 99920\r\n99950 0 99918\r\n99948 99890 0\r\n', 'output': ['99904 99978 99920\r\n99950 99934 99918\r\n99948 99890 99964', '99904 99978 99920\r\n 99950 99934 99918\r\n 99948 99890 99964', '99904 99978 99920 \r\n99950 99934 99918 \r\n99948 99890 99964']}, {'input': '0 120 83\r\n98 0 90\r\n105 68 0\r\n', 'output': ['79 120 83\r\n98 94 90\r\n105 68 109', '79 120 83\r\n 98 94 90\r\n 105 68 109', '79 120 83 \r\n98 94 90 \r\n105 68 109']}, {'input': '0 54 48\r\n36 0 78\r\n66 60 0\r\n', 'output': ['69 54 48 \r\n36 57 78 \r\n66 60 45', '69 54 48\r\n36 57 78\r\n66 60 45', '69 54 48\r\n 36 57 78\r\n 66 60 45']}, {'input': '0 97 56\r\n69 0 71\r\n84 43 0\r\n', 'output': ['57 97 56\r\n69 70 71\r\n84 43 83', '57 97 56\r\n 69 70 71\r\n 84 43 83', '57 97 56 \r\n69 70 71 \r\n84 43 83']}, {'input': '0 93 95\r\n93 0 97\r\n95 97 0\r\n', 'output': ['97 93 95\r\n93 95 97\r\n95 97 93', '97 93 95 \r\n93 95 97 \r\n95 97 93', '97 93 95\r\n 93 95 97\r\n 95 97 93']}] | [{'input': '0 28 10\r\n12 0 24\r\n26 8 0\r\n', 'output': ['16 28 10 \r\n12 18 24 \r\n26 8 20', '16 28 10\r\n12 18 24\r\n26 8 20', '16 28 10\r\n 12 18 24\r\n 26 8 20']}, {'input': '0 1 1\r\n1 0 1\r\n1 1 0\r\n', 'output': ['1 1 1 \r\n1 1 1 \r\n1 1 1', '1 1 1\r\n 1 1 1\r\n 1 1 1', '1 1 1\r\n1 1 1\r\n1 1 1']}, {'input': '0 93 95\r\n93 0 97\r\n95 97 0\r\n', 'output': ['97 93 95\r\n93 95 97\r\n95 97 93', '97 93 95 \r\n93 95 97 \r\n95 97 93', '97 93 95\r\n 93 95 97\r\n 95 97 93']}, {'input': '0 86900 85807\r\n85836 0 86842\r\n86871 85778 0\r\n', 'output': ['86310 86900 85807\r\n 85836 86339 86842\r\n 86871 85778 86368', '86310 86900 85807\r\n85836 86339 86842\r\n86871 85778 86368', '86310 86900 85807 \r\n85836 86339 86842 \r\n86871 85778 86368']}, {'input': '0 1099 1002\r\n1027 0 1049\r\n1074 977 0\r\n', 'output': ['1013 1099 1002 \r\n1027 1038 1049 \r\n1074 977 1063', '1013 1099 1002\r\n1027 1038 1049\r\n1074 977 1063', '1013 1099 1002\r\n 1027 1038 1049\r\n 1074 977 1063']}] | [{'input': '0 97 56\r\n69 0 71\r\n84 43 0\r\n', 'output': ['57 97 56\r\n69 70 71\r\n84 43 83', '57 97 56\r\n 69 70 71\r\n 84 43 83', '57 97 56 \r\n69 70 71 \r\n84 43 83']}, {'input': '0 98721 99776\r\n99575 0 99123\r\n98922 99977 0\r\n', 'output': ['99550 98721 99776\r\n99575 99349 99123\r\n98922 99977 99148', '99550 98721 99776\r\n 99575 99349 99123\r\n 98922 99977 99148', '99550 98721 99776 \r\n99575 99349 99123 \r\n98922 99977 99148']}, {'input': '0 28 10\r\n12 0 24\r\n26 8 0\r\n', 'output': ['16 28 10 \r\n12 18 24 \r\n26 8 20', '16 28 10\r\n12 18 24\r\n26 8 20', '16 28 10\r\n 12 18 24\r\n 26 8 20']}, {'input': '0 4 4\r\n4 0 4\r\n4 4 0\r\n', 'output': ['4 4 4\r\n 4 4 4\r\n 4 4 4', '4 4 4 \r\n4 4 4 \r\n4 4 4', '4 4 4\r\n4 4 4\r\n4 4 4']}, {'input': '0 3 6\r\n5 0 5\r\n4 7 0\r\n', 'output': ['6 3 6\r\n 5 5 5\r\n 4 7 4', '6 3 6\r\n5 5 5\r\n4 7 4', '6 3 6 \r\n5 5 5 \r\n4 7 4']}] | [{'input': '0 1 43\r\n13 0 61\r\n31 73 0\r\n', 'output': ['67 1 43\r\n 13 37 61\r\n 31 73 7', '67 1 43\r\n13 37 61\r\n31 73 7', '67 1 43 \r\n13 37 61 \r\n31 73 7']}, {'input': '0 9 2\r\n3 0 7\r\n8 1 0\r\n', 'output': ['4 9 2 \r\n3 5 7 \r\n8 1 6', '4 9 2\r\n3 5 7\r\n8 1 6', '4 9 2\r\n 3 5 7\r\n 8 1 6']}, {'input': '0 7 6\r\n9 0 1\r\n4 3 0\r\n', 'output': ['2 7 6\r\n9 5 1\r\n4 3 8', '2 7 6 \r\n9 5 1 \r\n4 3 8', '2 7 6\r\n 9 5 1\r\n 4 3 8']}, {'input': '0 1099 1002\r\n1027 0 1049\r\n1074 977 0\r\n', 'output': ['1013 1099 1002 \r\n1027 1038 1049 \r\n1074 977 1063', '1013 1099 1002\r\n1027 1038 1049\r\n1074 977 1063', '1013 1099 1002\r\n 1027 1038 1049\r\n 1074 977 1063']}, {'input': '0 662 918\r\n822 0 854\r\n758 1014 0\r\n', 'output': ['934 662 918 \r\n822 838 854 \r\n758 1014 742', '934 662 918\r\n 822 838 854\r\n 758 1014 742', '934 662 918\r\n822 838 854\r\n758 1014 742']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 20 | 100 | 100 | 100 |
["8 5\n10 9 8 7 7 7 5 5", "4 2\n0 0 0 0"] | The first line of the input contains two integers n and k (1ββ€βkββ€βnββ€β50) separated by a single space. The second line contains n space-separated integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to nβ-β1 the following condition is fulfilled: aiββ₯βaiβ+β1). | 193ec1226ffe07522caf63e84a7d007f | #include<stdio.h>
int main()
{
int n, k;
int i, s = 0, a[101];
while (scanf("%d%d", &n, &k) != EOF)
{
for (i = 1; i <= n; i++)
scanf("%d", &a[i]);
for (i = 1; i <= n; i++)
{
if (a[i] >= a[k] && a[i] != 0)
s++;
}
printf("%d\n", s);
}
return 0;
}
| ["6", "0"] | C | NoteIn the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.In the second example nobody got a positive score. | Output the number of participants who advance to the next round. | "Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." β an excerpt from contest rules.A total of n participants took part in the contest (nββ₯βk), and you already know their scores. Calculate how many participants will advance to the next round. | [{"input": "8 5\r\n10 9 8 7 7 7 5 5\r\n", "output": ["6"]}, {"input": "4 2\r\n0 0 0 0\r\n", "output": ["0"]}, {"input": "5 1\r\n1 1 1 1 1\r\n", "output": ["5"]}, {"input": "5 5\r\n1 1 1 1 1\r\n", "output": ["5"]}, {"input": "1 1\r\n10\r\n", "output": ["1"]}, {"input": "17 14\r\n16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0\r\n", "output": ["14"]}, {"input": "5 5\r\n3 2 1 0 0\r\n", "output": ["3"]}, {"input": "8 6\r\n10 9 8 7 7 7 5 5\r\n", "output": ["6"]}, {"input": "8 7\r\n10 9 8 7 7 7 5 5\r\n", "output": ["8"]}, {"input": "8 4\r\n10 9 8 7 7 7 5 5\r\n", "output": ["6"]}, {"input": "8 3\r\n10 9 8 7 7 7 5 5\r\n", "output": ["3"]}, {"input": "8 1\r\n10 9 8 7 7 7 5 5\r\n", "output": ["1"]}, {"input": "8 2\r\n10 9 8 7 7 7 5 5\r\n", "output": ["2"]}, {"input": "1 1\r\n100\r\n", "output": ["1"]}, {"input": "1 1\r\n0\r\n", "output": ["0"]}, {"input": "50 25\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\r\n", "output": ["50"]}, {"input": "50 25\r\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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\r\n", "output": ["25"]}, {"input": "50 25\r\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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\r\n", "output": ["26"]}, {"input": "50 25\r\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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\r\n", "output": ["50"]}, {"input": "11 5\r\n100 99 98 97 96 95 94 93 92 91 90\r\n", "output": ["5"]}, {"input": "10 4\r\n100 81 70 69 64 43 34 29 15 3\r\n", "output": ["4"]}, {"input": "11 6\r\n87 71 62 52 46 46 43 35 32 25 12\r\n", "output": ["6"]}, {"input": "17 12\r\n99 88 86 82 75 75 74 65 58 52 45 30 21 16 7 2 2\r\n", "output": ["12"]}, {"input": "20 3\r\n98 98 96 89 87 82 82 80 76 74 74 68 61 60 43 32 30 22 4 2\r\n", "output": ["3"]}, {"input": "36 12\r\n90 87 86 85 83 80 79 78 76 70 69 69 61 61 59 58 56 48 45 44 42 41 33 31 27 25 23 21 20 19 15 14 12 7 5 5\r\n", "output": ["12"]}, {"input": "49 8\r\n99 98 98 96 92 92 90 89 89 86 86 85 83 80 79 76 74 69 67 67 58 56 55 51 49 47 47 46 45 41 41 40 39 34 34 33 25 23 18 15 13 13 11 9 5 4 3 3 1\r\n", "output": ["9"]}, {"input": "49 29\r\n100 98 98 96 96 96 95 87 85 84 81 76 74 70 63 63 63 62 57 57 56 54 53 52 50 47 45 41 41 39 38 31 30 28 27 26 23 22 20 15 15 11 7 6 6 4 2 1 0\r\n", "output": ["29"]}, {"input": "49 34\r\n99 98 96 96 93 92 90 89 88 86 85 85 82 76 73 69 66 64 63 63 60 59 57 57 56 55 54 54 51 48 47 44 42 42 40 39 38 36 33 26 24 23 19 17 17 14 12 7 4\r\n", "output": ["34"]}, {"input": "50 44\r\n100 100 99 97 95 91 91 84 83 83 79 71 70 69 69 62 61 60 59 59 58 58 58 55 55 54 52 48 47 45 44 44 38 36 32 31 28 28 25 25 24 24 24 22 17 15 14 13 12 4\r\n", "output": ["44"]}, {"input": "50 13\r\n99 95 94 94 88 87 81 79 78 76 74 72 72 69 68 67 67 67 66 63 62 61 58 57 55 55 54 51 50 50 48 48 42 41 38 35 34 32 31 30 26 24 13 13 12 6 5 4 3 3\r\n", "output": ["13"]}, {"input": "50 30\r\n100 98 96 94 91 89 88 81 81 81 81 81 76 73 72 71 70 69 66 64 61 59 59 56 52 50 49 48 43 39 36 35 34 34 31 29 27 26 24 22 16 16 15 14 14 14 9 7 4 3\r\n", "output": ["30"]}, {"input": "2 1\r\n10 10\r\n", "output": ["2"]}, {"input": "2 2\r\n10 10\r\n", "output": ["2"]}, {"input": "2 2\r\n10 0\r\n", "output": ["1"]}, {"input": "2 2\r\n10 1\r\n", "output": ["2"]}, {"input": "2 1\r\n10 0\r\n", "output": ["1"]}, {"input": "2 1\r\n10 2\r\n", "output": ["1"]}, {"input": "50 13\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n", "output": ["0"]}, {"input": "50 1\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n", "output": ["0"]}, {"input": "50 50\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n", "output": ["0"]}, {"input": "10 1\r\n5 5 5 3 3 3 0 0 0 0\r\n", "output": ["3"]}, {"input": "10 2\r\n5 5 5 3 3 3 0 0 0 0\r\n", "output": ["3"]}, {"input": "10 3\r\n5 5 5 3 3 3 0 0 0 0\r\n", "output": ["3"]}, {"input": "10 4\r\n5 5 5 3 3 3 0 0 0 0\r\n", "output": ["6"]}, {"input": "10 5\r\n5 5 5 3 3 3 0 0 0 0\r\n", "output": ["6"]}, {"input": "10 6\r\n5 5 5 3 3 3 0 0 0 0\r\n", "output": ["6"]}, {"input": "10 7\r\n5 5 5 3 3 3 0 0 0 0\r\n", "output": ["6"]}, {"input": "10 8\r\n5 5 5 3 3 3 0 0 0 0\r\n", "output": ["6"]}, {"input": "10 9\r\n5 5 5 3 3 3 0 0 0 0\r\n", "output": ["6"]}, {"input": "10 10\r\n5 5 5 3 3 3 0 0 0 0\r\n", "output": ["6"]}] | 100 | 100 | 100 | [{'input': '8 4\r\n10 9 8 7 7 7 5 5\r\n', 'output': ['6']}, {'input': '10 3\r\n5 5 5 3 3 3 0 0 0 0\r\n', 'output': ['3']}, {'input': '49 34\r\n99 98 96 96 93 92 90 89 88 86 85 85 82 76 73 69 66 64 63 63 60 59 57 57 56 55 54 54 51 48 47 44 42 42 40 39 38 36 33 26 24 23 19 17 17 14 12 7 4\r\n', 'output': ['34']}, {'input': '1 1\r\n10\r\n', 'output': ['1']}, {'input': '8 1\r\n10 9 8 7 7 7 5 5\r\n', 'output': ['1']}] | [{'input': '5 5\r\n1 1 1 1 1\r\n', 'output': ['5']}, {'input': '2 1\r\n10 2\r\n', 'output': ['1']}, {'input': '11 5\r\n100 99 98 97 96 95 94 93 92 91 90\r\n', 'output': ['5']}, {'input': '50 30\r\n100 98 96 94 91 89 88 81 81 81 81 81 76 73 72 71 70 69 66 64 61 59 59 56 52 50 49 48 43 39 36 35 34 34 31 29 27 26 24 22 16 16 15 14 14 14 9 7 4 3\r\n', 'output': ['30']}, {'input': '49 8\r\n99 98 98 96 92 92 90 89 89 86 86 85 83 80 79 76 74 69 67 67 58 56 55 51 49 47 47 46 45 41 41 40 39 34 34 33 25 23 18 15 13 13 11 9 5 4 3 3 1\r\n', 'output': ['9']}] | [{'input': '2 2\r\n10 10\r\n', 'output': ['2']}, {'input': '50 50\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n', 'output': ['0']}, {'input': '49 29\r\n100 98 98 96 96 96 95 87 85 84 81 76 74 70 63 63 63 62 57 57 56 54 53 52 50 47 45 41 41 39 38 31 30 28 27 26 23 22 20 15 15 11 7 6 6 4 2 1 0\r\n', 'output': ['29']}, {'input': '36 12\r\n90 87 86 85 83 80 79 78 76 70 69 69 61 61 59 58 56 48 45 44 42 41 33 31 27 25 23 21 20 19 15 14 12 7 5 5\r\n', 'output': ['12']}, {'input': '50 25\r\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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\r\n', 'output': ['50']}] | [{'input': '50 13\r\n99 95 94 94 88 87 81 79 78 76 74 72 72 69 68 67 67 67 66 63 62 61 58 57 55 55 54 51 50 50 48 48 42 41 38 35 34 32 31 30 26 24 13 13 12 6 5 4 3 3\r\n', 'output': ['13']}, {'input': '50 25\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\r\n', 'output': ['50']}, {'input': '10 9\r\n5 5 5 3 3 3 0 0 0 0\r\n', 'output': ['6']}, {'input': '1 1\r\n0\r\n', 'output': ['0']}, {'input': '50 1\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n', 'output': ['0']}] | [{'input': '5 1\r\n1 1 1 1 1\r\n', 'output': ['5']}, {'input': '20 3\r\n98 98 96 89 87 82 82 80 76 74 74 68 61 60 43 32 30 22 4 2\r\n', 'output': ['3']}, {'input': '2 2\r\n10 1\r\n', 'output': ['2']}, {'input': '2 1\r\n10 10\r\n', 'output': ['2']}, {'input': '50 13\r\n99 95 94 94 88 87 81 79 78 76 74 72 72 69 68 67 67 67 66 63 62 61 58 57 55 55 54 51 50 50 48 48 42 41 38 35 34 32 31 30 26 24 13 13 12 6 5 4 3 3\r\n', 'output': ['13']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 90 | 90 | 100 | 100 | 90 | 21 | 100 | 100 | 94 |
["10 3 2", "7 1 2"] | The first line of the input contains three integers t, w and b (1ββ€βt,βw,βbββ€β5Β·1018) β the maximum possible length of the racetrack, the length of Willman's steps and the length of Bolt's steps respectively. | 7a1d8ca25bce0073c4eb5297b94501b5 | #include <stdio.h>
#include <stdlib.h>
unsigned long long int pgcd(unsigned long long int x,unsigned long long int y)
{
if (x==0) return y;
if (y==0) return x;
if ((x==1) || (y==1)) return 1;
if (x==y) return x;
if (x<y) return pgcd(x,y%x);
return pgcd(x%y,y);
}
main()
{
unsigned long long int t,w,b,ww,bb,m,a,r,p,q,d,s;
scanf("%llu%llu%llu",&t,&w,&b);
if (w<b) m = w;
else m = b;
d = pgcd(w,b);
ww = w / d;
bb = b / d;
if (t<ww)
{
a = 0;
r = t;
}
else
{
s = ww;
if ((t/s)<bb)
{
a = 0;
r = t;
}
else
{
s = ww * bb;
if ((t/s)<d)
{
a = 0;
r = t;
}
else
{
s = ww * bb * d;
a = t / s;
r = t % s;
}
}
}
if (m<=r) p = ((a + 1) * m) - 1;
else p = (a * m) + r;
q = t;
d = pgcd(p,q);
p = p / d;
q = q / d;
printf("%llu/%llu",p,q);
}
| ["3/10", "3/7"] | C | NoteIn the first sample Willman and Bolt will tie in case 1, 6 or 7 are chosen as the length of the racetrack. | Print the answer to the problem as an irreducible fraction . Follow the format of the samples output. The fraction (p and q are integers, and both pββ₯β0 and qβ>β0 holds) is called irreducible, if there is no such integer dβ>β1, that both p and q are divisible by d. | Vector Willman and Array Bolt are the two most famous athletes of Byteforces. They are going to compete in a race with a distance of L meters today. Willman and Bolt have exactly the same speed, so when they compete the result is always a tie. That is a problem for the organizers because they want a winner. While watching previous races the organizers have noticed that Willman can perform only steps of length equal to w meters, and Bolt can perform only steps of length equal to b meters. Organizers decided to slightly change the rules of the race. Now, at the end of the racetrack there will be an abyss, and the winner will be declared the athlete, who manages to run farther from the starting point of the the racetrack (which is not the subject to change by any of the athletes). Note that none of the athletes can run infinitely far, as they both will at some moment of time face the point, such that only one step further will cause them to fall in the abyss. In other words, the athlete will not fall into the abyss if the total length of all his steps will be less or equal to the chosen distance L.Since the organizers are very fair, the are going to set the length of the racetrack as an integer chosen randomly and uniformly in range from 1 to t (both are included). What is the probability that Willman and Bolt tie again today? | [{"input": "10 3 2\r\n", "output": ["3/10"]}, {"input": "7 1 2\r\n", "output": ["3/7"]}, {"input": "1 1 1\r\n", "output": ["1/1"]}, {"input": "5814 31 7\r\n", "output": ["94/2907"]}, {"input": "94268 813 766\r\n", "output": ["765/94268"]}, {"input": "262610 5583 4717\r\n", "output": ["2358/131305"]}, {"input": "3898439 96326 71937\r\n", "output": ["71936/3898439"]}, {"input": "257593781689876390 32561717 4411677\r\n", "output": ["7914548537/257593781689876390"]}, {"input": "111319886766128339 7862842484895022 3003994959686829\r\n", "output": ["3003994959686828/111319886766128339"]}, {"input": "413850294331656955 570110918058849723 409853735661743839\r\n", "output": ["409853735661743838/413850294331656955"]}, {"input": "3000000000000000000 2999999999999999873 2999999999999999977\r\n", "output": ["23437499999999999/23437500000000000"]}, {"input": "9 6 1\r\n", "output": ["1/9"]}, {"input": "32 9 2\r\n", "output": ["3/32"]}, {"input": "976 5 6\r\n", "output": ["41/244"]}, {"input": "94268 714 345\r\n", "output": ["689/94268"]}, {"input": "54682301 778668 253103\r\n", "output": ["253102/54682301"]}, {"input": "329245015 1173508 8918834\r\n", "output": ["1173507/329245015"]}, {"input": "321076647734423976 7 7\r\n", "output": ["1/1"]}, {"input": "455227494055672047 92 28\r\n", "output": ["19792499741550983/455227494055672047"]}, {"input": "595779167455745259 6954 8697\r\n", "output": ["205511958419723/595779167455745259"]}, {"input": "1000000000000000000 1000000000 2000000000\r\n", "output": ["1/2"]}, {"input": "462643382718281828 462643382718281507 462643382718281701\r\n", "output": ["33045955908448679/33045955908448702"]}, {"input": "4000000000000000000 9999999999999997 99999999999999999\r\n", "output": ["2499999999999999/1000000000000000000"]}, {"input": "4003000100004000000 9999999099999999 99999999999999999\r\n", "output": ["4999999549999999/2001500050002000000"]}, {"input": "4903000100004000000 58997960959949999 99933992929999999\r\n", "output": ["29498980479974999/2451500050002000000"]}, {"input": "232 17 83\r\n", "output": ["2/29"]}, {"input": "5496272 63 200\r\n", "output": ["13765/2748136"]}, {"input": "180 174 53\r\n", "output": ["13/45"]}, {"input": "1954 190 537\r\n", "output": ["189/1954"]}, {"input": "146752429 510 514\r\n", "output": ["571199/146752429"]}, {"input": "579312860 55 70\r\n", "output": ["10344881/144828215"]}, {"input": "1 9 9\r\n", "output": ["1/1"]}, {"input": "95 19 19\r\n", "output": ["1/1"]}, {"input": "404 63 441\r\n", "output": ["31/202"]}, {"input": "5566 4798 4798\r\n", "output": ["1/1"]}, {"input": "118289676 570846883 570846883\r\n", "output": ["1/1"]}, {"input": "763 358 358\r\n", "output": ["1/1"]}, {"input": "85356138 7223 482120804\r\n", "output": ["3611/42678069"]}, {"input": "674664088 435395270 5\r\n", "output": ["9/674664088"]}, {"input": "762200126044291557 370330636048898430 6\r\n", "output": ["17/762200126044291557"]}, {"input": "917148533938841535 47 344459175789842163\r\n", "output": ["28/183429706787768307"]}, {"input": "360212127113008697 877228952036215545 5259\r\n", "output": ["5258/360212127113008697"]}, {"input": "683705963104411677 89876390 116741460012229240\r\n", "output": ["539258339/683705963104411677"]}, {"input": "573003994959686829 275856334120822851 1319886766128339\r\n", "output": ["3959660298385016/573003994959686829"]}, {"input": "409853735661743839 413850294331656955 413850294331656955\r\n", "output": ["1/1"]}, {"input": "19 1 19\r\n", "output": ["1/19"]}, {"input": "576 18 32\r\n", "output": ["1/16"]}, {"input": "9540 10 954\r\n", "output": ["1/477"]}, {"input": "101997840 6 16999640\r\n", "output": ["1/8499820"]}, {"input": "955944 1278 748\r\n", "output": ["1/639"]}, {"input": "482120804 66748 7223\r\n", "output": ["1/66748"]}, {"input": "370330636048898430 61721772674816405 6\r\n", "output": ["1/61721772674816405"]}, {"input": "344459175789842163 7328918633826429 47\r\n", "output": ["1/7328918633826429"]}, {"input": "877228952036215545 166805277055755 5259\r\n", "output": ["1/55601759018585"]}, {"input": "116741460012229240 1298911316 89876390\r\n", "output": ["1/649455658"]}, {"input": "275856334120822851 209 1319886766128339\r\n", "output": ["1/1319886766128339"]}, {"input": "413850294331656955 1 413850294331656955\r\n", "output": ["1/413850294331656955"]}, {"input": "329245015 3931027 6443236\r\n", "output": ["357366/29931365"]}, {"input": "321076647734423976 7 8\r\n", "output": ["1672274206950125/13378193655600999"]}, {"input": "455227494055672047 71 60\r\n", "output": ["6411654845854559/455227494055672047"]}, {"input": "595779167455745259 9741 9331\r\n", "output": ["61162012885196/595779167455745259"]}, {"input": "6470 80 160\r\n", "output": ["327/647"]}, {"input": "686325 828 1656\r\n", "output": ["114511/228775"]}, {"input": "4535304 2129 4258\r\n", "output": ["755973/1511768"]}, {"input": "40525189 6365 12730\r\n", "output": ["20265394/40525189"]}, {"input": "675297075 25986 51972\r\n", "output": ["112553659/225099025"]}, {"input": "5681598412 75376 226128\r\n", "output": ["1893897375/5681598412"]}, {"input": "384118571739435733 619773000 1859319000\r\n", "output": ["128039524053435733/384118571739435733"]}, {"input": "391554751752251913 625743359 1877230077\r\n", "output": ["130518250652782079/391554751752251913"]}, {"input": "390728504279201198 625082797 1250165594\r\n", "output": ["195364252413988195/390728504279201198"]}, {"input": "389902265396085075 624421544 1248843088\r\n", "output": ["64983710976697837/129967421798695025"]}, {"input": "734812071040507372 857211800 2571635400\r\n", "output": ["61234339274051543/183703017760126843"]}, {"input": "1 1 2\r\n", "output": ["0/1"]}, {"input": "3 1 4\r\n", "output": ["0/1"]}, {"input": "8 2 3\r\n", "output": ["3/8"]}, {"input": "64 32 16\r\n", "output": ["1/2"]}, {"input": "1 1 1000000000\r\n", "output": ["0/1"]}, {"input": "1000000000 1 1\r\n", "output": ["1/1"]}, {"input": "1000000000 1000000000 1000000000\r\n", "output": ["1/1"]}, {"input": "1000000000 2 4\r\n", "output": ["1/2"]}, {"input": "1000000000 123 456\r\n", "output": ["6579023/1000000000"]}, {"input": "1000000000 123123 654\r\n", "output": ["24851/1000000000"]}, {"input": "123456 123 456\r\n", "output": ["215/30864"]}, {"input": "123456 1234567 123\r\n", "output": ["61/61728"]}, {"input": "314159265 271 8281\r\n", "output": ["37939/314159265"]}, {"input": "11071994 4231 1324\r\n", "output": ["2647/11071994"]}, {"input": "961748927 961748941 982451653\r\n", "output": ["1/1"]}, {"input": "15485221 1259 90863\r\n", "output": ["1258/15485221"]}, {"input": "5000000000000000000 4999999999999999837 4999999999999999963\r\n", "output": ["1249999999999999959/1250000000000000000"]}, {"input": "4000000000000000000 3999999999999999691 3999999999999999887\r\n", "output": ["399999999999999969/400000000000000000"]}, {"input": "999999999999999999 999999999999999709 999999999999999737\r\n", "output": ["333333333333333236/333333333333333333"]}, {"input": "799999999999999999 799999999999999969 799999999999999991\r\n", "output": ["799999999999999968/799999999999999999"]}, {"input": "812312312312312222 812312312312311897 812312312312312029\r\n", "output": ["406156156156155948/406156156156156111"]}, {"input": "500000000000000000 499999999999999927 499999999999999931\r\n", "output": ["249999999999999963/250000000000000000"]}, {"input": "555555555555555555 555555555555555083 555555555555555229\r\n", "output": ["50505050505050462/50505050505050505"]}, {"input": "199419941994199419 199419941994199369 199419941994199391\r\n", "output": ["66473313998066456/66473313998066473"]}, {"input": "145685485411238588 145685485411238483 145685485411238573\r\n", "output": ["72842742705619241/72842742705619294"]}, {"input": "314159265358979323 314159265358979167 314159265358979213\r\n", "output": ["314159265358979166/314159265358979323"]}, {"input": "10 1000000000000000000 1000000000000000001\r\n", "output": ["1/1"]}, {"input": "5 100000000000000000 99999999999999999\r\n", "output": ["1/1"]}, {"input": "5 1000000000000 1000000000001\r\n", "output": ["1/1"]}, {"input": "5 1000000000000000000 1000000000000000001\r\n", "output": ["1/1"]}, {"input": "2 1000000000000000000 1000000000000000001\r\n", "output": ["1/1"]}, {"input": "2 10 11\r\n", "output": ["1/1"]}, {"input": "10 123456789123456789 723456789123456781\r\n", "output": ["1/1"]}, {"input": "12345678910 123456789101112131 123456789101112132\r\n", "output": ["1/1"]}, {"input": "5 499999999999999999 499999999999999998\r\n", "output": ["1/1"]}] | 100 | 100 | 100 | [{'input': '555555555555555555 555555555555555083 555555555555555229\r\n', 'output': ['50505050505050462/50505050505050505']}, {'input': '573003994959686829 275856334120822851 1319886766128339\r\n', 'output': ['3959660298385016/573003994959686829']}, {'input': '370330636048898430 61721772674816405 6\r\n', 'output': ['1/61721772674816405']}, {'input': '1000000000 2 4\r\n', 'output': ['1/2']}, {'input': '5496272 63 200\r\n', 'output': ['13765/2748136']}] | [{'input': '40525189 6365 12730\r\n', 'output': ['20265394/40525189']}, {'input': '917148533938841535 47 344459175789842163\r\n', 'output': ['28/183429706787768307']}, {'input': '9 6 1\r\n', 'output': ['1/9']}, {'input': '462643382718281828 462643382718281507 462643382718281701\r\n', 'output': ['33045955908448679/33045955908448702']}, {'input': '329245015 1173508 8918834\r\n', 'output': ['1173507/329245015']}] | [{'input': '1000000000 123123 654\r\n', 'output': ['24851/1000000000']}, {'input': '1000000000 1000000000 1000000000\r\n', 'output': ['1/1']}, {'input': '404 63 441\r\n', 'output': ['31/202']}, {'input': '812312312312312222 812312312312311897 812312312312312029\r\n', 'output': ['406156156156155948/406156156156156111']}, {'input': '573003994959686829 275856334120822851 1319886766128339\r\n', 'output': ['3959660298385016/573003994959686829']}] | [{'input': '391554751752251913 625743359 1877230077\r\n', 'output': ['130518250652782079/391554751752251913']}, {'input': '123456 1234567 123\r\n', 'output': ['61/61728']}, {'input': '1000000000000000000 1000000000 2000000000\r\n', 'output': ['1/2']}, {'input': '5814 31 7\r\n', 'output': ['94/2907']}, {'input': '10 3 2\r\n', 'output': ['3/10']}] | [{'input': '11071994 4231 1324\r\n', 'output': ['2647/11071994']}, {'input': '683705963104411677 89876390 116741460012229240\r\n', 'output': ['539258339/683705963104411677']}, {'input': '3 1 4\r\n', 'output': ['0/1']}, {'input': '763 358 358\r\n', 'output': ['1/1']}, {'input': '2 1000000000000000000 1000000000000000001\r\n', 'output': ['1/1']}] | 100 | 100 | 100 | 100 | 100 | 88.57 | 88.57 | 94.29 | 88.57 | 94.29 | 86.36 | 86.36 | 95.45 | 86.36 | 95.45 | 22 | 100 | 90.858 | 89.996 |
["2", "3", "4", "10"] | The only line of the input contains a single integer n (2ββ€βnββ€β1018)Β β the number of players to participate in the tournament. | 3d3432b4f7c6a3b901161fa24b415b14 | #include <stdio.h>
int main()
{
long long int n;
long long ans = 0, a = 2, b = 1, c = 0;
scanf("%lld", &n);
if(n == 2) {printf("1\n");return 0;}
else if(n == 3) {printf("2\n");return 0;}
else
while(1)
{
if(a > n) break;
ans++;
c = b;
b = a;
a += c;
}
printf("%lld", ans);
return 0;
}
| ["1", "2", "2", "4"] | C | NoteIn all samples we consider that player number 1 is the winner.In the first sample, there would be only one game so the answer is 1.In the second sample, player 1 can consequently beat players 2 and 3. In the third sample, player 1 can't play with each other player as after he plays with players 2 and 3 he can't play against player 4, as he has 0 games played, while player 1 already played 2. Thus, the answer is 2 and to achieve we make pairs (1,β2) and (3,β4) and then clash the winners. | Print the maximum number of games in which the winner of the tournament can take part. | Famous Brazil city Rio de Janeiro holds a tennis tournament and Ostap Bender doesn't want to miss this event. There will be n players participating, and the tournament will follow knockout rules from the very first game. That means, that if someone loses a game he leaves the tournament immediately.Organizers are still arranging tournament grid (i.e. the order games will happen and who is going to play with whom) but they have already fixed one rule: two players can play against each other only if the number of games one of them has already played differs by no more than one from the number of games the other one has already played. Of course, both players had to win all their games in order to continue participating in the tournament.Tournament hasn't started yet so the audience is a bit bored. Ostap decided to find out what is the maximum number of games the winner of the tournament can take part in (assuming the rule above is used). However, it is unlikely he can deal with this problem without your help. | [{"input": "2\r\n", "output": ["1"]}, {"input": "3\r\n", "output": ["2"]}, {"input": "4\r\n", "output": ["2"]}, {"input": "10\r\n", "output": ["4"]}, {"input": "1000\r\n", "output": ["14"]}, {"input": "2500\r\n", "output": ["15"]}, {"input": "690000\r\n", "output": ["27"]}, {"input": "3000000000\r\n", "output": ["45"]}, {"input": "123456789123456789\r\n", "output": ["81"]}, {"input": "5\r\n", "output": ["3"]}, {"input": "143\r\n", "output": ["9"]}, {"input": "144\r\n", "output": ["10"]}, {"input": "145\r\n", "output": ["10"]}, {"input": "232\r\n", "output": ["10"]}, {"input": "233\r\n", "output": ["11"]}, {"input": "234\r\n", "output": ["11"]}, {"input": "679891637638612257\r\n", "output": ["84"]}, {"input": "679891637638612258\r\n", "output": ["85"]}, {"input": "679891637638612259\r\n", "output": ["85"]}, {"input": "1000000000000000000\r\n", "output": ["85"]}, {"input": "10235439547\r\n", "output": ["47"]}, {"input": "1240723548\r\n", "output": ["43"]}, {"input": "92353046212453\r\n", "output": ["66"]}, {"input": "192403205846532\r\n", "output": ["68"]}, {"input": "13925230525389\r\n", "output": ["62"]}, {"input": "12048230592523\r\n", "output": ["62"]}, {"input": "19204385325853\r\n", "output": ["63"]}, {"input": "902353283921\r\n", "output": ["56"]}, {"input": "793056859214355\r\n", "output": ["70"]}, {"input": "982045466234565\r\n", "output": ["71"]}, {"input": "126743950353465\r\n", "output": ["67"]}, {"input": "12405430465\r\n", "output": ["47"]}, {"input": "10238439257768\r\n", "output": ["61"]}, {"input": "1728493055346\r\n", "output": ["58"]}, {"input": "927553829046\r\n", "output": ["56"]}, {"input": "62735129403\r\n", "output": ["51"]}, {"input": "71624823950223\r\n", "output": ["65"]}, {"input": "8902353464851212\r\n", "output": ["75"]}, {"input": "61824012598535\r\n", "output": ["65"]}, {"input": "1294902504603347\r\n", "output": ["71"]}, {"input": "6\r\n", "output": ["3"]}, {"input": "7\r\n", "output": ["3"]}, {"input": "8\r\n", "output": ["4"]}, {"input": "9\r\n", "output": ["4"]}, {"input": "11\r\n", "output": ["4"]}, {"input": "12\r\n", "output": ["4"]}, {"input": "13\r\n", "output": ["5"]}, {"input": "14\r\n", "output": ["5"]}, {"input": "15\r\n", "output": ["5"]}, {"input": "16\r\n", "output": ["5"]}, {"input": "17\r\n", "output": ["5"]}, {"input": "18\r\n", "output": ["5"]}, {"input": "19\r\n", "output": ["5"]}, {"input": "20\r\n", "output": ["5"]}, {"input": "21\r\n", "output": ["6"]}, {"input": "22\r\n", "output": ["6"]}, {"input": "23\r\n", "output": ["6"]}, {"input": "355687428096000\r\n", "output": ["69"]}, {"input": "576460752303423488\r\n", "output": ["84"]}, {"input": "32212254719\r\n", "output": ["49"]}, {"input": "26388279066623\r\n", "output": ["63"]}, {"input": "618473717761\r\n", "output": ["56"]}, {"input": "262406072477\r\n", "output": ["54"]}] | 100 | 100 | 100 | [{'input': '62735129403\r\n', 'output': ['51']}, {'input': '8902353464851212\r\n', 'output': ['75']}, {'input': '145\r\n', 'output': ['10']}, {'input': '19204385325853\r\n', 'output': ['63']}, {'input': '679891637638612257\r\n', 'output': ['84']}] | [{'input': '902353283921\r\n', 'output': ['56']}, {'input': '3000000000\r\n', 'output': ['45']}, {'input': '618473717761\r\n', 'output': ['56']}, {'input': '10235439547\r\n', 'output': ['47']}, {'input': '126743950353465\r\n', 'output': ['67']}] | [{'input': '262406072477\r\n', 'output': ['54']}, {'input': '19\r\n', 'output': ['5']}, {'input': '18\r\n', 'output': ['5']}, {'input': '15\r\n', 'output': ['5']}, {'input': '902353283921\r\n', 'output': ['56']}] | [{'input': '92353046212453\r\n', 'output': ['66']}, {'input': '22\r\n', 'output': ['6']}, {'input': '3000000000\r\n', 'output': ['45']}, {'input': '6\r\n', 'output': ['3']}, {'input': '10238439257768\r\n', 'output': ['61']}] | [{'input': '20\r\n', 'output': ['5']}, {'input': '92353046212453\r\n', 'output': ['66']}, {'input': '192403205846532\r\n', 'output': ['68']}, {'input': '690000\r\n', 'output': ['27']}, {'input': '5\r\n', 'output': ['3']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 66.67 | 66.67 | 66.67 | 66.67 | 66.67 | 23 | 100 | 100 | 66.67 |
["2 3\nPPW\nW.P", "3 3\nP.W\n.P.\nW.P"] | The first line contains integers n and m (1ββ€βn,βmββ€β10) which denotes the number of rows and columns in our two-dimensional grid, respectively. Then follow n lines containing m characters each β that is the grid description. "." means that this cell is empty. "P" means that this cell contains a little pig. "W" means that this cell contains a wolf. It is guaranteed that there will be at most one wolf adjacent to any little pig. | 969b24ed98d916184821b2b2f8fd3aac | #include <stdio.h>
int n, m;
char map[10][11];
int wolf(int i, int j)
{
return (i >= 0 && i < n && j >= 0 && j < m && map[i][j] == 'W');
}
int main(int argc, char *argv[])
{
int i, j, c = 0;
scanf("%d %d", &n, &m);
for(i = 0; i < n; i ++)
scanf("%s", map[i]);
for(i = 0; i < n; i ++)
for(j = 0; j < m; j ++)
if(map[i][j] == 'P')
{
if(wolf(i - 1, j))
map[i - 1][j] = '.', c ++;
else if(wolf(i + 1, j))
map[i + 1][j] = '.', c ++;
else if(wolf(i, j - 1))
map[i][j - 1] = '.', c ++;
else if(wolf(i, j + 1))
map[i][j + 1] = '.', c ++;
}
printf("%d\n", c);
return 0;
}
| ["2", "0"] | C | NoteIn the first example, one possible scenario in which two little pigs get eaten by the wolves is as follows. | Print a single number β the maximal number of little pigs that may be eaten by the wolves. | Once upon a time there were several little pigs and several wolves on a two-dimensional grid of size nβΓβm. Each cell in this grid was either empty, containing one little pig, or containing one wolf.A little pig and a wolf are adjacent if the cells that they are located at share a side. The little pigs are afraid of wolves, so there will be at most one wolf adjacent to each little pig. But each wolf may be adjacent to any number of little pigs.They have been living peacefully for several years. But today the wolves got hungry. One by one, each wolf will choose one of the little pigs adjacent to it (if any), and eats the poor little pig. This process is not repeated. That is, each wolf will get to eat at most one little pig. Once a little pig gets eaten, it disappears and cannot be eaten by any other wolf.What is the maximum number of little pigs that may be eaten by the wolves? | [{"input": "2 3\r\nPPW\r\nW.P\r\n", "output": ["2"]}, {"input": "3 3\r\nP.W\r\n.P.\r\nW.P\r\n", "output": ["0"]}, {"input": "6 5\r\n.....\r\n..PW.\r\n.....\r\n.WP..\r\n.....\r\n.....\r\n", "output": ["2"]}, {"input": "5 5\r\n.....\r\n..P..\r\n.W.W.\r\n..P..\r\n.....\r\n", "output": ["0"]}, {"input": "5 5\r\n.....\r\n..P..\r\n..W..\r\n..P..\r\n.....\r\n", "output": ["1"]}, {"input": "10 10\r\n..........\r\n..........\r\n..........\r\n....P.....\r\n...PWP....\r\n....P.....\r\n..........\r\n..........\r\n..........\r\n..........\r\n", "output": ["1"]}, {"input": "1 1\r\nP\r\n", "output": ["0"]}, {"input": "2 6\r\nWW..WW\r\n.PPPP.\r\n", "output": ["2"]}, {"input": "6 2\r\n.W\r\n.W\r\n.P\r\nWP\r\n.P\r\nPW\r\n", "output": ["3"]}, {"input": "2 10\r\nW..WWP.P.P\r\nW..PP.WWP.\r\n", "output": ["3"]}, {"input": "10 2\r\nP.\r\n.W\r\nPW\r\n..\r\nW.\r\nW.\r\n..\r\nP.\r\nWP\r\nPP\r\n", "output": ["2"]}, {"input": "3 4\r\nWPPW\r\n.P..\r\nPWW.\r\n", "output": ["3"]}, {"input": "4 3\r\n.WW\r\n..P\r\nP.P\r\nPWW\r\n", "output": ["3"]}, {"input": "3 10\r\nWPPP...PP.\r\n.P...WW..W\r\n.WWP.PP.PW\r\n", "output": ["6"]}, {"input": "10 3\r\n...\r\nPWW\r\n..P\r\n..P\r\nP.P\r\nWP.\r\nPPW\r\n..W\r\nW..\r\nWPP\r\n", "output": ["5"]}, {"input": "4 8\r\n..PW..WW\r\nWWPP.PP.\r\nP...PW.P\r\nP.WW...P\r\n", "output": ["5"]}, {"input": "8 4\r\nP.WW\r\nW..P\r\nP..P\r\nP.WW\r\n..P.\r\nW.P.\r\nWP.W\r\nP..P\r\n", "output": ["6"]}, {"input": "1 1\r\nW\r\n", "output": ["0"]}, {"input": "4 10\r\n..P.PW.P.P\r\nP.WP.W..WP\r\nW..P.P..WP\r\nW.PWW.P.P.\r\n", "output": ["7"]}, {"input": "10 4\r\nWPPP\r\nP.PW\r\n...W\r\nW..P\r\n..W.\r\n.PP.\r\nW..P\r\nW.PW\r\n..P.\r\nPPW.\r\n", "output": ["6"]}, {"input": "5 1\r\n.\r\nP\r\n.\r\n.\r\nW\r\n", "output": ["0"]}, {"input": "1 5\r\nPW...\r\n", "output": ["1"]}, {"input": "5 10\r\nP.PPWWP.PP\r\n.W....P.PP\r\nPWPP..WW..\r\n...W..P.P.\r\nWP.W...PWW\r\n", "output": ["7"]}, {"input": "10 5\r\n..PWW\r\nWWP.P\r\n.PP..\r\nP..WW\r\nPW...\r\n.W..P\r\n..P.W\r\nP.PP.\r\nW..WP\r\nWPPP.\r\n", "output": ["8"]}, {"input": "6 5\r\n..WP.\r\nWP..W\r\nW.PP.\r\n.PWW.\r\nP.PPP\r\nWP..W\r\n", "output": ["6"]}, {"input": "5 6\r\nP...PW\r\n.WWP.W\r\n.P...P\r\nWP..W.\r\nWPPPWP\r\n", "output": ["7"]}, {"input": "6 10\r\nPPP.WW..PW\r\n.W.....WP.\r\n.W.PP..WP.\r\n.PP..WPP.P\r\nW.PW.P.PWW\r\nWP.P..P.P.\r\n", "output": ["10"]}, {"input": "10 6\r\n.WW.PW\r\n......\r\nWP..W.\r\nPPWP.P\r\n.PW.PW\r\nPP.P.W\r\nP.PWPP\r\nW..W.P\r\nWPP..W\r\n.PWP.W\r\n", "output": ["11"]}, {"input": "10 10\r\n..........\r\n..........\r\n..........\r\n..........\r\n..........\r\n..........\r\n..........\r\n..........\r\n..........\r\n..........\r\n", "output": ["0"]}, {"input": "7 3\r\nWPP\r\nW.P\r\n...\r\nPWP\r\nPW.\r\n..P\r\n..W\r\n", "output": ["4"]}, {"input": "3 7\r\nWP...PW\r\n.PW.P..\r\nPPW.PW.\r\n", "output": ["5"]}, {"input": "7 10\r\nW..W.PWW.P\r\nW.P.P.PP.W\r\nP...W.....\r\nPWPPW..WW.\r\n....PPP..P\r\nWP.WPP.P.P\r\nPP..PWP.WW\r\n", "output": ["11"]}, {"input": "10 7\r\n.PW..WP\r\nW...PW.\r\n..PW...\r\nPW..PP.\r\n.W.P.WW\r\n.P.P...\r\nP.PPW..\r\n.PW...P\r\nW.P.PPP\r\nW.PPWPP\r\n", "output": ["10"]}, {"input": "8 8\r\n.WP....W\r\n.W..W.PW\r\n.PPPWPP.\r\nW..P..W.\r\nP.WP...P\r\n.P..WPP.\r\nP.PPPPWW\r\n.PWWP...\r\n", "output": ["11"]}, {"input": "8 8\r\nWP.W...P\r\nW.P..WW.\r\nP.W.P.P.\r\nPPPPPPPP\r\nWW..WP.W\r\nP.P.PP..\r\n..WW..W.\r\nPP....W.\r\n", "output": ["9"]}, {"input": "8 10\r\nPWW..P..W.\r\nPP.PP...W.\r\nWP..PWW.P.\r\nP.P.....P.\r\nPPW.P.P.WW\r\nPPP.WW.PP.\r\nW.P....P.P\r\n..WWPPW..W\r\n", "output": ["12"]}, {"input": "10 8\r\n.PPW.PWW\r\nW.PWP.P.\r\nWP..PP..\r\n..WP.PPP\r\n..PP.WW.\r\n.WP...P.\r\n..PWW..W\r\nW.P..PPW\r\n...P...P\r\nPWP.WWP.\r\n", "output": ["12"]}, {"input": "9 8\r\nPP..W..W\r\n.PP.W..W\r\n..W...PP\r\nWP.P.WW.\r\nW..W.P..\r\nP.PP..P.\r\n...PW.PP\r\n.WPPW..W\r\nPWP.PPPP\r\n", "output": ["12"]}, {"input": "8 9\r\nPWWPPW..W\r\nP.P..WP.P\r\nW..WPP.PP\r\nP.PP....W\r\n.....WWP.\r\nP.WWP.P..\r\nW......WW\r\nPP.PWPP.P\r\n", "output": ["13"]}, {"input": "10 10\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\n", "output": ["0"]}, {"input": "9 10\r\nW.PPWW..P.\r\nW.P.....WP\r\nP..W......\r\n..P.PP.W.P\r\n.PW.P..W..\r\n..P...PPPP\r\nPPP.W..PPP\r\nWW.PW...PP\r\n.PPP..WW.P\r\n", "output": ["8"]}, {"input": "10 9\r\nWWP.P.WPP\r\n..PWP.P.W\r\n....PWP..\r\nWW...P.WP\r\n.P.WP..W.\r\nPP...W.P.\r\nP.W..WP.W\r\n.PWPP..P.\r\n.PPPPPWW.\r\nPW..W..PP\r\n", "output": ["15"]}, {"input": "10 1\r\n.\r\nW\r\nW\r\nP\r\nP\r\n.\r\n.\r\n.\r\nW\r\nP\r\n", "output": ["2"]}, {"input": "1 10\r\nP.PW.PW..W\r\n", "output": ["2"]}, {"input": "10 10\r\nPWPP...PPW\r\n.P.W...W..\r\nW.P.PW....\r\nP.P.PW..WP\r\nPP.W.PP.P.\r\n.P.P..WP.W\r\n.WW.PPP..P\r\n..P...PPP.\r\nP.P..WW..W\r\n.WWP...PPW\r\n", "output": ["16"]}, {"input": "10 10\r\n.PW...P.PW\r\n....W..PPW\r\nWWP.W..P.P\r\n.P..PP.P..\r\n...W...WW.\r\nPWP..W....\r\nPW...W..PW\r\n.P..P.PP.P\r\nPPPPWP..W.\r\nPPPPP.W.PP\r\n", "output": ["11"]}, {"input": "10 10\r\nPP..PPWPPW\r\nPPPPPPPP..\r\n.PPPPPPP.P\r\nPPPPPPPPPP\r\nPWP.PPP.PP\r\nPW.PP.PPPP\r\nPPPPPP.PPW\r\n..PPWPPP.P\r\nWPPPPPPPPP\r\nWP.WPPPWPP\r\n", "output": ["10"]}, {"input": "10 10\r\nPPPPPPPPPP\r\nPPPPPPPWPP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\n", "output": ["1"]}, {"input": "10 10\r\nPPPPPPPPWP\r\nPPPWPPPPPP\r\nPPPPPPPPPP\r\nPWWPPWPPPP\r\nPPPPPPPPPP\r\nPPPPWPPPPP\r\nPPPPPPPPPP\r\nPPPPPPWPPW\r\nPPPPPPPPPP\r\nPPWPPPPPWP\r\n", "output": ["10"]}, {"input": "10 10\r\n.PWWP..W..\r\n.....W...W\r\nWP........\r\nW...WP....\r\nP.W..P..WW\r\n..W...WP.P\r\nW...W.....\r\n....WP..P.\r\n.W....W..W\r\n.W....W..W\r\n", "output": ["8"]}, {"input": "10 10\r\nWWWWWWWWWW\r\nWWWWWWWWWW\r\nWWWWWWWWWW\r\nWWWWWWWWWW\r\nWWWWWWWWWW\r\nWWWWWWWWWW\r\nWWWWWWWWWW\r\nWWWWWWWWWW\r\nWWWWWWWWWW\r\nWWWWWWWWWW\r\n", "output": ["0"]}, {"input": "10 10\r\nW..W..W...\r\nW..P..W...\r\n..W.....WW\r\n....WW....\r\nWW.....W..\r\n.........W\r\n..WW......\r\n.......WW.\r\nW.........\r\nW..WW....W\r\n", "output": ["1"]}, {"input": "10 10\r\nWP..P....W\r\nW...W..P.W\r\n....P.WW..\r\n..WW......\r\n.........W\r\nWP....W..W\r\nW..W..W...\r\n...WP...W.\r\n.W.P..P.W.\r\nPW...PW...\r\n", "output": ["7"]}, {"input": "10 10\r\n..P..WWP.W\r\nPP.WPPPPPP\r\nWWPP.PPWPP\r\nPPPPW..PPW\r\nPP.PW.P.PW\r\nWW..PPWWP.\r\n..PW...PP.\r\n.PPPP.PPPW\r\nPP.PWP..P.\r\nPWPPP..WWP\r\n", "output": ["20"]}, {"input": "10 10\r\n......W...\r\n..........\r\n..........\r\n..........\r\n..........\r\n..........\r\n..........\r\n..........\r\n..........\r\n........P.\r\n", "output": ["0"]}, {"input": "10 10\r\n.........P\r\n...P.W....\r\nPP...WP.WP\r\n.W........\r\n..........\r\n.....WP.W.\r\n........WP\r\n...P......\r\n.......W..\r\n.PW..W....\r\n", "output": ["6"]}, {"input": "10 10\r\n.P.PPPP..W\r\nPWW.PPWPPW\r\n...PPP.P..\r\nW..P...WP.\r\n.PPWPP.W..\r\n...PPWPPPP\r\nWP..PW..W.\r\nPPW.....P.\r\nP.P...PP.W\r\nWPPWW.PPPW\r\n", "output": ["14"]}, {"input": "10 10\r\nW....W...W\r\nW....W....\r\n..WW...WW.\r\n..........\r\n.....W...W\r\n.....W....\r\nWW........\r\n........WW\r\n..W...W...\r\nW...W.....\r\n", "output": ["0"]}, {"input": "10 10\r\nW...W.....\r\n..W...WW..\r\n.........W\r\n...WW....W\r\nWW.....W..\r\n.....W....\r\n..W.....W.\r\nW...W.....\r\nW.....W..W\r\n..WW..W..W\r\n", "output": ["0"]}, {"input": "10 10\r\nWW..W...WW\r\n....W.....\r\n......WW..\r\n.W.....P..\r\n.W...W..WW\r\n...W......\r\nW..W......\r\nW....WW..P\r\nP.........\r\n...WW...WW\r\n", "output": ["2"]}, {"input": "10 10\r\nP.PPP.PP.P\r\nPPP.PPP.P.\r\nP.PPPP..PW\r\nP.PPP.PP.P\r\nPPPPPP.P.P\r\nPPPP.PP.P.\r\n.PPWPPPPP.\r\nPPP...PPPP\r\nPPP.PPPP.P\r\n.WPPPP.P.P\r\n", "output": ["3"]}, {"input": "1 4\r\nW..P\r\n", "output": ["0"]}, {"input": "10 10\r\nP.W.P.W.P.\r\n.W.P.W.P.W\r\nP.W.P.W.P.\r\n.W.P.W.P.W\r\nP.W.P.W.P.\r\n.W.P.W.P.W\r\nP.W.P.W.P.\r\n.W.P.W.P.W\r\nP.W.P.W.P.\r\n.W.P.W.P.W\r\n", "output": ["0"]}, {"input": "10 10\r\nWPPPWPPPWP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nWPPPWPPPWP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nWPPPWPPPWP\r\nPPPPPPPPPP\r\n", "output": ["9"]}, {"input": "10 10\r\nPPPPPPPPPP\r\nWWWWWWWWWW\r\nWWWWWWWWWW\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nWWWWWWWWWW\r\nWWWWWWWWWW\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nWWWWWWWWWW\r\n", "output": ["50"]}, {"input": "4 1\r\n.\r\nW\r\nP\r\n.\r\n", "output": ["1"]}, {"input": "1 10\r\nP..W.PPWW.\r\n", "output": ["1"]}, {"input": "10 1\r\nP\r\nP\r\nW\r\nW\r\n.\r\nP\r\n.\r\n.\r\n.\r\nW\r\n", "output": ["1"]}, {"input": "1 1\r\n.\r\n", "output": ["0"]}, {"input": "10 10\r\nPPPWPPPWPP\r\nPWPPPWPPPP\r\nPPPPPPPPPP\r\nWPPWPPWPPW\r\nPPPPPPPPPP\r\nPWPPWPPWPP\r\nPPPPPPPPPP\r\nPPWPPWPPWP\r\nPPPPPPPPPP\r\nWPPWPPWPPW\r\n", "output": ["18"]}, {"input": "10 10\r\nWPPPPWPPWP\r\nPPPWPPPPPP\r\nPWPPPPWPPP\r\nPPPPWPPPWP\r\nWPPPPPPPPP\r\nPPPWPPWPPP\r\nPWPPPPPPWP\r\nPPPPWPPPPP\r\nWPPPPPWPPP\r\nPPPWPPPPWP\r\n", "output": ["18"]}, {"input": "4 4\r\n.P..\r\n.W..\r\n.P..\r\n..W.\r\n", "output": ["1"]}, {"input": "4 1\r\n.\r\n.\r\nW\r\nP\r\n", "output": ["1"]}, {"input": "3 3\r\nPWP\r\n...\r\nW..\r\n", "output": ["1"]}, {"input": "2 3\r\nWWP\r\nPPP\r\n", "output": ["2"]}] | 100 | 100 | 100 | [{'input': '1 5\r\nPW...\r\n', 'output': ['1']}, {'input': '2 3\r\nWWP\r\nPPP\r\n', 'output': ['2']}, {'input': '3 3\r\nPWP\r\n...\r\nW..\r\n', 'output': ['1']}, {'input': '10 10\r\nPP..PPWPPW\r\nPPPPPPPP..\r\n.PPPPPPP.P\r\nPPPPPPPPPP\r\nPWP.PPP.PP\r\nPW.PP.PPPP\r\nPPPPPP.PPW\r\n..PPWPPP.P\r\nWPPPPPPPPP\r\nWP.WPPPWPP\r\n', 'output': ['10']}, {'input': '8 9\r\nPWWPPW..W\r\nP.P..WP.P\r\nW..WPP.PP\r\nP.PP....W\r\n.....WWP.\r\nP.WWP.P..\r\nW......WW\r\nPP.PWPP.P\r\n', 'output': ['13']}] | [{'input': '3 3\r\nPWP\r\n...\r\nW..\r\n', 'output': ['1']}, {'input': '6 5\r\n..WP.\r\nWP..W\r\nW.PP.\r\n.PWW.\r\nP.PPP\r\nWP..W\r\n', 'output': ['6']}, {'input': '10 1\r\nP\r\nP\r\nW\r\nW\r\n.\r\nP\r\n.\r\n.\r\n.\r\nW\r\n', 'output': ['1']}, {'input': '10 10\r\nW..W..W...\r\nW..P..W...\r\n..W.....WW\r\n....WW....\r\nWW.....W..\r\n.........W\r\n..WW......\r\n.......WW.\r\nW.........\r\nW..WW....W\r\n', 'output': ['1']}, {'input': '10 10\r\nWW..W...WW\r\n....W.....\r\n......WW..\r\n.W.....P..\r\n.W...W..WW\r\n...W......\r\nW..W......\r\nW....WW..P\r\nP.........\r\n...WW...WW\r\n', 'output': ['2']}] | [{'input': '2 3\r\nPPW\r\nW.P\r\n', 'output': ['2']}, {'input': '10 10\r\nPPPPPPPPWP\r\nPPPWPPPPPP\r\nPPPPPPPPPP\r\nPWWPPWPPPP\r\nPPPPPPPPPP\r\nPPPPWPPPPP\r\nPPPPPPPPPP\r\nPPPPPPWPPW\r\nPPPPPPPPPP\r\nPPWPPPPPWP\r\n', 'output': ['10']}, {'input': '10 10\r\n.PWWP..W..\r\n.....W...W\r\nWP........\r\nW...WP....\r\nP.W..P..WW\r\n..W...WP.P\r\nW...W.....\r\n....WP..P.\r\n.W....W..W\r\n.W....W..W\r\n', 'output': ['8']}, {'input': '10 10\r\nWPPPPWPPWP\r\nPPPWPPPPPP\r\nPWPPPPWPPP\r\nPPPPWPPPWP\r\nWPPPPPPPPP\r\nPPPWPPWPPP\r\nPWPPPPPPWP\r\nPPPPWPPPPP\r\nWPPPPPWPPP\r\nPPPWPPPPWP\r\n', 'output': ['18']}, {'input': '10 10\r\nWPPPWPPPWP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nWPPPWPPPWP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nPPPPPPPPPP\r\nWPPPWPPPWP\r\nPPPPPPPPPP\r\n', 'output': ['9']}] | [{'input': '10 10\r\nW....W...W\r\nW....W....\r\n..WW...WW.\r\n..........\r\n.....W...W\r\n.....W....\r\nWW........\r\n........WW\r\n..W...W...\r\nW...W.....\r\n', 'output': ['0']}, {'input': '9 8\r\nPP..W..W\r\n.PP.W..W\r\n..W...PP\r\nWP.P.WW.\r\nW..W.P..\r\nP.PP..P.\r\n...PW.PP\r\n.WPPW..W\r\nPWP.PPPP\r\n', 'output': ['12']}, {'input': '6 5\r\n.....\r\n..PW.\r\n.....\r\n.WP..\r\n.....\r\n.....\r\n', 'output': ['2']}, {'input': '10 10\r\nP.W.P.W.P.\r\n.W.P.W.P.W\r\nP.W.P.W.P.\r\n.W.P.W.P.W\r\nP.W.P.W.P.\r\n.W.P.W.P.W\r\nP.W.P.W.P.\r\n.W.P.W.P.W\r\nP.W.P.W.P.\r\n.W.P.W.P.W\r\n', 'output': ['0']}, {'input': '10 10\r\nW...W.....\r\n..W...WW..\r\n.........W\r\n...WW....W\r\nWW.....W..\r\n.....W....\r\n..W.....W.\r\nW...W.....\r\nW.....W..W\r\n..WW..W..W\r\n', 'output': ['0']}] | [{'input': '10 10\r\n.........P\r\n...P.W....\r\nPP...WP.WP\r\n.W........\r\n..........\r\n.....WP.W.\r\n........WP\r\n...P......\r\n.......W..\r\n.PW..W....\r\n', 'output': ['6']}, {'input': '8 8\r\nWP.W...P\r\nW.P..WW.\r\nP.W.P.P.\r\nPPPPPPPP\r\nWW..WP.W\r\nP.P.PP..\r\n..WW..W.\r\nPP....W.\r\n', 'output': ['9']}, {'input': '3 3\r\nPWP\r\n...\r\nW..\r\n', 'output': ['1']}, {'input': '8 4\r\nP.WW\r\nW..P\r\nP..P\r\nP.WW\r\n..P.\r\nW.P.\r\nWP.W\r\nP..P\r\n', 'output': ['6']}, {'input': '6 5\r\n.....\r\n..PW.\r\n.....\r\n.WP..\r\n.....\r\n.....\r\n', 'output': ['2']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 24 | 100 | 100 | 100 |
["1 3 2", "3 2 1"] | The first line contains three integers r, g and b (0ββ€βr,βg,βbββ€β100). It is guaranteed that rβ+βgβ+βbβ>β0, it means that the group consists of at least one student. | a45daac108076102da54e07e1e2a37d7 | #include <stdio.h>
int main()
{
int n, sum = 0, i;
int a[3];
scanf("%d %d %d", &a[0], &a[1], &a[2]);
n = a[0] + a[1] + a[2];
for (i = 0; ; i++) {
if (a[i % 3] >= 2) {
a[i % 3] -= 2;
n -= 2;
} else if (a[i % 3] == 1) {
a[i % 3]--;
n--;
}
if (n == 0) break;
}
printf("%d\n", i + 30);
return 0;
}
| ["34", "33"] | C | NoteLet's analyze the first sample.At the moment of time 0 a red cablecar comes and one student from the r group get on it and ascends to the top at the moment of time 30.At the moment of time 1 a green cablecar arrives and two students from the g group get on it; they get to the top at the moment of time 31.At the moment of time 2 comes the blue cablecar and two students from the b group get on it. They ascend to the top at the moment of time 32.At the moment of time 3 a red cablecar arrives but the only student who is left doesn't like red and the cablecar leaves empty.At the moment of time 4 a green cablecar arrives and one student from the g group gets on it. He ascends to top at the moment of time 34.Thus, all the students are on the top, overall the ascension took exactly 34 minutes. | Print a single number β the minimal time the students need for the whole group to ascend to the top of the mountain. | A group of university students wants to get to the top of a mountain to have a picnic there. For that they decided to use a cableway.A cableway is represented by some cablecars, hanged onto some cable stations by a cable. A cable is scrolled cyclically between the first and the last cable stations (the first of them is located at the bottom of the mountain and the last one is located at the top). As the cable moves, the cablecar attached to it move as well.The number of cablecars is divisible by three and they are painted three colors: red, green and blue, in such manner that after each red cablecar goes a green one, after each green cablecar goes a blue one and after each blue cablecar goes a red one. Each cablecar can transport no more than two people, the cablecars arrive with the periodicity of one minute (i. e. every minute) and it takes exactly 30 minutes for a cablecar to get to the top.All students are divided into three groups: r of them like to ascend only in the red cablecars, g of them prefer only the green ones and b of them prefer only the blue ones. A student never gets on a cablecar painted a color that he doesn't like,The first cablecar to arrive (at the moment of time 0) is painted red. Determine the least time it will take all students to ascend to the mountain top. | [{"input": "1 3 2\r\n", "output": ["34"]}, {"input": "3 2 1\r\n", "output": ["33"]}, {"input": "3 5 2\r\n", "output": ["37"]}, {"input": "10 10 10\r\n", "output": ["44"]}, {"input": "29 7 24\r\n", "output": ["72"]}, {"input": "28 94 13\r\n", "output": ["169"]}, {"input": "90 89 73\r\n", "output": ["163"]}, {"input": "0 0 1\r\n", "output": ["32"]}, {"input": "0 0 2\r\n", "output": ["32"]}, {"input": "0 1 0\r\n", "output": ["31"]}, {"input": "0 1 1\r\n", "output": ["32"]}, {"input": "0 1 2\r\n", "output": ["32"]}, {"input": "0 2 0\r\n", "output": ["31"]}, {"input": "0 2 1\r\n", "output": ["32"]}, {"input": "0 2 2\r\n", "output": ["32"]}, {"input": "1 0 0\r\n", "output": ["30"]}, {"input": "1 0 1\r\n", "output": ["32"]}, {"input": "1 0 2\r\n", "output": ["32"]}, {"input": "1 1 0\r\n", "output": ["31"]}, {"input": "1 1 1\r\n", "output": ["32"]}, {"input": "1 1 2\r\n", "output": ["32"]}, {"input": "1 2 0\r\n", "output": ["31"]}, {"input": "1 2 1\r\n", "output": ["32"]}, {"input": "1 2 2\r\n", "output": ["32"]}, {"input": "2 0 0\r\n", "output": ["30"]}, {"input": "2 0 1\r\n", "output": ["32"]}, {"input": "2 0 2\r\n", "output": ["32"]}, {"input": "2 1 0\r\n", "output": ["31"]}, {"input": "2 1 1\r\n", "output": ["32"]}, {"input": "2 1 2\r\n", "output": ["32"]}, {"input": "2 2 0\r\n", "output": ["31"]}, {"input": "2 2 1\r\n", "output": ["32"]}, {"input": "2 2 2\r\n", "output": ["32"]}, {"input": "4 5 2\r\n", "output": ["37"]}, {"input": "5 7 8\r\n", "output": ["41"]}, {"input": "13 25 19\r\n", "output": ["67"]}, {"input": "29 28 30\r\n", "output": ["74"]}, {"input": "45 52 48\r\n", "output": ["106"]}, {"input": "68 72 58\r\n", "output": ["136"]}, {"input": "89 92 90\r\n", "output": ["166"]}, {"input": "99 97 98\r\n", "output": ["177"]}, {"input": "89 97 2\r\n", "output": ["175"]}, {"input": "96 3 92\r\n", "output": ["171"]}, {"input": "1 99 87\r\n", "output": ["178"]}, {"input": "95 2 3\r\n", "output": ["171"]}, {"input": "2 97 3\r\n", "output": ["175"]}, {"input": "2 2 99\r\n", "output": ["179"]}, {"input": "100 100 100\r\n", "output": ["179"]}, {"input": "100 0 100\r\n", "output": ["179"]}, {"input": "0 100 100\r\n", "output": ["179"]}, {"input": "100 100 0\r\n", "output": ["178"]}, {"input": "100 0 0\r\n", "output": ["177"]}, {"input": "0 100 0\r\n", "output": ["178"]}, {"input": "0 0 100\r\n", "output": ["179"]}, {"input": "5 4 5\r\n", "output": ["38"]}] | 100 | 100 | 100 | [{'input': '2 2 1\r\n', 'output': ['32']}, {'input': '29 28 30\r\n', 'output': ['74']}, {'input': '99 97 98\r\n', 'output': ['177']}, {'input': '0 2 0\r\n', 'output': ['31']}, {'input': '100 0 100\r\n', 'output': ['179']}] | [{'input': '95 2 3\r\n', 'output': ['171']}, {'input': '2 0 1\r\n', 'output': ['32']}, {'input': '0 0 100\r\n', 'output': ['179']}, {'input': '1 2 0\r\n', 'output': ['31']}, {'input': '100 100 100\r\n', 'output': ['179']}] | [{'input': '89 97 2\r\n', 'output': ['175']}, {'input': '1 1 0\r\n', 'output': ['31']}, {'input': '10 10 10\r\n', 'output': ['44']}, {'input': '2 1 2\r\n', 'output': ['32']}, {'input': '2 0 2\r\n', 'output': ['32']}] | [{'input': '0 1 1\r\n', 'output': ['32']}, {'input': '95 2 3\r\n', 'output': ['171']}, {'input': '2 2 2\r\n', 'output': ['32']}, {'input': '0 0 2\r\n', 'output': ['32']}, {'input': '99 97 98\r\n', 'output': ['177']}] | [{'input': '1 2 1\r\n', 'output': ['32']}, {'input': '2 0 1\r\n', 'output': ['32']}, {'input': '89 97 2\r\n', 'output': ['175']}, {'input': '1 3 2\r\n', 'output': ['34']}, {'input': '1 2 0\r\n', 'output': ['31']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 25 | 100 | 100 | 100 |
["3", "4"] | A single line contains one non-negative integer $$$n$$$ ($$$0 \le n \leq 10^{18}$$$)Β β the number of Shiro's friends. The circular pizza has to be sliced into $$$n + 1$$$ pieces. | 236177ff30dafe68295b5d33dc501828 | #include <stdio.h>
int main()
{
long long int n;
scanf("%lld", &n);
n = n+1;
if(n%2==0||n-1==0)
printf("%lld",n/2);
else
printf("%lld",n);
} | ["2", "5"] | C | NoteTo cut the round pizza into quarters one has to make two cuts through the center with angle $$$90^{\circ}$$$ between them.To cut the round pizza into five equal parts one has to make five cuts. | A single integerΒ β the number of straight cuts Shiro needs. | Katie, Kuro and Shiro are best friends. They have known each other since kindergarten. That's why they often share everything with each other and work together on some very hard problems.Today is Shiro's birthday. She really loves pizza so she wants to invite her friends to the pizza restaurant near her house to celebrate her birthday, including her best friends Katie and Kuro.She has ordered a very big round pizza, in order to serve her many friends. Exactly $$$n$$$ of Shiro's friends are here. That's why she has to divide the pizza into $$$n + 1$$$ slices (Shiro also needs to eat). She wants the slices to be exactly the same size and shape. If not, some of her friends will get mad and go home early, and the party will be over.Shiro is now hungry. She wants to cut the pizza with minimum of straight cuts. A cut is a straight segment, it might have ends inside or outside the pizza. But she is too lazy to pick up the calculator.As usual, she will ask Katie and Kuro for help. But they haven't come yet. Could you help Shiro with this problem? | [{"input": "3\r\n", "output": ["2"]}, {"input": "4\r\n", "output": ["5"]}, {"input": "10\r\n", "output": ["11"]}, {"input": "10000000000\r\n", "output": ["10000000001"]}, {"input": "1234567891\r\n", "output": ["617283946"]}, {"input": "7509213957\r\n", "output": ["3754606979"]}, {"input": "99999999999999999\r\n", "output": ["50000000000000000"]}, {"input": "21\r\n", "output": ["11"]}, {"input": "712394453192\r\n", "output": ["712394453193"]}, {"input": "172212168\r\n", "output": ["172212169"]}, {"input": "822981260158260519\r\n", "output": ["411490630079130260"]}, {"input": "28316250877914571\r\n", "output": ["14158125438957286"]}, {"input": "779547116602436424\r\n", "output": ["779547116602436425"]}, {"input": "578223540024979436\r\n", "output": ["578223540024979437"]}, {"input": "335408917861648766\r\n", "output": ["335408917861648767"]}, {"input": "74859962623690078\r\n", "output": ["74859962623690079"]}, {"input": "252509054433933439\r\n", "output": ["126254527216966720"]}, {"input": "760713016476190622\r\n", "output": ["760713016476190623"]}, {"input": "919845426262703496\r\n", "output": ["919845426262703497"]}, {"input": "585335723211047194\r\n", "output": ["585335723211047195"]}, {"input": "522842184971407769\r\n", "output": ["261421092485703885"]}, {"input": "148049062628894320\r\n", "output": ["148049062628894321"]}, {"input": "84324828731963974\r\n", "output": ["84324828731963975"]}, {"input": "354979173822804781\r\n", "output": ["177489586911402391"]}, {"input": "1312150450968413\r\n", "output": ["656075225484207"]}, {"input": "269587449430302150\r\n", "output": ["269587449430302151"]}, {"input": "645762258982631926\r\n", "output": ["645762258982631927"]}, {"input": "615812229161735895\r\n", "output": ["307906114580867948"]}, {"input": "0\r\n", "output": ["0"]}, {"input": "349993004923078531\r\n", "output": ["174996502461539266"]}, {"input": "891351282707723851\r\n", "output": ["445675641353861926"]}, {"input": "563324731189330734\r\n", "output": ["563324731189330735"]}, {"input": "520974001910286909\r\n", "output": ["260487000955143455"]}, {"input": "666729339802329204\r\n", "output": ["666729339802329205"]}, {"input": "856674611404539671\r\n", "output": ["428337305702269836"]}, {"input": "791809296303238499\r\n", "output": ["395904648151619250"]}, {"input": "711066337317063338\r\n", "output": ["711066337317063339"]}, {"input": "931356503492686566\r\n", "output": ["931356503492686567"]}, {"input": "234122432773361866\r\n", "output": ["234122432773361867"]}, {"input": "1000000000000000000\r\n", "output": ["1000000000000000001"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "2\r\n", "output": ["3"]}, {"input": "7\r\n", "output": ["4"]}, {"input": "63\r\n", "output": ["32"]}, {"input": "24\r\n", "output": ["25"]}, {"input": "8\r\n", "output": ["9"]}, {"input": "15\r\n", "output": ["8"]}] | 100 | 100 | 100 | [{'input': '712394453192\r\n', 'output': ['712394453193']}, {'input': '148049062628894320\r\n', 'output': ['148049062628894321']}, {'input': '172212168\r\n', 'output': ['172212169']}, {'input': '63\r\n', 'output': ['32']}, {'input': '10\r\n', 'output': ['11']}] | [{'input': '563324731189330734\r\n', 'output': ['563324731189330735']}, {'input': '7\r\n', 'output': ['4']}, {'input': '21\r\n', 'output': ['11']}, {'input': '666729339802329204\r\n', 'output': ['666729339802329205']}, {'input': '615812229161735895\r\n', 'output': ['307906114580867948']}] | [{'input': '615812229161735895\r\n', 'output': ['307906114580867948']}, {'input': '856674611404539671\r\n', 'output': ['428337305702269836']}, {'input': '252509054433933439\r\n', 'output': ['126254527216966720']}, {'input': '645762258982631926\r\n', 'output': ['645762258982631927']}, {'input': '0\r\n', 'output': ['0']}] | [{'input': '354979173822804781\r\n', 'output': ['177489586911402391']}, {'input': '563324731189330734\r\n', 'output': ['563324731189330735']}, {'input': '0\r\n', 'output': ['0']}, {'input': '99999999999999999\r\n', 'output': ['50000000000000000']}, {'input': '15\r\n', 'output': ['8']}] | [{'input': '21\r\n', 'output': ['11']}, {'input': '615812229161735895\r\n', 'output': ['307906114580867948']}, {'input': '711066337317063338\r\n', 'output': ['711066337317063339']}, {'input': '791809296303238499\r\n', 'output': ['395904648151619250']}, {'input': '666729339802329204\r\n', 'output': ['666729339802329205']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 75 | 75 | 100 | 100 | 75 | 26 | 100 | 100 | 85 |
["7 2", "59 9"] | The input consists of two integers n and k, separated by spaces β the size of the program in lines and the productivity reduction coefficient, 1ββ€βnββ€β109, 2ββ€βkββ€β10. | 41dfc86d341082dd96e089ac5433dc04 | #include<stdio.h>
typedef long long int L;
int k;
L i,s,n;
int check(L m)
{
s=0;
for(i=m;i>0;i=i/k)
{
s=s+i;
if(s>=n) return 1;
}
return 0;
}
int main()
{
L low=1,high,mid;
scanf("%I64d%d",&n,&k);
high=n;
while(low<high)
{
mid=(low+high)/2;
if(check(mid))
high=mid;
else
low=mid+1;
}
printf("%I64d\n",high);
return 0;
} | ["4", "54"] | C | NoteIn the first sample the answer is vβ=β4. Vasya writes the code in the following portions: first 4 lines, then 2, then 1, and then Vasya falls asleep. Thus, he manages to write 4β+β2β+β1β=β7 lines in a night and complete the task.In the second sample the answer is vβ=β54. Vasya writes the code in the following portions: 54, 6. The total sum is 54β+β6β=β60, that's even more than nβ=β59. | Print the only integer β the minimum value of v that lets Vasya write the program in one night. | One day a highly important task was commissioned to Vasya β writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as lines, drinks another cup of tea, then he writes lines and so on: , , , ...The expression is regarded as the integral part from dividing number a by number b.The moment the current value equals 0, Vasya immediately falls asleep and he wakes up only in the morning, when the program should already be finished.Vasya is wondering, what minimum allowable value v can take to let him write not less than n lines of code before he falls asleep. | [{"input": "7 2\r\n", "output": ["4"]}, {"input": "59 9\r\n", "output": ["54"]}, {"input": "1 9\r\n", "output": ["1"]}, {"input": "11 2\r\n", "output": ["7"]}, {"input": "747 2\r\n", "output": ["376"]}, {"input": "6578 2\r\n", "output": ["3293"]}, {"input": "37212 2\r\n", "output": ["18609"]}, {"input": "12357 2\r\n", "output": ["6181"]}, {"input": "7998332 2\r\n", "output": ["3999172"]}, {"input": "86275251 2\r\n", "output": ["43137632"]}, {"input": "75584551 2\r\n", "output": ["37792280"]}, {"input": "6 3\r\n", "output": ["5"]}, {"input": "43 4\r\n", "output": ["33"]}, {"input": "811 3\r\n", "output": ["543"]}, {"input": "3410 4\r\n", "output": ["2560"]}, {"input": "21341 4\r\n", "output": ["16009"]}, {"input": "696485 4\r\n", "output": ["522368"]}, {"input": "8856748 3\r\n", "output": ["5904504"]}, {"input": "2959379 4\r\n", "output": ["2219538"]}, {"input": "831410263 3\r\n", "output": ["554273516"]}, {"input": "2 5\r\n", "output": ["2"]}, {"input": "19 6\r\n", "output": ["17"]}, {"input": "715 7\r\n", "output": ["615"]}, {"input": "9122 5\r\n", "output": ["7300"]}, {"input": "89117 6\r\n", "output": ["74268"]}, {"input": "689973 7\r\n", "output": ["591408"]}, {"input": "3024524 5\r\n", "output": ["2419624"]}, {"input": "67127156 6\r\n", "output": ["55939302"]}, {"input": "412262167 7\r\n", "output": ["353367574"]}, {"input": "6 8\r\n", "output": ["6"]}, {"input": "246 10\r\n", "output": ["222"]}, {"input": "5314 8\r\n", "output": ["4651"]}, {"input": "15309 9\r\n", "output": ["13609"]}, {"input": "35648 10\r\n", "output": ["32085"]}, {"input": "3018012 8\r\n", "output": ["2640764"]}, {"input": "92153348 9\r\n", "output": ["81914089"]}, {"input": "177583558 10\r\n", "output": ["159825206"]}, {"input": "1000000000 2\r\n", "output": ["500000008"]}, {"input": "1000000000 3\r\n", "output": ["666666672"]}, {"input": "1000000000 4\r\n", "output": ["750000005"]}, {"input": "1000000000 5\r\n", "output": ["800000003"]}, {"input": "1000000000 6\r\n", "output": ["833333338"]}, {"input": "1000000000 7\r\n", "output": ["857142861"]}, {"input": "1000000000 8\r\n", "output": ["875000004"]}, {"input": "1000000000 9\r\n", "output": ["888888894"]}, {"input": "1000000000 10\r\n", "output": ["900000001"]}, {"input": "1 4\r\n", "output": ["1"]}, {"input": "2 10\r\n", "output": ["2"]}, {"input": "1 2\r\n", "output": ["1"]}, {"input": "987862820 9\r\n", "output": ["878100288"]}, {"input": "979591791 9\r\n", "output": ["870748262"]}, {"input": "948889213 9\r\n", "output": ["843457081"]}, {"input": "8 9\r\n", "output": ["8"]}, {"input": "999999999 10\r\n", "output": ["900000000"]}] | 100 | 100 | 100 | [{'input': '1000000000 5\r\n', 'output': ['800000003']}, {'input': '35648 10\r\n', 'output': ['32085']}, {'input': '92153348 9\r\n', 'output': ['81914089']}, {'input': '7 2\r\n', 'output': ['4']}, {'input': '37212 2\r\n', 'output': ['18609']}] | [{'input': '12357 2\r\n', 'output': ['6181']}, {'input': '177583558 10\r\n', 'output': ['159825206']}, {'input': '747 2\r\n', 'output': ['376']}, {'input': '1000000000 3\r\n', 'output': ['666666672']}, {'input': '689973 7\r\n', 'output': ['591408']}] | [{'input': '999999999 10\r\n', 'output': ['900000000']}, {'input': '246 10\r\n', 'output': ['222']}, {'input': '1000000000 5\r\n', 'output': ['800000003']}, {'input': '3018012 8\r\n', 'output': ['2640764']}, {'input': '19 6\r\n', 'output': ['17']}] | [{'input': '8 9\r\n', 'output': ['8']}, {'input': '1000000000 8\r\n', 'output': ['875000004']}, {'input': '1 2\r\n', 'output': ['1']}, {'input': '1000000000 5\r\n', 'output': ['800000003']}, {'input': '6 8\r\n', 'output': ['6']}] | [{'input': '67127156 6\r\n', 'output': ['55939302']}, {'input': '11 2\r\n', 'output': ['7']}, {'input': '3024524 5\r\n', 'output': ['2419624']}, {'input': '2 5\r\n', 'output': ['2']}, {'input': '92153348 9\r\n', 'output': ['81914089']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 27 | 100 | 100 | 100 |
["5 2 1 4 10", "5 2 1 4 5"] | The first line contains 5 positive integers d,βk,βa,βb,βt (1ββ€βdββ€β1012; 1ββ€βk,βa,βb,βtββ€β106; aβ<βb), where: d β the distance from home to the post office; k β the distance, which car is able to drive before breaking; a β the time, which Vasiliy spends to drive 1 kilometer on his car; b β the time, which Vasiliy spends to walk 1 kilometer on foot; t β the time, which Vasiliy spends to repair his car. | 359ddf1f1aed9b3256836e5856fe3466 | #include <stdio.h>
int main() {
long long d, ans, k, a, b, t;
scanf("%lld%lld%lld%lld%lld", &d, &k, &a, &b, &t);
if (d < k)
ans = d * a;
else {
ans = k * a + (d - k) * b;
if (ans > (d / k) * (k * a + t) - t + (d % k) * b)
ans = (d / k) * (k * a + t) - t + (d % k) * b;
if (ans > (d / k) * (k * a + t) + (d % k) * a)
ans = (d / k) * (k * a + t) + (d % k) * a;
}
printf("%lld\n", ans);
return 0;
}
| ["14", "13"] | C | NoteIn the first example Vasiliy needs to drive the first 2 kilometers on the car (in 2 seconds) and then to walk on foot 3 kilometers (in 12 seconds). So the answer equals to 14 seconds.In the second example Vasiliy needs to drive the first 2 kilometers on the car (in 2 seconds), then repair his car (in 5 seconds) and drive 2 kilometers more on the car (in 2 seconds). After that he needs to walk on foot 1 kilometer (in 4 seconds). So the answer equals to 13 seconds. | Print the minimal time after which Vasiliy will be able to reach the post office. | Vasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals to d kilometers.Vasiliy's car is not new β it breaks after driven every k kilometers and Vasiliy needs t seconds to repair it. After repairing his car Vasiliy can drive again (but after k kilometers it will break again, and so on). In the beginning of the trip the car is just from repair station.To drive one kilometer on car Vasiliy spends a seconds, to walk one kilometer on foot he needs b seconds (aβ<βb).Your task is to find minimal time after which Vasiliy will be able to reach the post office. Consider that in every moment of time Vasiliy can left his car and start to go on foot. | [{"input": "5 2 1 4 10\r\n", "output": ["14"]}, {"input": "5 2 1 4 5\r\n", "output": ["13"]}, {"input": "1 1 1 2 1\r\n", "output": ["1"]}, {"input": "1000000000000 1000000 999999 1000000 1000000\r\n", "output": ["999999999999000000"]}, {"input": "997167959139 199252 232602 952690 802746\r\n", "output": ["231947279018960454"]}, {"input": "244641009859 748096 689016 889744 927808\r\n", "output": ["168561873458925288"]}, {"input": "483524125987 264237 209883 668942 244358\r\n", "output": ["101483941282301425"]}, {"input": "726702209411 813081 730750 893907 593611\r\n", "output": ["531038170074636443"]}, {"input": "965585325539 329221 187165 817564 718673\r\n", "output": ["180725885278576882"]}, {"input": "213058376259 910770 679622 814124 67926\r\n", "output": ["144799175679959130"]}, {"input": "451941492387 235422 164446 207726 192988\r\n", "output": ["74320341137487118"]}, {"input": "690824608515 751563 656903 733131 509537\r\n", "output": ["453805226165077316"]}, {"input": "934002691939 300407 113318 885765 858791\r\n", "output": ["105841987132852686"]}, {"input": "375802030518 196518 567765 737596 550121\r\n", "output": ["213368291855090933"]}, {"input": "614685146646 521171 24179 943227 899375\r\n", "output": ["14863532910609884"]}, {"input": "857863230070 37311 545046 657309 991732\r\n", "output": ["467597724229950776"]}, {"input": "101041313494 586155 1461 22992 340986\r\n", "output": ["147680137840428"]}, {"input": "344219396918 167704 522327 941101 690239\r\n", "output": ["179796501677835485"]}, {"input": "583102513046 683844 978741 986255 815301\r\n", "output": ["570707031914457669"]}, {"input": "821985629174 232688 471200 927237 164554\r\n", "output": ["387320209764489810"]}, {"input": "1000000000000 1 1 2 1000000\r\n", "output": ["1999999999999"]}, {"input": "1049 593 10 36 7\r\n", "output": ["10497"]}, {"input": "1 100 1 5 10\r\n", "output": ["1"]}, {"input": "2 3 1 4 10\r\n", "output": ["2"]}, {"input": "10 20 5 15 50\r\n", "output": ["50"]}, {"input": "404319 964146 262266 311113 586991\r\n", "output": ["106039126854"]}, {"input": "1000000000000 1 1 4 1\r\n", "output": ["1999999999999"]}, {"input": "1000000000000 1 1 10 1\r\n", "output": ["1999999999999"]}, {"input": "100 123 1 2 1000\r\n", "output": ["100"]}, {"input": "100 111 1 2 123456\r\n", "output": ["100"]}, {"input": "100 110 1 2 100000\r\n", "output": ["100"]}, {"input": "100 122 1 2 70505\r\n", "output": ["100"]}, {"input": "100 120 1 2 300\r\n", "output": ["100"]}, {"input": "100 125 1 2 300\r\n", "output": ["100"]}, {"input": "100 120 1 2 305\r\n", "output": ["100"]}, {"input": "10 12 3 4 5\r\n", "output": ["30"]}, {"input": "100 1000 1 10 1000\r\n", "output": ["100"]}, {"input": "5 10 1 2 5\r\n", "output": ["5"]}, {"input": "11 3 4 5 1\r\n", "output": ["47"]}, {"input": "100 121 1 2 666\r\n", "output": ["100"]}, {"input": "1 10 1 10 10\r\n", "output": ["1"]}, {"input": "100 120 1 2 567\r\n", "output": ["100"]}, {"input": "1 2 1 2 1\r\n", "output": ["1"]}, {"input": "100 120 1 2 306\r\n", "output": ["100"]}, {"input": "1 2 1 2 2\r\n", "output": ["1"]}, {"input": "100 120 1 2 307\r\n", "output": ["100"]}, {"input": "3 100 1 2 5\r\n", "output": ["3"]}, {"input": "11 12 3 4 5\r\n", "output": ["33"]}, {"input": "100 120 1 2 399\r\n", "output": ["100"]}, {"input": "1 9 54 722 945\r\n", "output": ["54"]}, {"input": "100 10 1 10 100\r\n", "output": ["910"]}, {"input": "100 120 1 2 98765\r\n", "output": ["100"]}, {"input": "100 101 1 2 3\r\n", "output": ["100"]}, {"input": "1000000000000 1 1 1000000 1\r\n", "output": ["1999999999999"]}, {"input": "1 100 2 200 900\r\n", "output": ["2"]}, {"input": "100 120 1 2 505\r\n", "output": ["100"]}, {"input": "100 120 1 2 3\r\n", "output": ["100"]}, {"input": "2 100 1 2 10\r\n", "output": ["2"]}, {"input": "5 10 1 2 10\r\n", "output": ["5"]}, {"input": "10 100 5 6 1000\r\n", "output": ["50"]}, {"input": "100 120 1 2 506\r\n", "output": ["100"]}, {"input": "5 10 1 2 500\r\n", "output": ["5"]}, {"input": "100 120 1 2 507\r\n", "output": ["100"]}, {"input": "100 123 1 2 1006\r\n", "output": ["100"]}, {"input": "100 120 1 2 509\r\n", "output": ["100"]}, {"input": "100 120 1 2 510\r\n", "output": ["100"]}, {"input": "100 120 1 2 512\r\n", "output": ["100"]}, {"input": "4 5 3 4 199\r\n", "output": ["12"]}, {"input": "100 120 1 2 513\r\n", "output": ["100"]}, {"input": "100 123 1 2 1007\r\n", "output": ["100"]}, {"input": "5 6 1 2 10000\r\n", "output": ["5"]}, {"input": "1 10 10 11 12\r\n", "output": ["10"]}, {"input": "100 120 1 2 515\r\n", "output": ["100"]}, {"input": "100 120 1 2 516\r\n", "output": ["100"]}, {"input": "5 10 1 2000 100000\r\n", "output": ["5"]}, {"input": "1000000000000 3 4 5 1\r\n", "output": ["4333333333333"]}, {"input": "100 5 20 21 50\r\n", "output": ["2095"]}, {"input": "3 10 3 6 100\r\n", "output": ["9"]}, {"input": "41 18467 6334 26500 19169\r\n", "output": ["259694"]}, {"input": "10 20 1 2 100\r\n", "output": ["10"]}, {"input": "4 6 1 2 100\r\n", "output": ["4"]}, {"input": "270 66 76 82 27\r\n", "output": ["20628"]}, {"input": "4492 4 3 13 28\r\n", "output": ["44892"]}, {"input": "28 32 37 38 180\r\n", "output": ["1036"]}, {"input": "100 120 1 2 520\r\n", "output": ["100"]}, {"input": "5 10 2 3 10\r\n", "output": ["10"]}, {"input": "66 21 11 21 97\r\n", "output": ["950"]}, {"input": "549 88 81471 83555 35615\r\n", "output": ["44941269"]}, {"input": "100 120 1 2 1\r\n", "output": ["100"]}, {"input": "1 999999 1 2 1000000\r\n", "output": ["1"]}, {"input": "100 20 1 100 999999\r\n", "output": ["8020"]}, {"input": "3 9 8 9 4\r\n", "output": ["24"]}, {"input": "100 120 1 2 600\r\n", "output": ["100"]}, {"input": "6 3 4 9 4\r\n", "output": ["28"]}, {"input": "9 1 1 2 1\r\n", "output": ["17"]}, {"input": "100 120 1 2 522\r\n", "output": ["100"]}, {"input": "501 47 789 798 250\r\n", "output": ["397789"]}, {"input": "3 6 1 6 9\r\n", "output": ["3"]}, {"input": "2 5 8 9 4\r\n", "output": ["16"]}, {"input": "9 1 3 8 2\r\n", "output": ["43"]}, {"input": "17 42 22 64 14\r\n", "output": ["374"]}, {"input": "20 5 82 93 50\r\n", "output": ["1790"]}, {"input": "5 6 2 3 50\r\n", "output": ["10"]}, {"input": "100 120 1 2 525\r\n", "output": ["100"]}, {"input": "6 3 7 9 1\r\n", "output": ["43"]}, {"input": "1686604166 451776 534914 885584 885904\r\n", "output": ["902191487931356"]}, {"input": "1 4 4 6 7\r\n", "output": ["4"]}, {"input": "5 67 61 68 83\r\n", "output": ["305"]}, {"input": "15 5 11 20 15\r\n", "output": ["195"]}, {"input": "15 2 9 15 13\r\n", "output": ["213"]}, {"input": "17 15 9 17 19\r\n", "output": ["169"]}, {"input": "1 17 9 10 6\r\n", "output": ["9"]}, {"input": "2 10 10 16 8\r\n", "output": ["20"]}, {"input": "18419 54 591 791 797\r\n", "output": ["11157406"]}, {"input": "10 2 1 2 18\r\n", "output": ["18"]}, {"input": "100 120 1 2 528\r\n", "output": ["100"]}, {"input": "5 17 2 3 8\r\n", "output": ["10"]}, {"input": "63793 358 368 369 367\r\n", "output": ["23539259"]}, {"input": "7 2 4 16 19\r\n", "output": ["78"]}, {"input": "3 8 3 5 19\r\n", "output": ["9"]}, {"input": "17 7 6 9 13\r\n", "output": ["124"]}, {"input": "14 3 14 16 5\r\n", "output": ["215"]}, {"input": "2000002 1000000 1 3 1000000\r\n", "output": ["3000006"]}, {"input": "2 1 3 8 14\r\n", "output": ["11"]}, {"input": "18 6 8 9 7\r\n", "output": ["156"]}, {"input": "10 20 10 20 7\r\n", "output": ["100"]}, {"input": "12 7 8 18 1\r\n", "output": ["97"]}, {"input": "16 1 3 20 2\r\n", "output": ["78"]}, {"input": "5 1000 1 4 10\r\n", "output": ["5"]}] | 100 | 100 | 100 | [{'input': '1 1 1 2 1\r\n', 'output': ['1']}, {'input': '100 120 1 2 507\r\n', 'output': ['100']}, {'input': '2 100 1 2 10\r\n', 'output': ['2']}, {'input': '5 2 1 4 10\r\n', 'output': ['14']}, {'input': '1 10 10 11 12\r\n', 'output': ['10']}] | [{'input': '5 6 1 2 10000\r\n', 'output': ['5']}, {'input': '28 32 37 38 180\r\n', 'output': ['1036']}, {'input': '9 1 1 2 1\r\n', 'output': ['17']}, {'input': '1 10 10 11 12\r\n', 'output': ['10']}, {'input': '100 125 1 2 300\r\n', 'output': ['100']}] | [{'input': '100 120 1 2 525\r\n', 'output': ['100']}, {'input': '2 3 1 4 10\r\n', 'output': ['2']}, {'input': '100 120 1 2 513\r\n', 'output': ['100']}, {'input': '2 100 1 2 10\r\n', 'output': ['2']}, {'input': '11 12 3 4 5\r\n', 'output': ['33']}] | [{'input': '100 5 20 21 50\r\n', 'output': ['2095']}, {'input': '1 17 9 10 6\r\n', 'output': ['9']}, {'input': '100 120 1 2 306\r\n', 'output': ['100']}, {'input': '5 10 1 2000 100000\r\n', 'output': ['5']}, {'input': '5 17 2 3 8\r\n', 'output': ['10']}] | [{'input': '2 1 3 8 14\r\n', 'output': ['11']}, {'input': '15 5 11 20 15\r\n', 'output': ['195']}, {'input': '501 47 789 798 250\r\n', 'output': ['397789']}, {'input': '100 5 20 21 50\r\n', 'output': ['2095']}, {'input': '100 120 1 2 516\r\n', 'output': ['100']}] | 100 | 100 | 100 | 100 | 100 | 81.82 | 81.82 | 54.55 | 81.82 | 100 | 66.67 | 66.67 | 16.67 | 66.67 | 100 | 28 | 100 | 80.002 | 63.336 |
["5 3 2\nto head\n0001001", "3 2 1\nto tail\n0001"] | The first line contains three integers n, m and k. They represent the number of wagons in the train, the stowaway's and the controller's initial positions correspondingly (2ββ€βnββ€β50, 1ββ€βm,βkββ€βn, mββ βk). The second line contains the direction in which a controller moves. "to head" means that the controller moves to the train's head and "to tail" means that the controller moves to its tail. It is guaranteed that in the direction in which the controller is moving, there is at least one wagon. Wagon 1 is the head, and wagon n is the tail. The third line has the length from 1 to 200 and consists of symbols "0" and "1". The i-th symbol contains information about the train's state at the i-th minute of time. "0" means that in this very minute the train moves and "1" means that the train in this very minute stands idle. The last symbol of the third line is always "1" β that's the terminal train station. | 2222ce16926fdc697384add731819f75 | #include <stdio.h>
int main() {
int n,m,k;
int i;
char a[3],b[5];
char c[201];
char *p;
// 1-> -1<-
int d;
scanf("%d %d %d", &n, &m, &k);
scanf("%s %s",a,b);
scanf("%s", c);
if(b[0] == 'h')
d = -1;
else
d = 1;
for(p=c,i=1; *p!='\0'; p++,i++) {
if(*p=='0') {
// move stowaway
if(d == 1 && m-k==1 && m!=n){
m += 1;
}else if(d == -1 && k-m==1 && m!=1){
m -= 1;
}
// move controller
k += d;
if(k == 1)
d = 1;
if(k == n)
d = -1;
} else {
// move controller
k += d;
if(k == 1)
d = 1;
if(k == n)
d = -1;
// move stowaway
if(d == 1) {
if(n==2)
m = 2;
else if(k==1)
m = k+2;
else
m = k-1;
}else{
if(n==2)
m = 1;
else if(k!=n)
m = k+1;
else
m = k-2;
}
}
if(k == m){
printf("Controller %d\n",i);
return 0;
}
}
printf("Stowaway\n");
return 0;
}
| ["Stowaway", "Controller 2"] | C | null | If the stowaway wins, print "Stowaway" without quotes. Otherwise, print "Controller" again without quotes, then, separated by a space, print the number of a minute, at which the stowaway will be caught. | A stowaway and a controller play the following game. The train is represented by n wagons which are numbered with positive integers from 1 to n from the head to the tail. The stowaway and the controller are initially in some two different wagons. Every minute the train can be in one of two conditions β moving or idle. Every minute the players move.The controller's move is as follows. The controller has the movement direction β to the train's head or to its tail. During a move the controller moves to the neighbouring wagon correspondingly to its movement direction. If at the end of his move the controller enters the 1-st or the n-th wagon, that he changes the direction of his movement into the other one. In other words, the controller cyclically goes from the train's head to its tail and back again during all the time of a game, shifting during each move by one wagon. Note, that the controller always have exactly one possible move.The stowaway's move depends from the state of the train. If the train is moving, then the stowaway can shift to one of neighbouring wagons or he can stay where he is without moving. If the train is at a station and is idle, then the stowaway leaves the train (i.e. he is now not present in any train wagon) and then, if it is not the terminal train station, he enters the train again into any of n wagons (not necessarily into the one he's just left and not necessarily into the neighbouring one). If the train is idle for several minutes then each such minute the stowaway leaves the train and enters it back.Let's determine the order of the players' moves. If at the given minute the train is moving, then first the stowaway moves and then the controller does. If at this minute the train is idle, then first the stowaway leaves the train, then the controller moves and then the stowaway enters the train.If at some point in time the stowaway and the controller happen to be in one wagon, then the controller wins: he makes the stowaway pay fine. If after a while the stowaway reaches the terminal train station, then the stowaway wins: he simply leaves the station during his move and never returns there again.At any moment of time the players know each other's positions. The players play in the optimal way. Specifically, if the controller wins, then the stowaway plays so as to lose as late as possible. As all the possible moves for the controller are determined uniquely, then he is considered to play optimally always. Determine the winner. | [{"input": "5 3 2\r\nto head\r\n0001001\r\n", "output": ["Stowaway"]}, {"input": "3 2 1\r\nto tail\r\n0001\r\n", "output": ["Controller 2"]}, {"input": "4 2 1\r\nto tail\r\n1000001\r\n", "output": ["Controller 6"]}, {"input": "2 1 2\r\nto head\r\n111111\r\n", "output": ["Stowaway"]}, {"input": "4 1 4\r\nto head\r\n010001\r\n", "output": ["Stowaway"]}, {"input": "10 2 1\r\nto tail\r\n000000001\r\n", "output": ["Stowaway"]}, {"input": "5 5 3\r\nto tail\r\n01010000000001\r\n", "output": ["Controller 10"]}, {"input": "4 3 1\r\nto tail\r\n1000001001101\r\n", "output": ["Controller 6"]}, {"input": "4 1 3\r\nto head\r\n011000011000001\r\n", "output": ["Controller 14"]}, {"input": "20 13 9\r\nto head\r\n1111111111111111111111111111111111111111\r\n", "output": ["Stowaway"]}, {"input": "2 1 2\r\nto head\r\n1101\r\n", "output": ["Controller 3"]}, {"input": "2 2 1\r\nto tail\r\n1101\r\n", "output": ["Controller 3"]}, {"input": "2 1 2\r\nto head\r\n01\r\n", "output": ["Controller 1"]}, {"input": "2 2 1\r\nto tail\r\n01\r\n", "output": ["Controller 1"]}, {"input": "5 4 2\r\nto tail\r\n1\r\n", "output": ["Stowaway"]}, {"input": "8 8 7\r\nto head\r\n0000000000001\r\n", "output": ["Stowaway"]}, {"input": "8 8 7\r\nto head\r\n0000000000000100101000110101011\r\n", "output": ["Controller 13"]}, {"input": "10 3 8\r\nto head\r\n01\r\n", "output": ["Stowaway"]}, {"input": "5 1 4\r\nto head\r\n1000000000001\r\n", "output": ["Controller 7"]}, {"input": "5 1 3\r\nto head\r\n1000000000001\r\n", "output": ["Controller 6"]}, {"input": "3 3 1\r\nto tail\r\n1001000001\r\n", "output": ["Controller 6"]}, {"input": "4 3 1\r\nto tail\r\n00011110000000010001\r\n", "output": ["Controller 3"]}, {"input": "5 3 4\r\nto tail\r\n0001000000101000010010010000100110011\r\n", "output": ["Controller 9"]}, {"input": "6 4 5\r\nto tail\r\n0010000101101011001000000100111101101001010011001\r\n", "output": ["Stowaway"]}, {"input": "7 1 7\r\nto head\r\n011001001000100000000000000100001100000001100000000010000010011\r\n", "output": ["Controller 24"]}, {"input": "8 5 6\r\nto tail\r\n01110101111111111111111111001111111011011111111111101111111111011111101\r\n", "output": ["Stowaway"]}, {"input": "9 7 2\r\nto head\r\n1000100010110000101010010000000000010010000010100000001001000000001000000101100000000001\r\n", "output": ["Controller 33"]}, {"input": "10 8 2\r\nto tail\r\n0000000000000001000000000000000000000000001000000000010000000000001000000000000000100000000000000001\r\n", "output": ["Controller 8"]}, {"input": "10 1 8\r\nto tail\r\n0000000000000000001000010000000001000001000000010000000000000000010010001000001000110010000001010011\r\n", "output": ["Controller 11"]}, {"input": "10 3 6\r\nto head\r\n0000001001010100000001010001000110001100011100000100100001100000001100000000000010000001000100100011\r\n", "output": ["Controller 5"]}, {"input": "13 9 8\r\nto tail\r\n000000000000000000000000000010011100000000000100100000000010000100000000000000000000000000000000000000010000011\r\n", "output": ["Controller 5"]}, {"input": "17 14 17\r\nto head\r\n0000001010000000000000100011000000100000001010000001011000000000001000100000000010100000010001000000000000000100000000000001\r\n", "output": ["Stowaway"]}, {"input": "20 15 7\r\nto head\r\n10011111001101010111101110101101101111011110111101001000101111011111011001110010001111111111111101111101011011111010011111111101111011111111\r\n", "output": ["Stowaway"]}, {"input": "26 10 11\r\nto head\r\n0000000001001000100000010000110000000011100001000010000000000010000000000000110100000001000000010000110011000000100000000010001100010000000100001110001\r\n", "output": ["Stowaway"]}, {"input": "31 7 15\r\nto tail\r\n0010000000000000100000010000010000100000000000000000000001000001100100000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000100001\r\n", "output": ["Controller 106"]}, {"input": "38 7 18\r\nto tail\r\n00000000000000000000000000000000000000000000000000000000000000000000000000000001001000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\r\n", "output": ["Controller 57"]}, {"input": "42 24 17\r\nto head\r\n00000000000000000000100010000000000000000000001000100000000000000000001000000000000010000100100000100000001000000010010000000000101000000000000000010000000000000000000000000011001\r\n", "output": ["Stowaway"]}, {"input": "45 21 37\r\nto tail\r\n00000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\r\n", "output": ["Controller 96"]}, {"input": "49 44 14\r\nto head\r\n0000000000000000000000000000000000100000100000000000000000000000010000000000001000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000111001\r\n", "output": ["Controller 157"]}, {"input": "50 4 12\r\nto tail\r\n00000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000001000100000000000000000000000000000000000000010000000010000000000000000000000000000000000000000001\r\n", "output": ["Stowaway"]}, {"input": "50 9 39\r\nto tail\r\n00000000000000001000000000000000000000000000000000000000000010000000100000000000000001000100000000000000010000000001000000000000000000000000010000000000000000000000000000000000001000000000000000000101\r\n", "output": ["Stowaway"]}, {"input": "50 43 15\r\nto tail\r\n00000000000001000000000000000000000000001000000000000000000000001010000000000000000000000010000001000000000000100000000000000000000000000000100000000100000000000001000000000011000000101000010000000001\r\n", "output": ["Stowaway"]}, {"input": "2 2 1\r\nto tail\r\n11111101111111011111111111111111111111111111110111111110111111111101111111111001111110111111101011101110110011111011111011101011111111101111111110111111011111111111111111110111111111111111101111101111\r\n", "output": ["Controller 7"]}, {"input": "2 2 1\r\nto tail\r\n10111111111111111110111011111111111111111111111111111110111111111110111111101111111111111111111111011111111111111011111111110111111101111111111101111111111111111101111111111111111111111111111001111111\r\n", "output": ["Controller 2"]}, {"input": "3 1 3\r\nto head\r\n11111111101111101111011011001011101100101101111111111011011111110011110101010111111101101010010111110110111111011111111111111111111110011111011011101110111111111111100111001110111110111011100111111111\r\n", "output": ["Controller 28"]}, {"input": "3 1 3\r\nto head\r\n10111111111111111011110110111111110111011111111111111111110101111111111111101111111111011110111110111111111111111111111111111110111111111111111110001011101111101110111111111111111111110101111111110011\r\n", "output": ["Controller 148"]}, {"input": "4 2 4\r\nto head\r\n01101111110010111111111111011110111101000011111110111100111010111110111011010111010110011101101010111100000011001011011101101111010111101001001011101111111111100011110110011010111010111011001011111001\r\n", "output": ["Controller 42"]}, {"input": "50 50 14\r\nto head\r\n11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\r\n", "output": ["Stowaway"]}, {"input": "50 42 13\r\nto head\r\n00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\r\n", "output": ["Controller 61"]}, {"input": "50 43 39\r\nto head\r\n01100111001110101111000001011111111100101101011010010001000001110001010011001010010100101100110011010011110110011111011101001111110001111001001100011110000111100100010001000011001001100000000010001111\r\n", "output": ["Stowaway"]}, {"input": "3 3 2\r\nto tail\r\n0001\r\n", "output": ["Controller 1"]}, {"input": "3 2 3\r\nto head\r\n0000000000000000001\r\n", "output": ["Controller 2"]}] | 100 | 100 | 100 | [{'input': '3 2 3\r\nto head\r\n0000000000000000001\r\n', 'output': ['Controller 2']}, {'input': '13 9 8\r\nto tail\r\n000000000000000000000000000010011100000000000100100000000010000100000000000000000000000000000000000000010000011\r\n', 'output': ['Controller 5']}, {'input': '31 7 15\r\nto tail\r\n0010000000000000100000010000010000100000000000000000000001000001100100000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000100001\r\n', 'output': ['Controller 106']}, {'input': '50 50 14\r\nto head\r\n11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\r\n', 'output': ['Stowaway']}, {'input': '3 3 1\r\nto tail\r\n1001000001\r\n', 'output': ['Controller 6']}] | [{'input': '5 1 4\r\nto head\r\n1000000000001\r\n', 'output': ['Controller 7']}, {'input': '3 1 3\r\nto head\r\n11111111101111101111011011001011101100101101111111111011011111110011110101010111111101101010010111110110111111011111111111111111111110011111011011101110111111111111100111001110111110111011100111111111\r\n', 'output': ['Controller 28']}, {'input': '4 1 4\r\nto head\r\n010001\r\n', 'output': ['Stowaway']}, {'input': '2 1 2\r\nto head\r\n01\r\n', 'output': ['Controller 1']}, {'input': '50 43 39\r\nto head\r\n01100111001110101111000001011111111100101101011010010001000001110001010011001010010100101100110011010011110110011111011101001111110001111001001100011110000111100100010001000011001001100000000010001111\r\n', 'output': ['Stowaway']}] | [{'input': '50 9 39\r\nto tail\r\n00000000000000001000000000000000000000000000000000000000000010000000100000000000000001000100000000000000010000000001000000000000000000000000010000000000000000000000000000000000001000000000000000000101\r\n', 'output': ['Stowaway']}, {'input': '2 2 1\r\nto tail\r\n1101\r\n', 'output': ['Controller 3']}, {'input': '10 2 1\r\nto tail\r\n000000001\r\n', 'output': ['Stowaway']}, {'input': '8 8 7\r\nto head\r\n0000000000000100101000110101011\r\n', 'output': ['Controller 13']}, {'input': '42 24 17\r\nto head\r\n00000000000000000000100010000000000000000000001000100000000000000000001000000000000010000100100000100000001000000010010000000000101000000000000000010000000000000000000000000011001\r\n', 'output': ['Stowaway']}] | [{'input': '42 24 17\r\nto head\r\n00000000000000000000100010000000000000000000001000100000000000000000001000000000000010000100100000100000001000000010010000000000101000000000000000010000000000000000000000000011001\r\n', 'output': ['Stowaway']}, {'input': '2 2 1\r\nto tail\r\n10111111111111111110111011111111111111111111111111111110111111111110111111101111111111111111111111011111111111111011111111110111111101111111111101111111111111111101111111111111111111111111111001111111\r\n', 'output': ['Controller 2']}, {'input': '10 1 8\r\nto tail\r\n0000000000000000001000010000000001000001000000010000000000000000010010001000001000110010000001010011\r\n', 'output': ['Controller 11']}, {'input': '50 43 39\r\nto head\r\n01100111001110101111000001011111111100101101011010010001000001110001010011001010010100101100110011010011110110011111011101001111110001111001001100011110000111100100010001000011001001100000000010001111\r\n', 'output': ['Stowaway']}, {'input': '50 50 14\r\nto head\r\n11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\r\n', 'output': ['Stowaway']}] | [{'input': '10 3 6\r\nto head\r\n0000001001010100000001010001000110001100011100000100100001100000001100000000000010000001000100100011\r\n', 'output': ['Controller 5']}, {'input': '4 1 4\r\nto head\r\n010001\r\n', 'output': ['Stowaway']}, {'input': '5 3 2\r\nto head\r\n0001001\r\n', 'output': ['Stowaway']}, {'input': '6 4 5\r\nto tail\r\n0010000101101011001000000100111101101001010011001\r\n', 'output': ['Stowaway']}, {'input': '10 2 1\r\nto tail\r\n000000001\r\n', 'output': ['Stowaway']}] | 100 | 100 | 100 | 100 | 100 | 94.87 | 92.31 | 97.44 | 94.87 | 94.87 | 94.74 | 92.11 | 94.74 | 89.47 | 92.11 | 29 | 100 | 94.872 | 92.634 |
["1 1 1", "1 2 2", "1 3 5", "6 2 9"] | The first and only line of input contains three space-separated integers a, b and c (1ββ€βa,βb,βcββ€β5β000)Β β the number of islands in the red, blue and purple clusters, respectively. | b6dc5533fbf285d5ef4cf60ef6300383 | #include <stdio.h>
long long dp[5001][5001],a,b,c;
int main()
{
scanf("%I64d%I64d%I64d",&a,&b,&c);
for(int i=0;i<=5000;i++) dp[i][0]=dp[0][i]=1;
for(int i=1;i<=5000;i++)
for(int j=1;j<=5000;j++)
dp[i][j]=(dp[i-1][j]+(dp[i-1][j-1]*j)%998244353)%998244353;
printf("%I64d\n",(dp[a][b]*dp[a][c])%998244353*dp[b][c]%998244353);
} | ["8", "63", "3264", "813023575"] | C | NoteIn the first example, there are 3 bridges that can possibly be built, and no setup of bridges violates the restrictions. Thus the answer is 23β=β8.In the second example, the upper two structures in the figure below are instances of valid ones, while the lower two are invalid due to the blue and purple clusters, respectively. | Output one line containing an integerΒ β the number of different ways to build bridges, modulo 998β244β353. | β This is not playing but duty as allies of justice, Nii-chan!β Not allies but justice itself, Onii-chan!With hands joined, go everywhere at a speed faster than our thoughts! This time, the Fire SistersΒ β Karen and TsukihiΒ β is heading for somewhere they've never reachedΒ β water-surrounded islands!There are three clusters of islands, conveniently coloured red, blue and purple. The clusters consist of a, b and c distinct islands respectively.Bridges have been built between some (possibly all or none) of the islands. A bridge bidirectionally connects two different islands and has length 1. For any two islands of the same colour, either they shouldn't be reached from each other through bridges, or the shortest distance between them is at least 3, apparently in order to prevent oddities from spreading quickly inside a cluster.The Fire Sisters are ready for the unknown, but they'd also like to test your courage. And you're here to figure out the number of different ways to build all bridges under the constraints, and give the answer modulo 998β244β353. Two ways are considered different if a pair of islands exist, such that there's a bridge between them in one of them, but not in the other. | [{"input": "1 1 1\r\n", "output": ["8"]}, {"input": "1 2 2\r\n", "output": ["63"]}, {"input": "1 3 5\r\n", "output": ["3264"]}, {"input": "6 2 9\r\n", "output": ["813023575"]}, {"input": "7 3 7\r\n", "output": ["807577560"]}, {"input": "135 14 39\r\n", "output": ["414849507"]}, {"input": "5000 5000 5000\r\n", "output": ["986778560"]}, {"input": "2 1 1\r\n", "output": ["18"]}, {"input": "1 1 3\r\n", "output": ["32"]}, {"input": "1 2 3\r\n", "output": ["156"]}, {"input": "4 1 2\r\n", "output": ["315"]}, {"input": "5 9 4\r\n", "output": ["661093467"]}, {"input": "4 2 5\r\n", "output": ["326151"]}, {"input": "9 4 10\r\n", "output": ["391175867"]}, {"input": "16 8 29\r\n", "output": ["349763770"]}, {"input": "17 46 45\r\n", "output": ["518654435"]}, {"input": "28 47 1\r\n", "output": ["517406193"]}, {"input": "94 87 10\r\n", "output": ["846321893"]}, {"input": "84 29 61\r\n", "output": ["391253501"]}, {"input": "179 856 377\r\n", "output": ["518957210"]}, {"input": "1925 1009 273\r\n", "output": ["207866159"]}, {"input": "1171 2989 2853\r\n", "output": ["234725427"]}, {"input": "3238 2923 4661\r\n", "output": ["636587126"]}, {"input": "1158 506 4676\r\n", "output": ["6109065"]}, {"input": "4539 2805 2702\r\n", "output": ["356944655"]}, {"input": "4756 775 3187\r\n", "output": ["56242066"]}, {"input": "4998 4998 4998\r\n", "output": ["259368717"]}, {"input": "4996 1 5000\r\n", "output": ["196902859"]}, {"input": "2048 4096 1024\r\n", "output": ["445542375"]}, {"input": "5000 1 1\r\n", "output": ["50020002"]}] | 100 | 100 | 100 | [{'input': '16 8 29\r\n', 'output': ['349763770']}, {'input': '2048 4096 1024\r\n', 'output': ['445542375']}, {'input': '28 47 1\r\n', 'output': ['517406193']}, {'input': '1171 2989 2853\r\n', 'output': ['234725427']}, {'input': '4998 4998 4998\r\n', 'output': ['259368717']}] | [{'input': '1158 506 4676\r\n', 'output': ['6109065']}, {'input': '179 856 377\r\n', 'output': ['518957210']}, {'input': '4756 775 3187\r\n', 'output': ['56242066']}, {'input': '4996 1 5000\r\n', 'output': ['196902859']}, {'input': '1 1 1\r\n', 'output': ['8']}] | [{'input': '1171 2989 2853\r\n', 'output': ['234725427']}, {'input': '7 3 7\r\n', 'output': ['807577560']}, {'input': '28 47 1\r\n', 'output': ['517406193']}, {'input': '4 2 5\r\n', 'output': ['326151']}, {'input': '3238 2923 4661\r\n', 'output': ['636587126']}] | [{'input': '1 2 2\r\n', 'output': ['63']}, {'input': '7 3 7\r\n', 'output': ['807577560']}, {'input': '4998 4998 4998\r\n', 'output': ['259368717']}, {'input': '4 2 5\r\n', 'output': ['326151']}, {'input': '135 14 39\r\n', 'output': ['414849507']}] | [{'input': '1158 506 4676\r\n', 'output': ['6109065']}, {'input': '84 29 61\r\n', 'output': ['391253501']}, {'input': '4539 2805 2702\r\n', 'output': ['356944655']}, {'input': '1 1 1\r\n', 'output': ['8']}, {'input': '4756 775 3187\r\n', 'output': ['56242066']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 30 | 100 | 100 | 100 |
["a1\nb2", "a8\nd4"] | The first input line contains the description of the rook's position on the board. This description is a line which is 2 in length. Its first symbol is a lower-case Latin letter from a to h, and its second symbol is a number from 1 to 8. The second line contains the description of the knight's position in a similar way. It is guaranteed that their positions do not coincide. | 073023c6b72ce923df2afd6130719cfc | #include<stdio.h>
int board[191][119];
int main(){
int a,b,c,d,e;
char input[50];
char input1[50];
int i; int cnt=0;
scanf("%s%s",input,input1);
board[input[0]-'a'][(input[1]-'0')-1]=1;
board[input1[0]-'a'][(input1[1]-'0')-1]=1;
int rook=input[0]-'a'; int rook1=(input[1]-'0')-1;
for(i=0;i<8;i++){
for(a=0;a<8;a++){
if(board[i][a] != 1 && board[i+2][a+1] != 1 && board[i+2][a-1] != 1 && board[i-2][a+1] != 1 && board[i-2][a-1] != 1 && board[i-1][a+2] != 1 && board[i+1][a+2] != 1 && board[i-1][a-2] != 1 && board[i+1][a-2] != 1 && i!=rook && a!=rook1){
cnt++;
board[i][a]=2;
}
}
}
printf("%d",cnt);
}
| ["44", "38"] | C | null | Print a single number which is the required number of ways. | Two chess pieces, a rook and a knight, stand on a standard chessboard 8βΓβ8 in size. The positions in which they are situated are known. It is guaranteed that none of them beats the other one.Your task is to find the number of ways to place another knight on the board so that none of the three pieces on the board beat another one. A new piece can only be placed on an empty square. | [{"input": "a1\r\nb2\r\n", "output": ["44"]}, {"input": "a8\r\nd4\r\n", "output": ["38"]}, {"input": "a8\r\nf1\r\n", "output": ["42"]}, {"input": "f8\r\nh3\r\n", "output": ["42"]}, {"input": "g8\r\nb7\r\n", "output": ["42"]}, {"input": "h1\r\ng5\r\n", "output": ["42"]}, {"input": "c6\r\nb5\r\n", "output": ["39"]}, {"input": "c1\r\nd2\r\n", "output": ["42"]}, {"input": "g3\r\nh4\r\n", "output": ["42"]}, {"input": "e3\r\ng5\r\n", "output": ["38"]}, {"input": "f8\r\na3\r\n", "output": ["40"]}, {"input": "a2\r\nh8\r\n", "output": ["43"]}, {"input": "a3\r\nc5\r\n", "output": ["40"]}, {"input": "g1\r\ne6\r\n", "output": ["39"]}, {"input": "e1\r\na7\r\n", "output": ["41"]}, {"input": "b5\r\nc1\r\n", "output": ["39"]}, {"input": "b2\r\ne1\r\n", "output": ["43"]}, {"input": "h8\r\ng2\r\n", "output": ["43"]}, {"input": "a3\r\nd6\r\n", "output": ["38"]}, {"input": "g6\r\nb7\r\n", "output": ["39"]}, {"input": "c8\r\ne6\r\n", "output": ["40"]}, {"input": "e6\r\nf2\r\n", "output": ["35"]}, {"input": "b6\r\nd8\r\n", "output": ["41"]}, {"input": "a4\r\nd1\r\n", "output": ["42"]}, {"input": "b5\r\nh8\r\n", "output": ["40"]}, {"input": "h6\r\na1\r\n", "output": ["42"]}, {"input": "c3\r\na8\r\n", "output": ["39"]}, {"input": "g5\r\nd2\r\n", "output": ["38"]}, {"input": "b6\r\ng7\r\n", "output": ["39"]}, {"input": "h6\r\na8\r\n", "output": ["43"]}, {"input": "a8\r\nb7\r\n", "output": ["44"]}, {"input": "c8\r\nb2\r\n", "output": ["41"]}, {"input": "e4\r\nc1\r\n", "output": ["37"]}, {"input": "f1\r\nc3\r\n", "output": ["38"]}, {"input": "a3\r\nc8\r\n", "output": ["41"]}, {"input": "e8\r\nb6\r\n", "output": ["40"]}, {"input": "a1\r\nb7\r\n", "output": ["43"]}, {"input": "g2\r\nb7\r\n", "output": ["40"]}, {"input": "e1\r\nd6\r\n", "output": ["38"]}, {"input": "e5\r\nh6\r\n", "output": ["39"]}] | 100 | 100 | 100 | [{'input': 'e1\r\nd6\r\n', 'output': ['38']}, {'input': 'h8\r\ng2\r\n', 'output': ['43']}, {'input': 'e1\r\na7\r\n', 'output': ['41']}, {'input': 'a8\r\nb7\r\n', 'output': ['44']}, {'input': 'g1\r\ne6\r\n', 'output': ['39']}] | [{'input': 'a3\r\nc8\r\n', 'output': ['41']}, {'input': 'a1\r\nb2\r\n', 'output': ['44']}, {'input': 'a1\r\nb7\r\n', 'output': ['43']}, {'input': 'g2\r\nb7\r\n', 'output': ['40']}, {'input': 'a3\r\nd6\r\n', 'output': ['38']}] | [{'input': 'b5\r\nh8\r\n', 'output': ['40']}, {'input': 'h6\r\na8\r\n', 'output': ['43']}, {'input': 'a1\r\nb2\r\n', 'output': ['44']}, {'input': 'e1\r\nd6\r\n', 'output': ['38']}, {'input': 'h1\r\ng5\r\n', 'output': ['42']}] | [{'input': 'g2\r\nb7\r\n', 'output': ['40']}, {'input': 'e6\r\nf2\r\n', 'output': ['35']}, {'input': 'h6\r\na1\r\n', 'output': ['42']}, {'input': 'b5\r\nc1\r\n', 'output': ['39']}, {'input': 'f8\r\na3\r\n', 'output': ['40']}] | [{'input': 'c6\r\nb5\r\n', 'output': ['39']}, {'input': 'a8\r\nf1\r\n', 'output': ['42']}, {'input': 'b5\r\nc1\r\n', 'output': ['39']}, {'input': 'g8\r\nb7\r\n', 'output': ['42']}, {'input': 'f8\r\nh3\r\n', 'output': ['42']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 31 | 100 | 100 | 100 |
["1 1 1", "3 1 4"] | The first line will contain three integers integer k,βpa,βpb (1ββ€βkββ€β1β000, 1ββ€βpa,βpbββ€β1β000β000). | 0dc9f5d75143a2bc744480de859188b4 | #include <stdio.h>
#define MOD 1000000007
int K;
long long PA,PB,ans;
long long INV1,INV2;
long long f[1010][2010];
long long power(long long a,int b)
{
long long y = 1;
for(;b;b>>=1)
{
if(b&1) y = y * a % MOD;
a = a * a % MOD;
}
return y;
}
int main()
{
int i,j;
long long x,y;
scanf("%d%I64d%I64d",&K,&PA,&PB);
INV1 = power(PA+PB,MOD-2);
INV2 = power(PB,MOD-2);
f[1][0] = 1;
for(i=1;i<=K;i++) for(j=(i==1);j<=2*K;j++)
{
if(j < K) f[i][j] = f[i-1][j] * PA % MOD * INV1 % MOD;
if(j >= i && j-i < K) f[i][j] = (f[i][j] + f[i][j-i] * PB % MOD * INV1) % MOD;
}
for(i=1;i<K;i++) for(j=K;j<=2*K;j++) ans = (ans + j*f[i][j]) % MOD;
for(i=0;i<K;i++) ans = (ans + (PA*INV2 + K+i) % MOD * f[K][i]) % MOD;
printf("%I64d\n",ans);
return 0;
} | ["2", "370000006"] | C | NoteThe first sample, we will keep appending to our sequence until we get the subsequence 'ab' at least once. For instance, we get the sequence 'ab' with probability 1/4, 'bbab' with probability 1/16, and 'aab' with probability 1/8. Note, it's impossible for us to end with a sequence like 'aabab', since we would have stopped our algorithm once we had the prefix 'aab'. The expected amount of times that 'ab' will occur across all valid sequences is 2. For the second sample, the answer is equal to . | Print a single integer, the answer to the problem. | You are given three integers k, pa and pb.You will construct a sequence with the following algorithm: Initially, start with the empty sequence. Each second, you do the following. With probability paβ/β(paβ+βpb), add 'a' to the end of the sequence. Otherwise (with probability pbβ/β(paβ+βpb)), add 'b' to the end of the sequence.You stop once there are at least k subsequences that form 'ab'. Determine the expected number of times 'ab' is a subsequence in the resulting sequence. It can be shown that this can be represented by Pβ/βQ, where P and Q are coprime integers, and . Print the value of . | [{"input": "1 1 1\r\n", "output": ["2"]}, {"input": "3 1 4\r\n", "output": ["370000006"]}, {"input": "1000 123456 654321\r\n", "output": ["977760856"]}, {"input": "305 337309 378395\r\n", "output": ["174667130"]}, {"input": "108 531040 908573\r\n", "output": ["145579983"]}, {"input": "575 39377 68346\r\n", "output": ["899189133"]}, {"input": "66 199449 266025\r\n", "output": ["27912582"]}, {"input": "781 817338 452871\r\n", "output": ["711597307"]}, {"input": "99 534023 117289\r\n", "output": ["29694885"]}, {"input": "156 78149 46740\r\n", "output": ["114906561"]}, {"input": "57 339480 774350\r\n", "output": ["622654301"]}, {"input": "270 967166 795005\r\n", "output": ["530539317"]}, {"input": "628 446579 365440\r\n", "output": ["214808787"]}, {"input": "97 119368 2062\r\n", "output": ["2436614"]}, {"input": "757 869978 224540\r\n", "output": ["921904658"]}, {"input": "892 777143 664073\r\n", "output": ["527873013"]}, {"input": "177 2501 570142\r\n", "output": ["779148936"]}, {"input": "908 879494 944888\r\n", "output": ["114377456"]}, {"input": "734 32585 49636\r\n", "output": ["684730644"]}, {"input": "38 592277 400426\r\n", "output": ["499077928"]}, {"input": "192 42070 61266\r\n", "output": ["904814024"]}, {"input": "78 535199 331023\r\n", "output": ["684367478"]}, {"input": "842 171735 282219\r\n", "output": ["948183028"]}, {"input": "1000 1000000 1\r\n", "output": ["478180868"]}] | 100 | 100 | 100 | [{'input': '57 339480 774350\r\n', 'output': ['622654301']}, {'input': '270 967166 795005\r\n', 'output': ['530539317']}, {'input': '97 119368 2062\r\n', 'output': ['2436614']}, {'input': '305 337309 378395\r\n', 'output': ['174667130']}, {'input': '3 1 4\r\n', 'output': ['370000006']}] | [{'input': '575 39377 68346\r\n', 'output': ['899189133']}, {'input': '270 967166 795005\r\n', 'output': ['530539317']}, {'input': '177 2501 570142\r\n', 'output': ['779148936']}, {'input': '305 337309 378395\r\n', 'output': ['174667130']}, {'input': '3 1 4\r\n', 'output': ['370000006']}] | [{'input': '781 817338 452871\r\n', 'output': ['711597307']}, {'input': '192 42070 61266\r\n', 'output': ['904814024']}, {'input': '892 777143 664073\r\n', 'output': ['527873013']}, {'input': '270 967166 795005\r\n', 'output': ['530539317']}, {'input': '3 1 4\r\n', 'output': ['370000006']}] | [{'input': '757 869978 224540\r\n', 'output': ['921904658']}, {'input': '3 1 4\r\n', 'output': ['370000006']}, {'input': '1000 1000000 1\r\n', 'output': ['478180868']}, {'input': '57 339480 774350\r\n', 'output': ['622654301']}, {'input': '97 119368 2062\r\n', 'output': ['2436614']}] | [{'input': '38 592277 400426\r\n', 'output': ['499077928']}, {'input': '305 337309 378395\r\n', 'output': ['174667130']}, {'input': '177 2501 570142\r\n', 'output': ['779148936']}, {'input': '781 817338 452871\r\n', 'output': ['711597307']}, {'input': '99 534023 117289\r\n', 'output': ['29694885']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 32 | 100 | 100 | 100 |
["10", "4", "3"] | The first and only line contains an integer n (1ββ€βnββ€β106) which represents the denomination of the most expensive coin. | 2fc946bb72f56b6d86eabfaf60f9fa63 | #include <stdio.h>
int main()
{
int i = 2, num;
scanf("%d", &num);
printf("%d ", num);
while(num > 1){
for(i = 2; i < num && num % i != 0; i++){}
num /= i;
printf("%d ", num);
}
return 0;
}
| ["10 5 1", "4 2 1", "3 1"] | C | null | Print the denominations of all the coins in the order of decreasing. The number of coins must be the largest possible (with the given denomination n of the most expensive coin). Also, the denomination of every coin must be divisible by the denomination of any cheaper coin. Naturally, the denominations of all the coins should be different. If there are several solutins to that problem, print any of them. | In Berland a money reform is being prepared. New coins are being introduced. After long economic calculations was decided that the most expensive coin should possess the denomination of exactly n Berland dollars. Also the following restriction has been introduced for comfort: the denomination of each coin should be divisible by the denomination of any cheaper coin. It is known that among all the possible variants the variant with the largest number of new coins will be chosen. Find this variant. Print in the order of decreasing of the coins' denominations. | [{"input": "10\r\n", "output": ["10 5 1", "10\r\n5\r\n1"]}, {"input": "4\r\n", "output": ["4\r\n2\r\n1", "4 2 1"]}, {"input": "3\r\n", "output": ["3 1", "3\r\n1"]}, {"input": "2\r\n", "output": ["2 1", "2\r\n1"]}, {"input": "5\r\n", "output": ["5\r\n1", "5 1"]}, {"input": "6\r\n", "output": ["6\r\n3\r\n1", "6 3 1"]}, {"input": "7\r\n", "output": ["7 1", "7\r\n1"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "8\r\n", "output": ["8\r\n4\r\n2\r\n1", "8 4 2 1"]}, {"input": "12\r\n", "output": ["12 6 3 1", "12\r\n6\r\n3\r\n1"]}, {"input": "100\r\n", "output": ["100 50 25 5 1", "100\r\n50\r\n25\r\n5\r\n1"]}, {"input": "1000\r\n", "output": ["1000 500 250 125 25 5 1", "1000\r\n500\r\n250\r\n125\r\n25\r\n5\r\n1"]}, {"input": "10000\r\n", "output": ["10000\r\n5000\r\n2500\r\n1250\r\n625\r\n125\r\n25\r\n5\r\n1", "10000 5000 2500 1250 625 125 25 5 1"]}, {"input": "100000\r\n", "output": ["100000 50000 25000 12500 6250 3125 625 125 25 5 1", "100000\r\n50000\r\n25000\r\n12500\r\n6250\r\n3125\r\n625\r\n125\r\n25\r\n5\r\n1"]}, {"input": "1000000\r\n", "output": ["1000000\r\n500000\r\n250000\r\n125000\r\n62500\r\n31250\r\n15625\r\n3125\r\n625\r\n125\r\n25\r\n5\r\n1", "1000000 500000 250000 125000 62500 31250 15625 3125 625 125 25 5 1"]}, {"input": "509149\r\n", "output": ["509149\r\n1", "509149 1"]}, {"input": "572877\r\n", "output": ["572877\r\n190959\r\n63653\r\n1201\r\n1", "572877 190959 63653 1201 1"]}, {"input": "152956\r\n", "output": ["152956 76478 38239 1", "152956\r\n76478\r\n38239\r\n1"]}, {"input": "733035\r\n", "output": ["733035 244345 48869 1", "733035\r\n244345\r\n48869\r\n1"]}, {"input": "313114\r\n", "output": ["313114 156557 3331 1", "313114\r\n156557\r\n3331\r\n1"]}, {"input": "893193\r\n", "output": ["893193\r\n297731\r\n42533\r\n1", "893193 297731 42533 1"]}, {"input": "473273\r\n", "output": ["473273\r\n2243\r\n1", "473273 2243 1"]}, {"input": "537000\r\n", "output": ["537000 268500 134250 67125 22375 4475 895 179 1", "537000\r\n268500\r\n134250\r\n67125\r\n22375\r\n4475\r\n895\r\n179\r\n1"]}, {"input": "117079\r\n", "output": ["117079 6887 97 1", "117079\r\n6887\r\n97\r\n1"]}, {"input": "784653\r\n", "output": ["784653 261551 9019 311 1", "784653\r\n261551\r\n9019\r\n311\r\n1"]}, {"input": "627251\r\n", "output": ["627251 1", "627251\r\n1"]}, {"input": "9\r\n", "output": ["9 3 1", "9\r\n3\r\n1"]}, {"input": "999999\r\n", "output": ["999999\r\n333333\r\n111111\r\n37037\r\n5291\r\n481\r\n37\r\n1", "999999 333333 111111 37037 5291 481 37 1"]}, {"input": "120\r\n", "output": ["120\r\n60\r\n30\r\n15\r\n5\r\n1", "120 60 30 15 5 1"]}, {"input": "720\r\n", "output": ["720\r\n360\r\n180\r\n90\r\n45\r\n15\r\n5\r\n1", "720 360 180 90 45 15 5 1"]}, {"input": "648\r\n", "output": ["648 324 162 81 27 9 3 1", "648\r\n324\r\n162\r\n81\r\n27\r\n9\r\n3\r\n1"]}, {"input": "2430\r\n", "output": ["2430\r\n1215\r\n405\r\n135\r\n45\r\n15\r\n5\r\n1", "2430 1215 405 135 45 15 5 1"]}, {"input": "119070\r\n", "output": ["119070\r\n59535\r\n19845\r\n6615\r\n2205\r\n735\r\n245\r\n49\r\n7\r\n1", "119070 59535 19845 6615 2205 735 245 49 7 1"]}, {"input": "15\r\n", "output": ["15\r\n5\r\n1", "15 5 1"]}, {"input": "21\r\n", "output": ["21 7 1", "21\r\n7\r\n1"]}, {"input": "25\r\n", "output": ["25 5 1", "25\r\n5\r\n1"]}, {"input": "524287\r\n", "output": ["524287\r\n1", "524287 1"]}, {"input": "600\r\n", "output": ["600\r\n300\r\n150\r\n75\r\n25\r\n5\r\n1", "600 300 150 75 25 5 1"]}, {"input": "36\r\n", "output": ["36 18 9 3 1", "36\r\n18\r\n9\r\n3\r\n1"]}, {"input": "20\r\n", "output": ["20 10 5 1", "20\r\n10\r\n5\r\n1"]}, {"input": "999983\r\n", "output": ["999983\r\n1", "999983 1"]}, {"input": "121\r\n", "output": ["121 11 1", "121\r\n11\r\n1"]}, {"input": "1331\r\n", "output": ["1331 121 11 1", "1331\r\n121\r\n11\r\n1"]}] | 100 | 100 | 100 | [{'input': '1000\r\n', 'output': ['1000 500 250 125 25 5 1', '1000\r\n500\r\n250\r\n125\r\n25\r\n5\r\n1']}, {'input': '3\r\n', 'output': ['3 1', '3\r\n1']}, {'input': '537000\r\n', 'output': ['537000 268500 134250 67125 22375 4475 895 179 1', '537000\r\n268500\r\n134250\r\n67125\r\n22375\r\n4475\r\n895\r\n179\r\n1']}, {'input': '784653\r\n', 'output': ['784653 261551 9019 311 1', '784653\r\n261551\r\n9019\r\n311\r\n1']}, {'input': '648\r\n', 'output': ['648 324 162 81 27 9 3 1', '648\r\n324\r\n162\r\n81\r\n27\r\n9\r\n3\r\n1']}] | [{'input': '120\r\n', 'output': ['120\r\n60\r\n30\r\n15\r\n5\r\n1', '120 60 30 15 5 1']}, {'input': '6\r\n', 'output': ['6\r\n3\r\n1', '6 3 1']}, {'input': '784653\r\n', 'output': ['784653 261551 9019 311 1', '784653\r\n261551\r\n9019\r\n311\r\n1']}, {'input': '5\r\n', 'output': ['5\r\n1', '5 1']}, {'input': '2430\r\n', 'output': ['2430\r\n1215\r\n405\r\n135\r\n45\r\n15\r\n5\r\n1', '2430 1215 405 135 45 15 5 1']}] | [{'input': '572877\r\n', 'output': ['572877\r\n190959\r\n63653\r\n1201\r\n1', '572877 190959 63653 1201 1']}, {'input': '4\r\n', 'output': ['4\r\n2\r\n1', '4 2 1']}, {'input': '10\r\n', 'output': ['10 5 1', '10\r\n5\r\n1']}, {'input': '7\r\n', 'output': ['7 1', '7\r\n1']}, {'input': '1\r\n', 'output': ['1']}] | [{'input': '9\r\n', 'output': ['9 3 1', '9\r\n3\r\n1']}, {'input': '473273\r\n', 'output': ['473273\r\n2243\r\n1', '473273 2243 1']}, {'input': '999999\r\n', 'output': ['999999\r\n333333\r\n111111\r\n37037\r\n5291\r\n481\r\n37\r\n1', '999999 333333 111111 37037 5291 481 37 1']}, {'input': '25\r\n', 'output': ['25 5 1', '25\r\n5\r\n1']}, {'input': '1000\r\n', 'output': ['1000 500 250 125 25 5 1', '1000\r\n500\r\n250\r\n125\r\n25\r\n5\r\n1']}] | [{'input': '15\r\n', 'output': ['15\r\n5\r\n1', '15 5 1']}, {'input': '36\r\n', 'output': ['36 18 9 3 1', '36\r\n18\r\n9\r\n3\r\n1']}, {'input': '473273\r\n', 'output': ['473273\r\n2243\r\n1', '473273 2243 1']}, {'input': '25\r\n', 'output': ['25 5 1', '25\r\n5\r\n1']}, {'input': '119070\r\n', 'output': ['119070\r\n59535\r\n19845\r\n6615\r\n2205\r\n735\r\n245\r\n49\r\n7\r\n1', '119070 59535 19845 6615 2205 735 245 49 7 1']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 33 | 100 | 100 | 100 |
["7 1 4", "30 20 10"] | The first line of the input contains three distinct integers x1, x2 and x3 (1ββ€βx1,βx2,βx3ββ€β100)Β β the coordinates of the houses of the first, the second and the third friends respectively. | 7bffa6e8d2d21bbb3b7f4aec109b3319 | #include <stdio.h>
#include <stdlib.h>
int main(){
int a[3];
int b;
scanf("%d%d%d", &a[0], &a[1], &a[2]);
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j ++)
if (a[i] < a[j])
{
b = a[i];
a[i] = a[j];
a[j] = b;
}
printf("%d", a[2] - a[0]);
return 0;
}
| ["6", "20"] | C | NoteIn the first sample, friends should meet at the point 4. Thus, the first friend has to travel the distance of 3 (from the point 7 to the point 4), the second friend also has to travel the distance of 3 (from the point 1 to the point 4), while the third friend should not go anywhere because he lives at the point 4. | Print one integerΒ β the minimum total distance the friends need to travel in order to meet together. | There are three friend living on the straight line Ox in Lineland. The first friend lives at the point x1, the second friend lives at the point x2, and the third friend lives at the point x3. They plan to celebrate the New Year together, so they need to meet at one point. What is the minimum total distance they have to travel in order to meet at some point and celebrate the New Year?It's guaranteed that the optimal answer is always integer. | [{"input": "7 1 4\r\n", "output": ["6"]}, {"input": "30 20 10\r\n", "output": ["20"]}, {"input": "1 4 100\r\n", "output": ["99"]}, {"input": "100 1 91\r\n", "output": ["99"]}, {"input": "1 45 100\r\n", "output": ["99"]}, {"input": "1 2 3\r\n", "output": ["2"]}, {"input": "71 85 88\r\n", "output": ["17"]}, {"input": "30 38 99\r\n", "output": ["69"]}, {"input": "23 82 95\r\n", "output": ["72"]}, {"input": "22 41 47\r\n", "output": ["25"]}, {"input": "9 94 77\r\n", "output": ["85"]}, {"input": "1 53 51\r\n", "output": ["52"]}, {"input": "25 97 93\r\n", "output": ["72"]}, {"input": "42 53 51\r\n", "output": ["11"]}, {"input": "81 96 94\r\n", "output": ["15"]}, {"input": "21 5 93\r\n", "output": ["88"]}, {"input": "50 13 75\r\n", "output": ["62"]}, {"input": "41 28 98\r\n", "output": ["70"]}, {"input": "69 46 82\r\n", "output": ["36"]}, {"input": "87 28 89\r\n", "output": ["61"]}, {"input": "44 45 40\r\n", "output": ["5"]}, {"input": "86 97 68\r\n", "output": ["29"]}, {"input": "43 92 30\r\n", "output": ["62"]}, {"input": "16 70 1\r\n", "output": ["69"]}, {"input": "40 46 19\r\n", "output": ["27"]}, {"input": "71 38 56\r\n", "output": ["33"]}, {"input": "82 21 80\r\n", "output": ["61"]}, {"input": "75 8 35\r\n", "output": ["67"]}, {"input": "75 24 28\r\n", "output": ["51"]}, {"input": "78 23 56\r\n", "output": ["55"]}, {"input": "85 31 10\r\n", "output": ["75"]}, {"input": "76 50 9\r\n", "output": ["67"]}, {"input": "95 37 34\r\n", "output": ["61"]}, {"input": "84 61 35\r\n", "output": ["49"]}, {"input": "87 85 37\r\n", "output": ["50"]}, {"input": "1 3 2\r\n", "output": ["2"]}, {"input": "4 2 6\r\n", "output": ["4"]}, {"input": "6 9 3\r\n", "output": ["6"]}, {"input": "12 4 8\r\n", "output": ["8"]}, {"input": "15 10 5\r\n", "output": ["10"]}, {"input": "1 50 17\r\n", "output": ["49"]}, {"input": "10 5 15\r\n", "output": ["10"]}, {"input": "8 1 9\r\n", "output": ["8"]}, {"input": "3 5 4\r\n", "output": ["2"]}, {"input": "2 1 3\r\n", "output": ["2"]}, {"input": "1 8 2\r\n", "output": ["7"]}, {"input": "1 100 2\r\n", "output": ["99"]}, {"input": "1 4 6\r\n", "output": ["5"]}] | 100 | 100 | 100 | [{'input': '30 38 99\r\n', 'output': ['69']}, {'input': '86 97 68\r\n', 'output': ['29']}, {'input': '4 2 6\r\n', 'output': ['4']}, {'input': '42 53 51\r\n', 'output': ['11']}, {'input': '1 100 2\r\n', 'output': ['99']}] | [{'input': '84 61 35\r\n', 'output': ['49']}, {'input': '1 3 2\r\n', 'output': ['2']}, {'input': '50 13 75\r\n', 'output': ['62']}, {'input': '30 38 99\r\n', 'output': ['69']}, {'input': '25 97 93\r\n', 'output': ['72']}] | [{'input': '41 28 98\r\n', 'output': ['70']}, {'input': '43 92 30\r\n', 'output': ['62']}, {'input': '15 10 5\r\n', 'output': ['10']}, {'input': '7 1 4\r\n', 'output': ['6']}, {'input': '75 8 35\r\n', 'output': ['67']}] | [{'input': '23 82 95\r\n', 'output': ['72']}, {'input': '30 38 99\r\n', 'output': ['69']}, {'input': '76 50 9\r\n', 'output': ['67']}, {'input': '9 94 77\r\n', 'output': ['85']}, {'input': '30 20 10\r\n', 'output': ['20']}] | [{'input': '1 45 100\r\n', 'output': ['99']}, {'input': '1 2 3\r\n', 'output': ['2']}, {'input': '95 37 34\r\n', 'output': ['61']}, {'input': '15 10 5\r\n', 'output': ['10']}, {'input': '1 4 6\r\n', 'output': ['5']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 34 | 100 | 100 | 100 |
["... ... ...\n... ... ...\n... ... ...\n\n... ... ...\n... ... ...\n... x.. ...\n\n... ... ...\n... ... ...\n... ... ...\n6 4", "xoo x.. x..\nooo ... ...\nooo ... ...\n\nx.. x.. x..\n... ... ...\n... ... ...\n\nx.. x.. x..\n... ... ...\n... ... ...\n7 4", "o.. ... ...\n... ... ...\n... ... ...\n\n... xxx ...\n... xox ...\n... ooo ...\n\n... ... ...\n... ... ...\n... ... ...\n5 5"] | First 11 lines contains descriptions of table with 9 rows and 9 columns which are divided into 9 small fields by spaces and empty lines. Each small field is described by 9 characters without spaces and empty lines. character "x" (ASCII-code 120) means that the cell is occupied with chip of the first player, character "o" (ASCII-code 111) denotes a field occupied with chip of the second player, character "." (ASCII-code 46) describes empty cell. The line after the table contains two integers x and y (1ββ€βx,βyββ€β9). They describe coordinates of the cell in table where the last move was done. Rows in the table are numbered from up to down and columns are numbered from left to right. It's guaranteed that cell where the last move was done is filled with "x" or "o". Also, it's guaranteed that there is at least one empty cell. It's not guaranteed that current state of game is reachable. | 8f0fad22f629332868c39969492264d3 | #include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define eps 1e-4
#define PI acos(-1.0)
char s[10][15];
int sti[4]={0,1,4,7},eni[4]={0,3,6,9};
int stj[4]={0,0,4,8},enj[4]={0,2,6,10};
void printall2()
{
for (int i=1;i<=9;i++)
{
for (int j=0;j<=10;j++)
if (s[i][j]=='.') printf("!");
else printf("%c",s[i][j]);
printf("\n");
if (!(i%3)) printf("\n");
}
}
void printall1()
{
for (int i=1;i<=9;i++)
{
for (int j=0;j<=10;j++)
printf("%c",s[i][j]);
printf("\n");
if (!(i%3)&&i!=9) printf("\n");
}
}
int main()
{
for (int i=1;i<=3;i++) gets(s[i]);
gets(s[0]);
for (int i=4;i<=6;i++) gets(s[i]);
gets(s[0]);
for (int i=7;i<=9;i++) gets(s[i]);
int n,m;
scanf("%d%d",&n,&m);
n%=3; m%=3;
if (!n) n=3;
if (!m) m=3;
int flag=0;
for (int i=sti[n];i<=eni[n];i++)
for (int j=stj[m];j<=enj[m];j++)
if (s[i][j]=='.')
{
flag++;
s[i][j]='!';
}
if (flag) printall1();
else printall2();
return 0;
}
| ["... ... ... \n... ... ... \n... ... ... \n\n... ... ... \n... ... ... \n... x.. ... \n\n!!! ... ... \n!!! ... ... \n!!! ... ...", "xoo x!! x!! \nooo !!! !!! \nooo !!! !!! \n\nx!! x!! x!! \n!!! !!! !!! \n!!! !!! !!! \n\nx!! x!! x!! \n!!! !!! !!! \n!!! !!! !!!", "o!! !!! !!! \n!!! !!! !!! \n!!! !!! !!! \n\n!!! xxx !!! \n!!! xox !!! \n!!! ooo !!! \n\n!!! !!! !!! \n!!! !!! !!! \n!!! !!! !!!"] | C | NoteIn the first test case the first player made a move to lower left cell of central field, so the second player can put a chip only to cells of lower left field.In the second test case the last move was done to upper left cell of lower central field, however all cells in upper left field are occupied, so the second player can put his chip to any empty cell.In the third test case the last move was done to central cell of central field, so current player can put his chip to any cell of central field, which is already occupied, so he can move anywhere. Pay attention that this state of the game is unreachable. | Output the field in same format with characters "!" (ASCII-code 33) on positions where the current player can put his chip. All other cells should not be modified. | Two bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules.The game is played on the following field. Players are making moves by turns. At first move a player can put his chip in any cell of any small field. For following moves, there are some restrictions: if during last move the opposite player put his chip to cell with coordinates (xl,βyl) in some small field, the next move should be done in one of the cells of the small field with coordinates (xl,βyl). For example, if in the first move a player puts his chip to lower left cell of central field, then the second player on his next move should put his chip into some cell of lower left field (pay attention to the first test case). If there are no free cells in the required field, the player can put his chip to any empty cell on any field.You are given current state of the game and coordinates of cell in which the last move was done. You should find all cells in which the current player can put his chip.A hare works as a postman in the forest, he likes to foul bears. Sometimes he changes the game field a bit, so the current state of the game could be unreachable. However, after his changes the cell where the last move was done is not empty. You don't need to find if the state is unreachable or not, just output possible next moves according to the rules. | [{"input": "... ... ...\r\n... ... ...\r\n... ... ...\r\n\r\n... ... ...\r\n... ... ...\r\n... x.. ...\r\n\r\n... ... ...\r\n... ... ...\r\n... ... ...\r\n6 4\r\n", "output": ["... ... ...\r\n ... ... ...\r\n ... ... ...\r\n\r\n ... ... ...\r\n ... ... ...\r\n ... x.. ...\r\n\r\n !!! ... ...\r\n !!! ... ...\r\n !!! ... ...", "... ... ... \r\n... ... ... \r\n... ... ... \r\n\r\n... ... ... \r\n... ... ... \r\n... x.. ... \r\n\r\n!!! ... ... \r\n!!! ... ... \r\n!!! ... ...", "... ... ...\r\n... ... ...\r\n... ... ...\r\n\r\n... ... ...\r\n... ... ...\r\n... x.. ...\r\n\r\n!!! ... ...\r\n!!! ... ...\r\n!!! ... ..."]}, {"input": "xoo x.. x..\r\nooo ... ...\r\nooo ... ...\r\n\r\nx.. x.. x..\r\n... ... ...\r\n... ... ...\r\n\r\nx.. x.. x..\r\n... ... ...\r\n... ... ...\r\n7 4\r\n", "output": ["xoo x!! x!!\r\n ooo !!! !!!\r\n ooo !!! !!!\r\n\r\n x!! x!! x!!\r\n !!! !!! !!!\r\n !!! !!! !!!\r\n\r\n x!! x!! x!!\r\n !!! !!! !!!\r\n !!! !!! !!!", "xoo x!! x!!\r\nooo !!! !!!\r\nooo !!! !!!\r\n\r\nx!! x!! x!!\r\n!!! !!! !!!\r\n!!! !!! !!!\r\n\r\nx!! x!! x!!\r\n!!! !!! !!!\r\n!!! !!! !!!", "xoo x!! x!! \r\nooo !!! !!! \r\nooo !!! !!! \r\n\r\nx!! x!! x!! \r\n!!! !!! !!! \r\n!!! !!! !!! \r\n\r\nx!! x!! x!! \r\n!!! !!! !!! \r\n!!! !!! !!!"]}, {"input": "o.. ... ...\r\n... ... ...\r\n... ... ...\r\n\r\n... xxx ...\r\n... xox ...\r\n... ooo ...\r\n\r\n... ... ...\r\n... ... ...\r\n... ... ...\r\n5 5\r\n", "output": ["o!! !!! !!!\r\n !!! !!! !!!\r\n !!! !!! !!!\r\n\r\n !!! xxx !!!\r\n !!! xox !!!\r\n !!! ooo !!!\r\n\r\n !!! !!! !!!\r\n !!! !!! !!!\r\n !!! !!! !!!", "o!! !!! !!!\r\n!!! !!! !!!\r\n!!! !!! !!!\r\n\r\n!!! xxx !!!\r\n!!! xox !!!\r\n!!! ooo !!!\r\n\r\n!!! !!! !!!\r\n!!! !!! !!!\r\n!!! !!! !!!", "o!! !!! !!! \r\n!!! !!! !!! \r\n!!! !!! !!! \r\n\r\n!!! xxx !!! \r\n!!! xox !!! \r\n!!! ooo !!! \r\n\r\n!!! !!! !!! \r\n!!! !!! !!! \r\n!!! !!! !!!"]}, {"input": ".o. .o. ..x\r\n..x .xx ..o\r\n... ... ...\r\n\r\n... ... xxo\r\n..x o.o oxo\r\n.x. .o. xoo\r\n\r\n... o.. ...\r\n..o .xx ..x\r\n... ... ...\r\n5 9\r\n", "output": ["!o! !o! !!x \r\n!!x !xx !!o \r\n!!! !!! !!! \r\n\r\n!!! !!! xxo \r\n!!x o!o oxo \r\n!x! !o! xoo \r\n\r\n!!! o!! !!! \r\n!!o !xx !!x \r\n!!! !!! !!!", "!o! !o! !!x\r\n!!x !xx !!o\r\n!!! !!! !!!\r\n\r\n!!! !!! xxo\r\n!!x o!o oxo\r\n!x! !o! xoo\r\n\r\n!!! o!! !!!\r\n!!o !xx !!x\r\n!!! !!! !!!", "!o! !o! !!x\r\n !!x !xx !!o\r\n !!! !!! !!!\r\n\r\n !!! !!! xxo\r\n !!x o!o oxo\r\n !x! !o! xoo\r\n\r\n !!! o!! !!!\r\n !!o !xx !!x\r\n !!! !!! !!!"]}, {"input": "... .o. ...\r\n... ... ...\r\n... ... ...\r\n\r\n... ... ...\r\n... ... ...\r\n... .x. ..x\r\n\r\n.x. ... ...\r\n..o ... .o.\r\n... o.o xx.\r\n1 5\r\n", "output": ["... !o! ... \r\n... !!! ... \r\n... !!! ... \r\n\r\n... ... ... \r\n... ... ... \r\n... .x. ..x \r\n\r\n.x. ... ... \r\n..o ... .o. \r\n... o.o xx.", "... !o! ...\r\n... !!! ...\r\n... !!! ...\r\n\r\n... ... ...\r\n... ... ...\r\n... .x. ..x\r\n\r\n.x. ... ...\r\n..o ... .o.\r\n... o.o xx.", "... !o! ...\r\n ... !!! ...\r\n ... !!! ...\r\n\r\n ... ... ...\r\n ... ... ...\r\n ... .x. ..x\r\n\r\n .x. ... ...\r\n ..o ... .o.\r\n ... o.o xx."]}, {"input": "ooo oxx xxo\r\nx.x oox xox\r\noox xo. xxx\r\n\r\nxxo xxx o.o\r\nxoo xo. oxo\r\nooo xox ox.\r\n\r\nxoo xoo .oo\r\nxox xox ox.\r\noxx xox oxo\r\n1 3\r\n", "output": ["ooo oxx xxo \r\nx!x oox xox \r\noox xo! xxx \r\n\r\nxxo xxx o!o \r\nxoo xo! oxo \r\nooo xox ox! \r\n\r\nxoo xoo !oo \r\nxox xox ox! \r\noxx xox oxo", "ooo oxx xxo\r\nx!x oox xox\r\noox xo! xxx\r\n\r\nxxo xxx o!o\r\nxoo xo! oxo\r\nooo xox ox!\r\n\r\nxoo xoo !oo\r\nxox xox ox!\r\noxx xox oxo", "ooo oxx xxo\r\n x!x oox xox\r\n oox xo! xxx\r\n\r\n xxo xxx o!o\r\n xoo xo! oxo\r\n ooo xox ox!\r\n\r\n xoo xoo !oo\r\n xox xox ox!\r\n oxx xox oxo"]}, {"input": "... ... ...\r\n..o ... ..o\r\n... .x. ..x\r\n\r\nx.. ... ...\r\n.x. .ox oo.\r\n... .xo ..x\r\n\r\n... ... .ox\r\n... ox. ..x\r\n... ..o .o.\r\n2 3\r\n", "output": ["... ... ...\r\n ..o ... ..o\r\n ... .x. ..x\r\n\r\n x.. ... !!!\r\n .x. .ox oo!\r\n ... .xo !!x\r\n\r\n ... ... .ox\r\n ... ox. ..x\r\n ... ..o .o.", "... ... ...\r\n..o ... ..o\r\n... .x. ..x\r\n\r\nx.. ... !!!\r\n.x. .ox oo!\r\n... .xo !!x\r\n\r\n... ... .ox\r\n... ox. ..x\r\n... ..o .o.", "... ... ... \r\n..o ... ..o \r\n... .x. ..x \r\n\r\nx.. ... !!! \r\n.x. .ox oo! \r\n... .xo !!x \r\n\r\n... ... .ox \r\n... ox. ..x \r\n... ..o .o."]}, {"input": "xox o.x xxo\r\nxox xox oxo\r\nxxx .xx xoo\r\n\r\nooo oox o.x\r\n.xx xx. oo.\r\nooo xox ooo\r\n\r\nooo oxo xox\r\nx.x xox xox\r\noxo x.o xxo\r\n1 7\r\n", "output": ["xox o!x xxo\r\n xox xox oxo\r\n xxx !xx xoo\r\n\r\n ooo oox o!x\r\n !xx xx! oo!\r\n ooo xox ooo\r\n\r\n ooo oxo xox\r\n x!x xox xox\r\n oxo x!o xxo", "xox o!x xxo\r\nxox xox oxo\r\nxxx !xx xoo\r\n\r\nooo oox o!x\r\n!xx xx! oo!\r\nooo xox ooo\r\n\r\nooo oxo xox\r\nx!x xox xox\r\noxo x!o xxo", "xox o!x xxo \r\nxox xox oxo \r\nxxx !xx xoo \r\n\r\nooo oox o!x \r\n!xx xx! oo! \r\nooo xox ooo \r\n\r\nooo oxo xox \r\nx!x xox xox \r\noxo x!o xxo"]}, {"input": "ox. x.o ..x\r\n... ..o .o.\r\n.o. ... x.o\r\n\r\nx.x .oo ...\r\n..o ox. .xx\r\n..x o.x .o.\r\n\r\n... ... .x.\r\nox. xx. .o.\r\n... ... ..o\r\n9 9\r\n", "output": ["ox. x.o ..x\r\n... ..o .o.\r\n.o. ... x.o\r\n\r\nx.x .oo ...\r\n..o ox. .xx\r\n..x o.x .o.\r\n\r\n... ... !x!\r\nox. xx. !o!\r\n... ... !!o", "ox. x.o ..x\r\n ... ..o .o.\r\n .o. ... x.o\r\n\r\n x.x .oo ...\r\n ..o ox. .xx\r\n ..x o.x .o.\r\n\r\n ... ... !x!\r\n ox. xx. !o!\r\n ... ... !!o", "ox. x.o ..x \r\n... ..o .o. \r\n.o. ... x.o \r\n\r\nx.x .oo ... \r\n..o ox. .xx \r\n..x o.x .o. \r\n\r\n... ... !x! \r\nox. xx. !o! \r\n... ... !!o"]}, {"input": "xx. oxx .xo\r\nxxx o.o xox\r\nxoo xoo xoo\r\n\r\nooo o.x xox\r\no.. xoo .xo\r\noxx .x. xoo\r\n\r\nooo oxo oxx\r\nxxx xox ..o\r\noo. oxx xx.\r\n3 8\r\n", "output": ["xx! oxx !xo\r\n xxx o!o xox\r\n xoo xoo xoo\r\n\r\n ooo o!x xox\r\n o!! xoo !xo\r\n oxx !x! xoo\r\n\r\n ooo oxo oxx\r\n xxx xox !!o\r\n oo! oxx xx!", "xx! oxx !xo \r\nxxx o!o xox \r\nxoo xoo xoo \r\n\r\nooo o!x xox \r\no!! xoo !xo \r\noxx !x! xoo \r\n\r\nooo oxo oxx \r\nxxx xox !!o \r\noo! oxx xx!", "xx! oxx !xo\r\nxxx o!o xox\r\nxoo xoo xoo\r\n\r\nooo o!x xox\r\no!! xoo !xo\r\noxx !x! xoo\r\n\r\nooo oxo oxx\r\nxxx xox !!o\r\noo! oxx xx!"]}, {"input": "... xo. o..\r\noo. ..o xx.\r\n..x x.. ..o\r\n\r\n.ox .xx ...\r\no.x xox xo.\r\nxox .xo ..o\r\n\r\n..o ... xxo\r\no.. .o. oxo\r\n..o x.. ..x\r\n8 9\r\n", "output": ["... xo. o.. \r\noo. ..o xx. \r\n..x x.. ..o \r\n\r\n.ox .xx !!! \r\no.x xox xo! \r\nxox .xo !!o \r\n\r\n..o ... xxo \r\no.. .o. oxo \r\n..o x.. ..x", "... xo. o..\r\n oo. ..o xx.\r\n ..x x.. ..o\r\n\r\n .ox .xx !!!\r\n o.x xox xo!\r\n xox .xo !!o\r\n\r\n ..o ... xxo\r\n o.. .o. oxo\r\n ..o x.. ..x", "... xo. o..\r\noo. ..o xx.\r\n..x x.. ..o\r\n\r\n.ox .xx !!!\r\no.x xox xo!\r\nxox .xo !!o\r\n\r\n..o ... xxo\r\no.. .o. oxo\r\n..o x.. ..x"]}, {"input": "oox xoo xxx\r\nooo xxo oxo\r\nxxx xoo xxo\r\n\r\noxo oxx xoo\r\nxoo oox xox\r\nxox oox oox\r\n\r\nxxo xoo oxo\r\noxx xxx xxx\r\noxo oxo oo.\r\n1 5\r\n", "output": ["oox xoo xxx\r\nooo xxo oxo\r\nxxx xoo xxo\r\n\r\noxo oxx xoo\r\nxoo oox xox\r\nxox oox oox\r\n\r\nxxo xoo oxo\r\noxx xxx xxx\r\noxo oxo oo!", "oox xoo xxx \r\nooo xxo oxo \r\nxxx xoo xxo \r\n\r\noxo oxx xoo \r\nxoo oox xox \r\nxox oox oox \r\n\r\nxxo xoo oxo \r\noxx xxx xxx \r\noxo oxo oo!", "oox xoo xxx\r\n ooo xxo oxo\r\n xxx xoo xxo\r\n\r\n oxo oxx xoo\r\n xoo oox xox\r\n xox oox oox\r\n\r\n xxo xoo oxo\r\n oxx xxx xxx\r\n oxo oxo oo!"]}, {"input": ".oo x.o xoo\r\n.o. xxx .x.\r\n..o x.o xxx\r\n\r\n..o .oo .xx\r\n.x. xox o.o\r\n.xo o.o .x.\r\n\r\n.o. xo. xxx\r\n.xo o.. .xo\r\n..o ..o xox\r\n1 8\r\n", "output": [".oo x!o xoo \r\n.o. xxx .x. \r\n..o x!o xxx \r\n\r\n..o .oo .xx \r\n.x. xox o.o \r\n.xo o.o .x. \r\n\r\n.o. xo. xxx \r\n.xo o.. .xo \r\n..o ..o xox", ".oo x!o xoo\r\n.o. xxx .x.\r\n..o x!o xxx\r\n\r\n..o .oo .xx\r\n.x. xox o.o\r\n.xo o.o .x.\r\n\r\n.o. xo. xxx\r\n.xo o.. .xo\r\n..o ..o xox", ".oo x!o xoo\r\n .o. xxx .x.\r\n ..o x!o xxx\r\n\r\n ..o .oo .xx\r\n .x. xox o.o\r\n .xo o.o .x.\r\n\r\n .o. xo. xxx\r\n .xo o.. .xo\r\n ..o ..o xox"]}, {"input": "xxo xoo xxo\r\nooo ooo xxx\r\noox oxo oxx\r\n\r\noxo oxo xxx\r\nxoo oxx oxo\r\nxxx oxx ooo\r\n\r\noxx xoo xxo\r\nxxx oox xox\r\nxxo o.o oxo\r\n9 6\r\n", "output": ["xxo xoo xxo\r\n ooo ooo xxx\r\n oox oxo oxx\r\n\r\n oxo oxo xxx\r\n xoo oxx oxo\r\n xxx oxx ooo\r\n\r\n oxx xoo xxo\r\n xxx oox xox\r\n xxo o!o oxo", "xxo xoo xxo \r\nooo ooo xxx \r\noox oxo oxx \r\n\r\noxo oxo xxx \r\nxoo oxx oxo \r\nxxx oxx ooo \r\n\r\noxx xoo xxo \r\nxxx oox xox \r\nxxo o!o oxo", "xxo xoo xxo\r\nooo ooo xxx\r\noox oxo oxx\r\n\r\noxo oxo xxx\r\nxoo oxx oxo\r\nxxx oxx ooo\r\n\r\noxx xoo xxo\r\nxxx oox xox\r\nxxo o!o oxo"]}, {"input": "ox. o.x .o.\r\nxxo xoo .oo\r\n.xx oox o..\r\n\r\nxx. oox oxx\r\noox oxx xxo\r\nxo. oxo x.x\r\n\r\no.x .x. xx.\r\n.xo ox. ooo\r\n.ox xo. ..o\r\n6 2\r\n", "output": ["ox. o.x .o. \r\nxxo xoo .oo \r\n.xx oox o.. \r\n\r\nxx. oox oxx \r\noox oxx xxo \r\nxo. oxo x.x \r\n\r\no.x !x! xx. \r\n.xo ox! ooo \r\n.ox xo! ..o", "ox. o.x .o.\r\n xxo xoo .oo\r\n .xx oox o..\r\n\r\n xx. oox oxx\r\n oox oxx xxo\r\n xo. oxo x.x\r\n\r\n o.x !x! xx.\r\n .xo ox! ooo\r\n .ox xo! ..o", "ox. o.x .o.\r\nxxo xoo .oo\r\n.xx oox o..\r\n\r\nxx. oox oxx\r\noox oxx xxo\r\nxo. oxo x.x\r\n\r\no.x !x! xx.\r\n.xo ox! ooo\r\n.ox xo! ..o"]}, {"input": "oxo xoo ox.\r\nxxx xoo xxo\r\nxoo xxx xox\r\n\r\nxxx xxx xoo\r\nooo o.o oxx\r\nxxo ooo xxx\r\n\r\nooo oox ooo\r\nooo oxo xxx\r\nxxo xox xxo\r\n6 1\r\n", "output": ["oxo xoo ox!\r\n xxx xoo xxo\r\n xoo xxx xox\r\n\r\n xxx xxx xoo\r\n ooo o!o oxx\r\n xxo ooo xxx\r\n\r\n ooo oox ooo\r\n ooo oxo xxx\r\n xxo xox xxo", "oxo xoo ox! \r\nxxx xoo xxo \r\nxoo xxx xox \r\n\r\nxxx xxx xoo \r\nooo o!o oxx \r\nxxo ooo xxx \r\n\r\nooo oox ooo \r\nooo oxo xxx \r\nxxo xox xxo", "oxo xoo ox!\r\nxxx xoo xxo\r\nxoo xxx xox\r\n\r\nxxx xxx xoo\r\nooo o!o oxx\r\nxxo ooo xxx\r\n\r\nooo oox ooo\r\nooo oxo xxx\r\nxxo xox xxo"]}, {"input": ".xo oxx xoo\r\nooo .xo xxx\r\noxo oox xoo\r\n\r\nx.o xoo xxx\r\nxo. oxo oxx\r\nx.x xoo o.o\r\n\r\nxoo xox oxx\r\nooo .x. .xx\r\nxox x.. xoo\r\n6 5\r\n", "output": [".xo oxx xoo\r\n ooo .xo xxx\r\n oxo oox xoo\r\n\r\n x.o xoo xxx\r\n xo. oxo oxx\r\n x.x xoo o.o\r\n\r\n xoo xox oxx\r\n ooo !x! .xx\r\n xox x!! xoo", ".xo oxx xoo\r\nooo .xo xxx\r\noxo oox xoo\r\n\r\nx.o xoo xxx\r\nxo. oxo oxx\r\nx.x xoo o.o\r\n\r\nxoo xox oxx\r\nooo !x! .xx\r\nxox x!! xoo", ".xo oxx xoo \r\nooo .xo xxx \r\noxo oox xoo \r\n\r\nx.o xoo xxx \r\nxo. oxo oxx \r\nx.x xoo o.o \r\n\r\nxoo xox oxx \r\nooo !x! .xx \r\nxox x!! xoo"]}, {"input": "oxo xox ooo\r\n.xo xxo oxx\r\nxxx oxo xxx\r\n\r\nxxo oxx .xx\r\nxo. xoo oxx\r\noxo oxx xox\r\n\r\nxoo ooo oox\r\nooo ooo xxo\r\nxxx x.o oxo\r\n2 2\r\n", "output": ["oxo xox ooo \r\n!xo xxo oxx \r\nxxx oxo xxx \r\n\r\nxxo oxx !xx \r\nxo! xoo oxx \r\noxo oxx xox \r\n\r\nxoo ooo oox \r\nooo ooo xxo \r\nxxx x!o oxo", "oxo xox ooo\r\n !xo xxo oxx\r\n xxx oxo xxx\r\n\r\n xxo oxx !xx\r\n xo! xoo oxx\r\n oxo oxx xox\r\n\r\n xoo ooo oox\r\n ooo ooo xxo\r\n xxx x!o oxo", "oxo xox ooo\r\n!xo xxo oxx\r\nxxx oxo xxx\r\n\r\nxxo oxx !xx\r\nxo! xoo oxx\r\noxo oxx xox\r\n\r\nxoo ooo oox\r\nooo ooo xxo\r\nxxx x!o oxo"]}, {"input": "xox xxx xoo\r\nxoo xxx oxo\r\nxoo oox xoo\r\n\r\noxo oox xox\r\noxo xox xox\r\noox xoo oox\r\n\r\no.o xox oox\r\noox xxo xxo\r\nxox xxx oxo\r\n3 4\r\n", "output": ["xox xxx xoo\r\n xoo xxx oxo\r\n xoo oox xoo\r\n\r\n oxo oox xox\r\n oxo xox xox\r\n oox xoo oox\r\n\r\n o!o xox oox\r\n oox xxo xxo\r\n xox xxx oxo", "xox xxx xoo \r\nxoo xxx oxo \r\nxoo oox xoo \r\n\r\noxo oox xox \r\noxo xox xox \r\noox xoo oox \r\n\r\no!o xox oox \r\noox xxo xxo \r\nxox xxx oxo", "xox xxx xoo\r\nxoo xxx oxo\r\nxoo oox xoo\r\n\r\noxo oox xox\r\noxo xox xox\r\noox xoo oox\r\n\r\no!o xox oox\r\noox xxo xxo\r\nxox xxx oxo"]}, {"input": "ooo xxx .x.\r\nxxo oox ooo\r\n.o. oox xxx\r\n\r\nxox oxx xxo\r\nxxx oxx oxx\r\noxx ooo ooo\r\n\r\n.oo xoo xo.\r\nxxo oox ooo\r\nxox xxx xxo\r\n5 1\r\n", "output": ["ooo xxx !x! \r\nxxo oox ooo \r\n!o! oox xxx \r\n\r\nxox oxx xxo \r\nxxx oxx oxx \r\noxx ooo ooo \r\n\r\n!oo xoo xo! \r\nxxo oox ooo \r\nxox xxx xxo", "ooo xxx !x!\r\nxxo oox ooo\r\n!o! oox xxx\r\n\r\nxox oxx xxo\r\nxxx oxx oxx\r\noxx ooo ooo\r\n\r\n!oo xoo xo!\r\nxxo oox ooo\r\nxox xxx xxo", "ooo xxx !x!\r\n xxo oox ooo\r\n !o! oox xxx\r\n\r\n xox oxx xxo\r\n xxx oxx oxx\r\n oxx ooo ooo\r\n\r\n !oo xoo xo!\r\n xxo oox ooo\r\n xox xxx xxo"]}] | 100 | 100 | 100 | [{'input': 'oxo xoo ox.\r\nxxx xoo xxo\r\nxoo xxx xox\r\n\r\nxxx xxx xoo\r\nooo o.o oxx\r\nxxo ooo xxx\r\n\r\nooo oox ooo\r\nooo oxo xxx\r\nxxo xox xxo\r\n6 1\r\n', 'output': ['oxo xoo ox!\r\n xxx xoo xxo\r\n xoo xxx xox\r\n\r\n xxx xxx xoo\r\n ooo o!o oxx\r\n xxo ooo xxx\r\n\r\n ooo oox ooo\r\n ooo oxo xxx\r\n xxo xox xxo', 'oxo xoo ox! \r\nxxx xoo xxo \r\nxoo xxx xox \r\n\r\nxxx xxx xoo \r\nooo o!o oxx \r\nxxo ooo xxx \r\n\r\nooo oox ooo \r\nooo oxo xxx \r\nxxo xox xxo', 'oxo xoo ox!\r\nxxx xoo xxo\r\nxoo xxx xox\r\n\r\nxxx xxx xoo\r\nooo o!o oxx\r\nxxo ooo xxx\r\n\r\nooo oox ooo\r\nooo oxo xxx\r\nxxo xox xxo']}, {'input': '... ... ...\r\n... ... ...\r\n... ... ...\r\n\r\n... ... ...\r\n... ... ...\r\n... x.. ...\r\n\r\n... ... ...\r\n... ... ...\r\n... ... ...\r\n6 4\r\n', 'output': ['... ... ...\r\n ... ... ...\r\n ... ... ...\r\n\r\n ... ... ...\r\n ... ... ...\r\n ... x.. ...\r\n\r\n !!! ... ...\r\n !!! ... ...\r\n !!! ... ...', '... ... ... \r\n... ... ... \r\n... ... ... \r\n\r\n... ... ... \r\n... ... ... \r\n... x.. ... \r\n\r\n!!! ... ... \r\n!!! ... ... \r\n!!! ... ...', '... ... ...\r\n... ... ...\r\n... ... ...\r\n\r\n... ... ...\r\n... ... ...\r\n... x.. ...\r\n\r\n!!! ... ...\r\n!!! ... ...\r\n!!! ... ...']}, {'input': 'ox. x.o ..x\r\n... ..o .o.\r\n.o. ... x.o\r\n\r\nx.x .oo ...\r\n..o ox. .xx\r\n..x o.x .o.\r\n\r\n... ... .x.\r\nox. xx. .o.\r\n... ... ..o\r\n9 9\r\n', 'output': ['ox. x.o ..x\r\n... ..o .o.\r\n.o. ... x.o\r\n\r\nx.x .oo ...\r\n..o ox. .xx\r\n..x o.x .o.\r\n\r\n... ... !x!\r\nox. xx. !o!\r\n... ... !!o', 'ox. x.o ..x\r\n ... ..o .o.\r\n .o. ... x.o\r\n\r\n x.x .oo ...\r\n ..o ox. .xx\r\n ..x o.x .o.\r\n\r\n ... ... !x!\r\n ox. xx. !o!\r\n ... ... !!o', 'ox. x.o ..x \r\n... ..o .o. \r\n.o. ... x.o \r\n\r\nx.x .oo ... \r\n..o ox. .xx \r\n..x o.x .o. \r\n\r\n... ... !x! \r\nox. xx. !o! \r\n... ... !!o']}, {'input': '... xo. o..\r\noo. ..o xx.\r\n..x x.. ..o\r\n\r\n.ox .xx ...\r\no.x xox xo.\r\nxox .xo ..o\r\n\r\n..o ... xxo\r\no.. .o. oxo\r\n..o x.. ..x\r\n8 9\r\n', 'output': ['... xo. o.. \r\noo. ..o xx. \r\n..x x.. ..o \r\n\r\n.ox .xx !!! \r\no.x xox xo! \r\nxox .xo !!o \r\n\r\n..o ... xxo \r\no.. .o. oxo \r\n..o x.. ..x', '... xo. o..\r\n oo. ..o xx.\r\n ..x x.. ..o\r\n\r\n .ox .xx !!!\r\n o.x xox xo!\r\n xox .xo !!o\r\n\r\n ..o ... xxo\r\n o.. .o. oxo\r\n ..o x.. ..x', '... xo. o..\r\noo. ..o xx.\r\n..x x.. ..o\r\n\r\n.ox .xx !!!\r\no.x xox xo!\r\nxox .xo !!o\r\n\r\n..o ... xxo\r\no.. .o. oxo\r\n..o x.. ..x']}, {'input': 'ooo oxx xxo\r\nx.x oox xox\r\noox xo. xxx\r\n\r\nxxo xxx o.o\r\nxoo xo. oxo\r\nooo xox ox.\r\n\r\nxoo xoo .oo\r\nxox xox ox.\r\noxx xox oxo\r\n1 3\r\n', 'output': ['ooo oxx xxo \r\nx!x oox xox \r\noox xo! xxx \r\n\r\nxxo xxx o!o \r\nxoo xo! oxo \r\nooo xox ox! \r\n\r\nxoo xoo !oo \r\nxox xox ox! \r\noxx xox oxo', 'ooo oxx xxo\r\nx!x oox xox\r\noox xo! xxx\r\n\r\nxxo xxx o!o\r\nxoo xo! oxo\r\nooo xox ox!\r\n\r\nxoo xoo !oo\r\nxox xox ox!\r\noxx xox oxo', 'ooo oxx xxo\r\n x!x oox xox\r\n oox xo! xxx\r\n\r\n xxo xxx o!o\r\n xoo xo! oxo\r\n ooo xox ox!\r\n\r\n xoo xoo !oo\r\n xox xox ox!\r\n oxx xox oxo']}] | [{'input': '... xo. o..\r\noo. ..o xx.\r\n..x x.. ..o\r\n\r\n.ox .xx ...\r\no.x xox xo.\r\nxox .xo ..o\r\n\r\n..o ... xxo\r\no.. .o. oxo\r\n..o x.. ..x\r\n8 9\r\n', 'output': ['... xo. o.. \r\noo. ..o xx. \r\n..x x.. ..o \r\n\r\n.ox .xx !!! \r\no.x xox xo! \r\nxox .xo !!o \r\n\r\n..o ... xxo \r\no.. .o. oxo \r\n..o x.. ..x', '... xo. o..\r\n oo. ..o xx.\r\n ..x x.. ..o\r\n\r\n .ox .xx !!!\r\n o.x xox xo!\r\n xox .xo !!o\r\n\r\n ..o ... xxo\r\n o.. .o. oxo\r\n ..o x.. ..x', '... xo. o..\r\noo. ..o xx.\r\n..x x.. ..o\r\n\r\n.ox .xx !!!\r\no.x xox xo!\r\nxox .xo !!o\r\n\r\n..o ... xxo\r\no.. .o. oxo\r\n..o x.. ..x']}, {'input': 'ooo oxx xxo\r\nx.x oox xox\r\noox xo. xxx\r\n\r\nxxo xxx o.o\r\nxoo xo. oxo\r\nooo xox ox.\r\n\r\nxoo xoo .oo\r\nxox xox ox.\r\noxx xox oxo\r\n1 3\r\n', 'output': ['ooo oxx xxo \r\nx!x oox xox \r\noox xo! xxx \r\n\r\nxxo xxx o!o \r\nxoo xo! oxo \r\nooo xox ox! \r\n\r\nxoo xoo !oo \r\nxox xox ox! \r\noxx xox oxo', 'ooo oxx xxo\r\nx!x oox xox\r\noox xo! xxx\r\n\r\nxxo xxx o!o\r\nxoo xo! oxo\r\nooo xox ox!\r\n\r\nxoo xoo !oo\r\nxox xox ox!\r\noxx xox oxo', 'ooo oxx xxo\r\n x!x oox xox\r\n oox xo! xxx\r\n\r\n xxo xxx o!o\r\n xoo xo! oxo\r\n ooo xox ox!\r\n\r\n xoo xoo !oo\r\n xox xox ox!\r\n oxx xox oxo']}, {'input': 'xoo x.. x..\r\nooo ... ...\r\nooo ... ...\r\n\r\nx.. x.. x..\r\n... ... ...\r\n... ... ...\r\n\r\nx.. x.. x..\r\n... ... ...\r\n... ... ...\r\n7 4\r\n', 'output': ['xoo x!! x!!\r\n ooo !!! !!!\r\n ooo !!! !!!\r\n\r\n x!! x!! x!!\r\n !!! !!! !!!\r\n !!! !!! !!!\r\n\r\n x!! x!! x!!\r\n !!! !!! !!!\r\n !!! !!! !!!', 'xoo x!! x!!\r\nooo !!! !!!\r\nooo !!! !!!\r\n\r\nx!! x!! x!!\r\n!!! !!! !!!\r\n!!! !!! !!!\r\n\r\nx!! x!! x!!\r\n!!! !!! !!!\r\n!!! !!! !!!', 'xoo x!! x!! \r\nooo !!! !!! \r\nooo !!! !!! \r\n\r\nx!! x!! x!! \r\n!!! !!! !!! \r\n!!! !!! !!! \r\n\r\nx!! x!! x!! \r\n!!! !!! !!! \r\n!!! !!! !!!']}, {'input': 'oox xoo xxx\r\nooo xxo oxo\r\nxxx xoo xxo\r\n\r\noxo oxx xoo\r\nxoo oox xox\r\nxox oox oox\r\n\r\nxxo xoo oxo\r\noxx xxx xxx\r\noxo oxo oo.\r\n1 5\r\n', 'output': ['oox xoo xxx\r\nooo xxo oxo\r\nxxx xoo xxo\r\n\r\noxo oxx xoo\r\nxoo oox xox\r\nxox oox oox\r\n\r\nxxo xoo oxo\r\noxx xxx xxx\r\noxo oxo oo!', 'oox xoo xxx \r\nooo xxo oxo \r\nxxx xoo xxo \r\n\r\noxo oxx xoo \r\nxoo oox xox \r\nxox oox oox \r\n\r\nxxo xoo oxo \r\noxx xxx xxx \r\noxo oxo oo!', 'oox xoo xxx\r\n ooo xxo oxo\r\n xxx xoo xxo\r\n\r\n oxo oxx xoo\r\n xoo oox xox\r\n xox oox oox\r\n\r\n xxo xoo oxo\r\n oxx xxx xxx\r\n oxo oxo oo!']}, {'input': 'ox. x.o ..x\r\n... ..o .o.\r\n.o. ... x.o\r\n\r\nx.x .oo ...\r\n..o ox. .xx\r\n..x o.x .o.\r\n\r\n... ... .x.\r\nox. xx. .o.\r\n... ... ..o\r\n9 9\r\n', 'output': ['ox. x.o ..x\r\n... ..o .o.\r\n.o. ... x.o\r\n\r\nx.x .oo ...\r\n..o ox. .xx\r\n..x o.x .o.\r\n\r\n... ... !x!\r\nox. xx. !o!\r\n... ... !!o', 'ox. x.o ..x\r\n ... ..o .o.\r\n .o. ... x.o\r\n\r\n x.x .oo ...\r\n ..o ox. .xx\r\n ..x o.x .o.\r\n\r\n ... ... !x!\r\n ox. xx. !o!\r\n ... ... !!o', 'ox. x.o ..x \r\n... ..o .o. \r\n.o. ... x.o \r\n\r\nx.x .oo ... \r\n..o ox. .xx \r\n..x o.x .o. \r\n\r\n... ... !x! \r\nox. xx. !o! \r\n... ... !!o']}] | [{'input': 'ooo xxx .x.\r\nxxo oox ooo\r\n.o. oox xxx\r\n\r\nxox oxx xxo\r\nxxx oxx oxx\r\noxx ooo ooo\r\n\r\n.oo xoo xo.\r\nxxo oox ooo\r\nxox xxx xxo\r\n5 1\r\n', 'output': ['ooo xxx !x! \r\nxxo oox ooo \r\n!o! oox xxx \r\n\r\nxox oxx xxo \r\nxxx oxx oxx \r\noxx ooo ooo \r\n\r\n!oo xoo xo! \r\nxxo oox ooo \r\nxox xxx xxo', 'ooo xxx !x!\r\nxxo oox ooo\r\n!o! oox xxx\r\n\r\nxox oxx xxo\r\nxxx oxx oxx\r\noxx ooo ooo\r\n\r\n!oo xoo xo!\r\nxxo oox ooo\r\nxox xxx xxo', 'ooo xxx !x!\r\n xxo oox ooo\r\n !o! oox xxx\r\n\r\n xox oxx xxo\r\n xxx oxx oxx\r\n oxx ooo ooo\r\n\r\n !oo xoo xo!\r\n xxo oox ooo\r\n xox xxx xxo']}, {'input': 'xox xxx xoo\r\nxoo xxx oxo\r\nxoo oox xoo\r\n\r\noxo oox xox\r\noxo xox xox\r\noox xoo oox\r\n\r\no.o xox oox\r\noox xxo xxo\r\nxox xxx oxo\r\n3 4\r\n', 'output': ['xox xxx xoo\r\n xoo xxx oxo\r\n xoo oox xoo\r\n\r\n oxo oox xox\r\n oxo xox xox\r\n oox xoo oox\r\n\r\n o!o xox oox\r\n oox xxo xxo\r\n xox xxx oxo', 'xox xxx xoo \r\nxoo xxx oxo \r\nxoo oox xoo \r\n\r\noxo oox xox \r\noxo xox xox \r\noox xoo oox \r\n\r\no!o xox oox \r\noox xxo xxo \r\nxox xxx oxo', 'xox xxx xoo\r\nxoo xxx oxo\r\nxoo oox xoo\r\n\r\noxo oox xox\r\noxo xox xox\r\noox xoo oox\r\n\r\no!o xox oox\r\noox xxo xxo\r\nxox xxx oxo']}, {'input': '... ... ...\r\n... ... ...\r\n... ... ...\r\n\r\n... ... ...\r\n... ... ...\r\n... x.. ...\r\n\r\n... ... ...\r\n... ... ...\r\n... ... ...\r\n6 4\r\n', 'output': ['... ... ...\r\n ... ... ...\r\n ... ... ...\r\n\r\n ... ... ...\r\n ... ... ...\r\n ... x.. ...\r\n\r\n !!! ... ...\r\n !!! ... ...\r\n !!! ... ...', '... ... ... \r\n... ... ... \r\n... ... ... \r\n\r\n... ... ... \r\n... ... ... \r\n... x.. ... \r\n\r\n!!! ... ... \r\n!!! ... ... \r\n!!! ... ...', '... ... ...\r\n... ... ...\r\n... ... ...\r\n\r\n... ... ...\r\n... ... ...\r\n... x.. ...\r\n\r\n!!! ... ...\r\n!!! ... ...\r\n!!! ... ...']}, {'input': '... xo. o..\r\noo. ..o xx.\r\n..x x.. ..o\r\n\r\n.ox .xx ...\r\no.x xox xo.\r\nxox .xo ..o\r\n\r\n..o ... xxo\r\no.. .o. oxo\r\n..o x.. ..x\r\n8 9\r\n', 'output': ['... xo. o.. \r\noo. ..o xx. \r\n..x x.. ..o \r\n\r\n.ox .xx !!! \r\no.x xox xo! \r\nxox .xo !!o \r\n\r\n..o ... xxo \r\no.. .o. oxo \r\n..o x.. ..x', '... xo. o..\r\n oo. ..o xx.\r\n ..x x.. ..o\r\n\r\n .ox .xx !!!\r\n o.x xox xo!\r\n xox .xo !!o\r\n\r\n ..o ... xxo\r\n o.. .o. oxo\r\n ..o x.. ..x', '... xo. o..\r\noo. ..o xx.\r\n..x x.. ..o\r\n\r\n.ox .xx !!!\r\no.x xox xo!\r\nxox .xo !!o\r\n\r\n..o ... xxo\r\no.. .o. oxo\r\n..o x.. ..x']}, {'input': 'oxo xox ooo\r\n.xo xxo oxx\r\nxxx oxo xxx\r\n\r\nxxo oxx .xx\r\nxo. xoo oxx\r\noxo oxx xox\r\n\r\nxoo ooo oox\r\nooo ooo xxo\r\nxxx x.o oxo\r\n2 2\r\n', 'output': ['oxo xox ooo \r\n!xo xxo oxx \r\nxxx oxo xxx \r\n\r\nxxo oxx !xx \r\nxo! xoo oxx \r\noxo oxx xox \r\n\r\nxoo ooo oox \r\nooo ooo xxo \r\nxxx x!o oxo', 'oxo xox ooo\r\n !xo xxo oxx\r\n xxx oxo xxx\r\n\r\n xxo oxx !xx\r\n xo! xoo oxx\r\n oxo oxx xox\r\n\r\n xoo ooo oox\r\n ooo ooo xxo\r\n xxx x!o oxo', 'oxo xox ooo\r\n!xo xxo oxx\r\nxxx oxo xxx\r\n\r\nxxo oxx !xx\r\nxo! xoo oxx\r\noxo oxx xox\r\n\r\nxoo ooo oox\r\nooo ooo xxo\r\nxxx x!o oxo']}] | [{'input': 'oxo xox ooo\r\n.xo xxo oxx\r\nxxx oxo xxx\r\n\r\nxxo oxx .xx\r\nxo. xoo oxx\r\noxo oxx xox\r\n\r\nxoo ooo oox\r\nooo ooo xxo\r\nxxx x.o oxo\r\n2 2\r\n', 'output': ['oxo xox ooo \r\n!xo xxo oxx \r\nxxx oxo xxx \r\n\r\nxxo oxx !xx \r\nxo! xoo oxx \r\noxo oxx xox \r\n\r\nxoo ooo oox \r\nooo ooo xxo \r\nxxx x!o oxo', 'oxo xox ooo\r\n !xo xxo oxx\r\n xxx oxo xxx\r\n\r\n xxo oxx !xx\r\n xo! xoo oxx\r\n oxo oxx xox\r\n\r\n xoo ooo oox\r\n ooo ooo xxo\r\n xxx x!o oxo', 'oxo xox ooo\r\n!xo xxo oxx\r\nxxx oxo xxx\r\n\r\nxxo oxx !xx\r\nxo! xoo oxx\r\noxo oxx xox\r\n\r\nxoo ooo oox\r\nooo ooo xxo\r\nxxx x!o oxo']}, {'input': 'ooo xxx .x.\r\nxxo oox ooo\r\n.o. oox xxx\r\n\r\nxox oxx xxo\r\nxxx oxx oxx\r\noxx ooo ooo\r\n\r\n.oo xoo xo.\r\nxxo oox ooo\r\nxox xxx xxo\r\n5 1\r\n', 'output': ['ooo xxx !x! \r\nxxo oox ooo \r\n!o! oox xxx \r\n\r\nxox oxx xxo \r\nxxx oxx oxx \r\noxx ooo ooo \r\n\r\n!oo xoo xo! \r\nxxo oox ooo \r\nxox xxx xxo', 'ooo xxx !x!\r\nxxo oox ooo\r\n!o! oox xxx\r\n\r\nxox oxx xxo\r\nxxx oxx oxx\r\noxx ooo ooo\r\n\r\n!oo xoo xo!\r\nxxo oox ooo\r\nxox xxx xxo', 'ooo xxx !x!\r\n xxo oox ooo\r\n !o! oox xxx\r\n\r\n xox oxx xxo\r\n xxx oxx oxx\r\n oxx ooo ooo\r\n\r\n !oo xoo xo!\r\n xxo oox ooo\r\n xox xxx xxo']}, {'input': 'xox xxx xoo\r\nxoo xxx oxo\r\nxoo oox xoo\r\n\r\noxo oox xox\r\noxo xox xox\r\noox xoo oox\r\n\r\no.o xox oox\r\noox xxo xxo\r\nxox xxx oxo\r\n3 4\r\n', 'output': ['xox xxx xoo\r\n xoo xxx oxo\r\n xoo oox xoo\r\n\r\n oxo oox xox\r\n oxo xox xox\r\n oox xoo oox\r\n\r\n o!o xox oox\r\n oox xxo xxo\r\n xox xxx oxo', 'xox xxx xoo \r\nxoo xxx oxo \r\nxoo oox xoo \r\n\r\noxo oox xox \r\noxo xox xox \r\noox xoo oox \r\n\r\no!o xox oox \r\noox xxo xxo \r\nxox xxx oxo', 'xox xxx xoo\r\nxoo xxx oxo\r\nxoo oox xoo\r\n\r\noxo oox xox\r\noxo xox xox\r\noox xoo oox\r\n\r\no!o xox oox\r\noox xxo xxo\r\nxox xxx oxo']}, {'input': '... xo. o..\r\noo. ..o xx.\r\n..x x.. ..o\r\n\r\n.ox .xx ...\r\no.x xox xo.\r\nxox .xo ..o\r\n\r\n..o ... xxo\r\no.. .o. oxo\r\n..o x.. ..x\r\n8 9\r\n', 'output': ['... xo. o.. \r\noo. ..o xx. \r\n..x x.. ..o \r\n\r\n.ox .xx !!! \r\no.x xox xo! \r\nxox .xo !!o \r\n\r\n..o ... xxo \r\no.. .o. oxo \r\n..o x.. ..x', '... xo. o..\r\n oo. ..o xx.\r\n ..x x.. ..o\r\n\r\n .ox .xx !!!\r\n o.x xox xo!\r\n xox .xo !!o\r\n\r\n ..o ... xxo\r\n o.. .o. oxo\r\n ..o x.. ..x', '... xo. o..\r\noo. ..o xx.\r\n..x x.. ..o\r\n\r\n.ox .xx !!!\r\no.x xox xo!\r\nxox .xo !!o\r\n\r\n..o ... xxo\r\no.. .o. oxo\r\n..o x.. ..x']}, {'input': 'ox. o.x .o.\r\nxxo xoo .oo\r\n.xx oox o..\r\n\r\nxx. oox oxx\r\noox oxx xxo\r\nxo. oxo x.x\r\n\r\no.x .x. xx.\r\n.xo ox. ooo\r\n.ox xo. ..o\r\n6 2\r\n', 'output': ['ox. o.x .o. \r\nxxo xoo .oo \r\n.xx oox o.. \r\n\r\nxx. oox oxx \r\noox oxx xxo \r\nxo. oxo x.x \r\n\r\no.x !x! xx. \r\n.xo ox! ooo \r\n.ox xo! ..o', 'ox. o.x .o.\r\n xxo xoo .oo\r\n .xx oox o..\r\n\r\n xx. oox oxx\r\n oox oxx xxo\r\n xo. oxo x.x\r\n\r\n o.x !x! xx.\r\n .xo ox! ooo\r\n .ox xo! ..o', 'ox. o.x .o.\r\nxxo xoo .oo\r\n.xx oox o..\r\n\r\nxx. oox oxx\r\noox oxx xxo\r\nxo. oxo x.x\r\n\r\no.x !x! xx.\r\n.xo ox! ooo\r\n.ox xo! ..o']}] | [{'input': 'xxo xoo xxo\r\nooo ooo xxx\r\noox oxo oxx\r\n\r\noxo oxo xxx\r\nxoo oxx oxo\r\nxxx oxx ooo\r\n\r\noxx xoo xxo\r\nxxx oox xox\r\nxxo o.o oxo\r\n9 6\r\n', 'output': ['xxo xoo xxo\r\n ooo ooo xxx\r\n oox oxo oxx\r\n\r\n oxo oxo xxx\r\n xoo oxx oxo\r\n xxx oxx ooo\r\n\r\n oxx xoo xxo\r\n xxx oox xox\r\n xxo o!o oxo', 'xxo xoo xxo \r\nooo ooo xxx \r\noox oxo oxx \r\n\r\noxo oxo xxx \r\nxoo oxx oxo \r\nxxx oxx ooo \r\n\r\noxx xoo xxo \r\nxxx oox xox \r\nxxo o!o oxo', 'xxo xoo xxo\r\nooo ooo xxx\r\noox oxo oxx\r\n\r\noxo oxo xxx\r\nxoo oxx oxo\r\nxxx oxx ooo\r\n\r\noxx xoo xxo\r\nxxx oox xox\r\nxxo o!o oxo']}, {'input': 'xox xxx xoo\r\nxoo xxx oxo\r\nxoo oox xoo\r\n\r\noxo oox xox\r\noxo xox xox\r\noox xoo oox\r\n\r\no.o xox oox\r\noox xxo xxo\r\nxox xxx oxo\r\n3 4\r\n', 'output': ['xox xxx xoo\r\n xoo xxx oxo\r\n xoo oox xoo\r\n\r\n oxo oox xox\r\n oxo xox xox\r\n oox xoo oox\r\n\r\n o!o xox oox\r\n oox xxo xxo\r\n xox xxx oxo', 'xox xxx xoo \r\nxoo xxx oxo \r\nxoo oox xoo \r\n\r\noxo oox xox \r\noxo xox xox \r\noox xoo oox \r\n\r\no!o xox oox \r\noox xxo xxo \r\nxox xxx oxo', 'xox xxx xoo\r\nxoo xxx oxo\r\nxoo oox xoo\r\n\r\noxo oox xox\r\noxo xox xox\r\noox xoo oox\r\n\r\no!o xox oox\r\noox xxo xxo\r\nxox xxx oxo']}, {'input': '... .o. ...\r\n... ... ...\r\n... ... ...\r\n\r\n... ... ...\r\n... ... ...\r\n... .x. ..x\r\n\r\n.x. ... ...\r\n..o ... .o.\r\n... o.o xx.\r\n1 5\r\n', 'output': ['... !o! ... \r\n... !!! ... \r\n... !!! ... \r\n\r\n... ... ... \r\n... ... ... \r\n... .x. ..x \r\n\r\n.x. ... ... \r\n..o ... .o. \r\n... o.o xx.', '... !o! ...\r\n... !!! ...\r\n... !!! ...\r\n\r\n... ... ...\r\n... ... ...\r\n... .x. ..x\r\n\r\n.x. ... ...\r\n..o ... .o.\r\n... o.o xx.', '... !o! ...\r\n ... !!! ...\r\n ... !!! ...\r\n\r\n ... ... ...\r\n ... ... ...\r\n ... .x. ..x\r\n\r\n .x. ... ...\r\n ..o ... .o.\r\n ... o.o xx.']}, {'input': 'o.. ... ...\r\n... ... ...\r\n... ... ...\r\n\r\n... xxx ...\r\n... xox ...\r\n... ooo ...\r\n\r\n... ... ...\r\n... ... ...\r\n... ... ...\r\n5 5\r\n', 'output': ['o!! !!! !!!\r\n !!! !!! !!!\r\n !!! !!! !!!\r\n\r\n !!! xxx !!!\r\n !!! xox !!!\r\n !!! ooo !!!\r\n\r\n !!! !!! !!!\r\n !!! !!! !!!\r\n !!! !!! !!!', 'o!! !!! !!!\r\n!!! !!! !!!\r\n!!! !!! !!!\r\n\r\n!!! xxx !!!\r\n!!! xox !!!\r\n!!! ooo !!!\r\n\r\n!!! !!! !!!\r\n!!! !!! !!!\r\n!!! !!! !!!', 'o!! !!! !!! \r\n!!! !!! !!! \r\n!!! !!! !!! \r\n\r\n!!! xxx !!! \r\n!!! xox !!! \r\n!!! ooo !!! \r\n\r\n!!! !!! !!! \r\n!!! !!! !!! \r\n!!! !!! !!!']}, {'input': 'ooo oxx xxo\r\nx.x oox xox\r\noox xo. xxx\r\n\r\nxxo xxx o.o\r\nxoo xo. oxo\r\nooo xox ox.\r\n\r\nxoo xoo .oo\r\nxox xox ox.\r\noxx xox oxo\r\n1 3\r\n', 'output': ['ooo oxx xxo \r\nx!x oox xox \r\noox xo! xxx \r\n\r\nxxo xxx o!o \r\nxoo xo! oxo \r\nooo xox ox! \r\n\r\nxoo xoo !oo \r\nxox xox ox! \r\noxx xox oxo', 'ooo oxx xxo\r\nx!x oox xox\r\noox xo! xxx\r\n\r\nxxo xxx o!o\r\nxoo xo! oxo\r\nooo xox ox!\r\n\r\nxoo xoo !oo\r\nxox xox ox!\r\noxx xox oxo', 'ooo oxx xxo\r\n x!x oox xox\r\n oox xo! xxx\r\n\r\n xxo xxx o!o\r\n xoo xo! oxo\r\n ooo xox ox!\r\n\r\n xoo xoo !oo\r\n xox xox ox!\r\n oxx xox oxo']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 35 | 100 | 100 | 100 |
["6\nxxxiii", "5\nxxoxx", "10\nxxxxxxxxxx"] | The first line contains integer $$$n$$$ $$$(3 \le n \le 100)$$$ β the length of the file name. The second line contains a string of length $$$n$$$ consisting of lowercase Latin letters only β the file name. | 8de14db41d0acee116bd5d8079cb2b02 | #include<stdio.h>
int main()
{
char str[100];
int i, count = 0, n;
scanf("%d", &n);
scanf("%s", str);
for(i = 0; i < n; i++)
{
if(str[i] == 'x' && str[i+1] == 'x' && str[i+2] == 'x')
count++;
}
printf("%d", count);
}
| ["1", "0", "8"] | C | NoteIn the first example Polycarp tried to send a file with name contains number $$$33$$$, written in Roman numerals. But he can not just send the file, because it name contains three letters "x" in a row. To send the file he needs to remove any one of this letters. | Print the minimum number of characters to remove from the file name so after that the name does not contain "xxx" as a substring. If initially the file name dost not contain a forbidden substring "xxx", print 0. | You can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file contains three or more "x" (lowercase Latin letters "x") in a row, the system considers that the file content does not correspond to the social network topic. In this case, the file is not sent and an error message is displayed.Determine the minimum number of characters to remove from the file name so after that the name does not contain "xxx" as a substring. Print 0 if the file name does not initially contain a forbidden substring "xxx".You can delete characters in arbitrary positions (not necessarily consecutive). If you delete a character, then the length of a string is reduced by $$$1$$$. For example, if you delete the character in the position $$$2$$$ from the string "exxxii", then the resulting string is "exxii". | [{"input": "6\r\nxxxiii\r\n", "output": ["1\r\n", "1", "1\n"]}, {"input": "5\r\nxxoxx\r\n", "output": ["0\r\n", "0\n", "0"]}, {"input": "10\r\nxxxxxxxxxx\r\n", "output": ["8\n", "8", "8\r\n"]}, {"input": "100\r\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n", "output": ["98", "98\n", "98\r\n"]}, {"input": "99\r\nxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxa\r\n", "output": ["0\r\n", "0\n", "0"]}, {"input": "3\r\nxxx\r\n", "output": ["1\r\n", "1", "1\n"]}, {"input": "77\r\naaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxyyyzzz\r\n", "output": ["0\r\n", "0\n", "0"]}, {"input": "100\r\nuxxxxxlmexxxxxxxwnxxexxxxxcxxfydxxxxxxvmdxxxxxxisxxxxxxxxidkxxxpxxxxxxxxmnuxxxxjxxxqcxxwmxxxxxxxxmrx\r\n", "output": ["41", "41\r\n", "41\n"]}, {"input": "100\r\nxxxxxxxxxxxjtxxxxxxxxcxxxxxxcfxxxxzxxxxxxgxxxxxbxxxxbxxxxxxxxdycxxxxokixxxkizxxgcxxxxxxxxexxxxxfxxxc\r\n", "output": ["49", "49\n", "49\r\n"]}, {"input": "100\r\nuxxxxxlmexxxxxxxwnxxexxxxxcxxfydxxxxxxvmdxxxxxxisxxxxxxxxidkxxxpxxxxxxxxmnuxxxxjxxxqcxxwmxxxxxwxxxxx\r\n", "output": ["41", "41\r\n", "41\n"]}, {"input": "34\r\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n", "output": ["0\r\n", "0\n", "0"]}, {"input": "5\r\nfcyju\r\n", "output": ["0\r\n", "0\n", "0"]}, {"input": "100\r\nihygyvdvyeifomhxhkhdkimquvgallbqharcyriyqkidnwykozuhvkwdldlztpabgyuflikychqpdenwzgtlzotyumjgdsrbxxxx\r\n", "output": ["2", "2\n", "2\r\n"]}] | 100 | 100 | 100 | [{'input': '10\r\nxxxxxxxxxx\r\n', 'output': ['8\n', '8', '8\r\n']}, {'input': '100\r\nuxxxxxlmexxxxxxxwnxxexxxxxcxxfydxxxxxxvmdxxxxxxisxxxxxxxxidkxxxpxxxxxxxxmnuxxxxjxxxqcxxwmxxxxxwxxxxx\r\n', 'output': ['41', '41\r\n', '41\n']}, {'input': '3\r\nxxx\r\n', 'output': ['1\r\n', '1', '1\n']}, {'input': '100\r\nihygyvdvyeifomhxhkhdkimquvgallbqharcyriyqkidnwykozuhvkwdldlztpabgyuflikychqpdenwzgtlzotyumjgdsrbxxxx\r\n', 'output': ['2', '2\n', '2\r\n']}, {'input': '100\r\nuxxxxxlmexxxxxxxwnxxexxxxxcxxfydxxxxxxvmdxxxxxxisxxxxxxxxidkxxxpxxxxxxxxmnuxxxxjxxxqcxxwmxxxxxxxxmrx\r\n', 'output': ['41', '41\r\n', '41\n']}] | [{'input': '100\r\nihygyvdvyeifomhxhkhdkimquvgallbqharcyriyqkidnwykozuhvkwdldlztpabgyuflikychqpdenwzgtlzotyumjgdsrbxxxx\r\n', 'output': ['2', '2\n', '2\r\n']}, {'input': '100\r\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n', 'output': ['98', '98\n', '98\r\n']}, {'input': '6\r\nxxxiii\r\n', 'output': ['1\r\n', '1', '1\n']}, {'input': '5\r\nxxoxx\r\n', 'output': ['0\r\n', '0\n', '0']}, {'input': '100\r\nuxxxxxlmexxxxxxxwnxxexxxxxcxxfydxxxxxxvmdxxxxxxisxxxxxxxxidkxxxpxxxxxxxxmnuxxxxjxxxqcxxwmxxxxxwxxxxx\r\n', 'output': ['41', '41\r\n', '41\n']}] | [{'input': '34\r\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n', 'output': ['0\r\n', '0\n', '0']}, {'input': '5\r\nfcyju\r\n', 'output': ['0\r\n', '0\n', '0']}, {'input': '10\r\nxxxxxxxxxx\r\n', 'output': ['8\n', '8', '8\r\n']}, {'input': '99\r\nxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxa\r\n', 'output': ['0\r\n', '0\n', '0']}, {'input': '100\r\nuxxxxxlmexxxxxxxwnxxexxxxxcxxfydxxxxxxvmdxxxxxxisxxxxxxxxidkxxxpxxxxxxxxmnuxxxxjxxxqcxxwmxxxxxxxxmrx\r\n', 'output': ['41', '41\r\n', '41\n']}] | [{'input': '100\r\nxxxxxxxxxxxjtxxxxxxxxcxxxxxxcfxxxxzxxxxxxgxxxxxbxxxxbxxxxxxxxdycxxxxokixxxkizxxgcxxxxxxxxexxxxxfxxxc\r\n', 'output': ['49', '49\n', '49\r\n']}, {'input': '77\r\naaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxyyyzzz\r\n', 'output': ['0\r\n', '0\n', '0']}, {'input': '99\r\nxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxaxxa\r\n', 'output': ['0\r\n', '0\n', '0']}, {'input': '100\r\nuxxxxxlmexxxxxxxwnxxexxxxxcxxfydxxxxxxvmdxxxxxxisxxxxxxxxidkxxxpxxxxxxxxmnuxxxxjxxxqcxxwmxxxxxwxxxxx\r\n', 'output': ['41', '41\r\n', '41\n']}, {'input': '3\r\nxxx\r\n', 'output': ['1\r\n', '1', '1\n']}] | [{'input': '100\r\nuxxxxxlmexxxxxxxwnxxexxxxxcxxfydxxxxxxvmdxxxxxxisxxxxxxxxidkxxxpxxxxxxxxmnuxxxxjxxxqcxxwmxxxxxwxxxxx\r\n', 'output': ['41', '41\r\n', '41\n']}, {'input': '100\r\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n', 'output': ['98', '98\n', '98\r\n']}, {'input': '10\r\nxxxxxxxxxx\r\n', 'output': ['8\n', '8', '8\r\n']}, {'input': '5\r\nfcyju\r\n', 'output': ['0\r\n', '0\n', '0']}, {'input': '6\r\nxxxiii\r\n', 'output': ['1\r\n', '1', '1\n']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 36 | 100 | 100 | 100 |
["1 50\n50", "3 100\n50 50 100", "2 50\n50 50"] | The first line contains two integers n, k (1ββ€βnββ€β50,β1ββ€βkββ€β5000) β the number of people, including Greg, and the boat's weight limit. The next line contains n integers β the people's weights. A person's weight is either 50 kilos or 100 kilos. You can consider Greg and his friends indexed in some way. | ebb0323a854e19794c79ab559792a1f7 | #include <stdio.h>
#define mod 1000000007
long long dp[55][55][205]={};
long long c[55][55]={};
int n,lim,A=0,B=0,i,j,k,ii,jj;
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a<b?b:a;}
int main(){
scanf("%d %d",&n,&lim);
for(i=0;i<n;i++){
int fk; scanf("%d",&fk);
if(fk==50) A++;
else B++;
}
dp[A][B][0]=1;
c[0][0]=1;
for(i=1;i<=50;i++){
for(j=0;j<=i;j++){
c[i][j]=c[i-1][j-1]+c[i-1][j];
}
}
for(k=1;k<=4*n;k++){
for(i=A;i>=0;i--){
for(j=B;j>=0;j--){
int s=k%2;
dp[i][j][k]=0;
if(s){
for(ii=i;ii<=A;ii++){
int f=lim-(ii-i)*50;
if(f>=0){
f/=100;
f+=j; f=min(f,B);
for(jj=j;jj<=f;jj++){
if((i!=ii || j!=jj)){
dp[i][j][k]+=(dp[ii][jj][k-1]*c[ii][ii-i]*c[jj][jj-j])%mod;
dp[i][j][k]%=mod;
}
}
}
}
}else{
for(ii=0;ii<=i;ii++){
int f=lim-(i-ii)*50;
if(f>=0){
f/=100; f=max(j-f,0);
for(jj=f;jj<=j;jj++){
if((i!=ii || j!=jj)){
dp[i][j][k]+=(dp[ii][jj][k-1]*c[A-ii][i-ii]*c[B-jj][j-jj])%mod;
dp[i][j][k]%=mod;
}
}
}
}
}
if(dp[0][0][k]){
printf("%d\n",k);
printf("%lld\n",dp[0][0][k]);
return 0;
}
}
}
}
puts("-1\n0");
}
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
// | ["1\n1", "5\n2", "-1\n0"] | C | NoteIn the first test Greg walks alone and consequently, he needs only one ride across the river.In the second test you should follow the plan: transport two 50 kg. people; transport one 50 kg. person back; transport one 100 kg. person; transport one 50 kg. person back; transport two 50 kg. people. That totals to 5 rides. Depending on which person to choose at step 2, we can get two distinct ways. | In the first line print an integer β the minimum number of rides. If transporting everyone to the other bank is impossible, print an integer -1. In the second line print the remainder after dividing the number of ways to transport the people in the minimum number of rides by number 1000000007 (109β+β7). If transporting everyone to the other bank is impossible, print integer 0. | One day Greg and his friends were walking in the forest. Overall there were n people walking, including Greg. Soon he found himself in front of a river. The guys immediately decided to get across the river. Luckily, there was a boat by the river bank, just where the guys were standing. We know that the boat can hold people with the total weight of at most k kilograms.Greg immediately took a piece of paper and listed there the weights of all people in his group (including himself). It turned out that each person weights either 50 or 100 kilograms. Now Greg wants to know what minimum number of times the boat needs to cross the river to transport the whole group to the other bank. The boat needs at least one person to navigate it from one bank to the other. As the boat crosses the river, it can have any non-zero number of passengers as long as their total weight doesn't exceed k.Also Greg is wondering, how many ways there are to transport everybody to the other side in the minimum number of boat rides. Two ways are considered distinct if during some ride they have distinct sets of people on the boat.Help Greg with this problem. | [{"input": "1 50\r\n50\r\n", "output": ["1\r\n1"]}, {"input": "3 100\r\n50 50 100\r\n", "output": ["5\r\n2"]}, {"input": "2 50\r\n50 50\r\n", "output": ["-1\r\n0"]}, {"input": "5 258\r\n100 100 50 50 50\r\n", "output": ["3\r\n72"]}, {"input": "8 191\r\n50 100 50 100 50 100 100 50\r\n", "output": ["11\r\n19318272"]}, {"input": "3 121\r\n100 100 50\r\n", "output": ["-1\r\n0"]}, {"input": "8 271\r\n100 50 100 50 50 50 100 50\r\n", "output": ["5\r\n78090"]}, {"input": "2 233\r\n50 100\r\n", "output": ["1\r\n1"]}, {"input": "2 153\r\n100 50\r\n", "output": ["1\r\n1"]}, {"input": "5 257\r\n50 50 50 50 50\r\n", "output": ["1\r\n1"]}, {"input": "49 290\r\n100 100 100 100 100 100 100 100 50 100 50 100 100 100 50 50 100 50 50 100 100 100 100 100 100 50 100 100 50 100 50 50 100 100 100 50 50 50 50 50 100 100 100 50 100 50 100 50 50\r\n", "output": ["39\r\n99624366"]}, {"input": "29 129\r\n50 50 50 100 100 100 50 100 50 50 50 100 50 100 100 100 50 100 100 100 50 50 50 50 50 50 50 50 50\r\n", "output": ["77\r\n37050209"]}, {"input": "32 121\r\n100 100 100 100 100 50 100 100 50 100 50 100 50 100 50 100 50 50 50 100 100 50 100 100 100 100 50 100 50 100 100 50\r\n", "output": ["101\r\n245361086"]}, {"input": "3 118\r\n100 100 100\r\n", "output": ["-1\r\n0"]}, {"input": "10 4894\r\n100 50 50 50 100 50 50 100 50 100\r\n", "output": ["1\r\n1"]}, {"input": "36 250\r\n50 100 100 50 100 100 100 50 50 100 50 50 50 50 50 50 100 50 100 100 100 100 100 100 100 50 50 100 50 50 100 100 100 100 100 50\r\n", "output": ["27\r\n77447096"]}, {"input": "31 291\r\n50 100 100 50 100 100 100 50 100 100 100 100 50 50 50 100 100 100 50 100 100 50 50 50 50 100 100 50 50 100 100\r\n", "output": ["23\r\n393964729"]}, {"input": "31 161\r\n100 50 50 50 50 100 50 100 50 100 100 50 50 100 100 50 100 50 50 100 50 100 100 50 50 100 50 50 100 50 100\r\n", "output": ["43\r\n670669365"]}, {"input": "5 123\r\n50 100 50 50 50\r\n", "output": ["9\r\n4536"]}, {"input": "43 293\r\n50 50 100 100 50 100 100 50 100 100 50 100 50 100 50 50 50 50 50 100 100 100 50 50 100 50 100 100 100 50 100 100 100 50 50 50 100 50 100 100 50 100 50\r\n", "output": ["31\r\n658920847"]}, {"input": "23 100\r\n50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50\r\n", "output": ["43\r\n689584957"]}, {"input": "41 218\r\n50 50 100 50 100 100 50 100 100 50 50 100 50 50 50 50 100 50 100 50 50 50 100 50 50 50 50 100 100 100 100 100 100 50 100 50 100 100 100 50 50\r\n", "output": ["39\r\n298372053"]}, {"input": "11 4668\r\n50 100 100 100 50 100 50 50 100 100 100\r\n", "output": ["1\r\n1"]}, {"input": "43 178\r\n50 50 100 100 100 50 100 100 50 100 100 100 50 100 50 100 50 50 100 100 50 100 100 50 50 50 100 50 50 50 100 50 100 100 100 50 100 50 50 50 50 100 100\r\n", "output": ["63\r\n503334985"]}, {"input": "33 226\r\n50 50 50 50 50 100 100 100 100 50 100 50 100 50 100 50 100 100 50 50 50 100 100 50 50 100 50 100 50 100 50 50 50\r\n", "output": ["31\r\n370884215"]}, {"input": "1 2994\r\n100\r\n", "output": ["1\r\n1"]}, {"input": "1 204\r\n50\r\n", "output": ["1\r\n1"]}, {"input": "33 123\r\n50 100 100 100 50 100 50 50 50 50 50 100 100 50 100 50 100 50 50 50 50 50 50 50 100 100 50 50 100 100 100 100 100\r\n", "output": ["93\r\n337243149"]}, {"input": "34 2964\r\n50 50 50 50 50 100 50 100 50 100 100 50 50 50 50 50 50 100 100 100 50 50 100 100 50 50 50 100 50 100 100 50 100 50\r\n", "output": ["1\r\n1"]}, {"input": "27 200\r\n50 50 50 50 100 100 50 50 100 100 100 50 100 50 100 50 50 100 100 100 50 100 100 50 50 50 100\r\n", "output": ["25\r\n271877303"]}, {"input": "31 197\r\n50 100 50 50 100 50 100 100 100 50 50 100 50 100 50 50 50 50 100 100 50 50 100 50 50 50 50 50 100 50 100\r\n", "output": ["41\r\n24368657"]}, {"input": "28 183\r\n50 100 100 50 100 50 100 100 50 100 50 100 100 100 50 50 100 50 50 50 100 50 100 50 50 100 100 100\r\n", "output": ["41\r\n844409785"]}, {"input": "48 204\r\n100 100 100 50 50 50 50 100 100 50 100 100 50 100 50 50 50 100 100 100 50 100 50 50 50 100 50 100 50 100 100 100 50 50 100 100 100 50 100 50 50 50 50 50 100 50 50 50\r\n", "output": ["45\r\n538567333"]}, {"input": "5 188\r\n50 50 50 50 50\r\n", "output": ["3\r\n30"]}, {"input": "29 108\r\n100 50 100 100 100 100 100 50 50 100 100 100 50 100 50 50 100 50 100 50 50 100 100 50 50 50 100 100 50\r\n", "output": ["87\r\n417423429"]}, {"input": "50 125\r\n50 50 50 100 100 50 100 100 50 50 100 100 100 100 100 100 50 50 100 50 100 100 50 50 50 100 100 50 100 100 100 100 100 100 100 50 50 50 100 50 50 50 50 100 100 100 100 100 50 50\r\n", "output": ["153\r\n971933773"]}, {"input": "50 2263\r\n50 100 50 100 50 100 100 100 50 50 50 100 100 100 100 100 100 50 50 100 50 100 50 50 100 50 50 100 100 50 100 100 100 50 50 50 100 50 100 50 50 50 50 50 100 100 50 50 100 50\r\n", "output": ["3\r\n211048352"]}, {"input": "50 110\r\n50 100 100 50 50 50 50 50 50 50 100 100 50 100 50 50 50 50 100 50 100 100 100 100 50 100 100 100 100 50 50 50 50 50 100 100 50 100 50 100 100 50 50 100 50 100 50 50 100 100\r\n", "output": ["143\r\n105841088"]}, {"input": "50 185\r\n100 50 50 50 50 50 100 50 100 50 100 100 50 50 100 100 100 50 50 100 50 100 50 50 100 100 100 100 100 50 50 100 100 100 50 100 50 100 50 50 100 50 100 50 50 100 50 50 100 100\r\n", "output": ["73\r\n930170107"]}, {"input": "50 207\r\n50 100 100 100 100 50 100 100 100 50 100 100 100 50 100 100 50 100 50 100 50 100 100 100 50 100 50 50 100 50 100 100 50 100 100 100 100 50 100 100 100 100 50 50 50 100 100 50 100 100\r\n", "output": ["55\r\n833060250"]}, {"input": "3 49\r\n50 50 50\r\n", "output": ["-1\r\n0"]}, {"input": "3 50\r\n50 50 50\r\n", "output": ["-1\r\n0"]}, {"input": "3 99\r\n100 50 50\r\n", "output": ["-1\r\n0"]}, {"input": "4 100\r\n100 100 100 50\r\n", "output": ["-1\r\n0"]}] | 100 | 100 | 100 | [{'input': '5 258\r\n100 100 50 50 50\r\n', 'output': ['3\r\n72']}, {'input': '3 121\r\n100 100 50\r\n', 'output': ['-1\r\n0']}, {'input': '27 200\r\n50 50 50 50 100 100 50 50 100 100 100 50 100 50 100 50 50 100 100 100 50 100 100 50 50 50 100\r\n', 'output': ['25\r\n271877303']}, {'input': '28 183\r\n50 100 100 50 100 50 100 100 50 100 50 100 100 100 50 50 100 50 50 50 100 50 100 50 50 100 100 100\r\n', 'output': ['41\r\n844409785']}, {'input': '31 197\r\n50 100 50 50 100 50 100 100 100 50 50 100 50 100 50 50 50 50 100 100 50 50 100 50 50 50 50 50 100 50 100\r\n', 'output': ['41\r\n24368657']}] | [{'input': '8 271\r\n100 50 100 50 50 50 100 50\r\n', 'output': ['5\r\n78090']}, {'input': '32 121\r\n100 100 100 100 100 50 100 100 50 100 50 100 50 100 50 100 50 50 50 100 100 50 100 100 100 100 50 100 50 100 100 50\r\n', 'output': ['101\r\n245361086']}, {'input': '49 290\r\n100 100 100 100 100 100 100 100 50 100 50 100 100 100 50 50 100 50 50 100 100 100 100 100 100 50 100 100 50 100 50 50 100 100 100 50 50 50 50 50 100 100 100 50 100 50 100 50 50\r\n', 'output': ['39\r\n99624366']}, {'input': '50 185\r\n100 50 50 50 50 50 100 50 100 50 100 100 50 50 100 100 100 50 50 100 50 100 50 50 100 100 100 100 100 50 50 100 100 100 50 100 50 100 50 50 100 50 100 50 50 100 50 50 100 100\r\n', 'output': ['73\r\n930170107']}, {'input': '8 191\r\n50 100 50 100 50 100 100 50\r\n', 'output': ['11\r\n19318272']}] | [{'input': '31 291\r\n50 100 100 50 100 100 100 50 100 100 100 100 50 50 50 100 100 100 50 100 100 50 50 50 50 100 100 50 50 100 100\r\n', 'output': ['23\r\n393964729']}, {'input': '2 153\r\n100 50\r\n', 'output': ['1\r\n1']}, {'input': '50 2263\r\n50 100 50 100 50 100 100 100 50 50 50 100 100 100 100 100 100 50 50 100 50 100 50 50 100 50 50 100 100 50 100 100 100 50 50 50 100 50 100 50 50 50 50 50 100 100 50 50 100 50\r\n', 'output': ['3\r\n211048352']}, {'input': '31 197\r\n50 100 50 50 100 50 100 100 100 50 50 100 50 100 50 50 50 50 100 100 50 50 100 50 50 50 50 50 100 50 100\r\n', 'output': ['41\r\n24368657']}, {'input': '33 123\r\n50 100 100 100 50 100 50 50 50 50 50 100 100 50 100 50 100 50 50 50 50 50 50 50 100 100 50 50 100 100 100 100 100\r\n', 'output': ['93\r\n337243149']}] | [{'input': '36 250\r\n50 100 100 50 100 100 100 50 50 100 50 50 50 50 50 50 100 50 100 100 100 100 100 100 100 50 50 100 50 50 100 100 100 100 100 50\r\n', 'output': ['27\r\n77447096']}, {'input': '33 123\r\n50 100 100 100 50 100 50 50 50 50 50 100 100 50 100 50 100 50 50 50 50 50 50 50 100 100 50 50 100 100 100 100 100\r\n', 'output': ['93\r\n337243149']}, {'input': '29 129\r\n50 50 50 100 100 100 50 100 50 50 50 100 50 100 100 100 50 100 100 100 50 50 50 50 50 50 50 50 50\r\n', 'output': ['77\r\n37050209']}, {'input': '50 185\r\n100 50 50 50 50 50 100 50 100 50 100 100 50 50 100 100 100 50 50 100 50 100 50 50 100 100 100 100 100 50 50 100 100 100 50 100 50 100 50 50 100 50 100 50 50 100 50 50 100 100\r\n', 'output': ['73\r\n930170107']}, {'input': '41 218\r\n50 50 100 50 100 100 50 100 100 50 50 100 50 50 50 50 100 50 100 50 50 50 100 50 50 50 50 100 100 100 100 100 100 50 100 50 100 100 100 50 50\r\n', 'output': ['39\r\n298372053']}] | [{'input': '23 100\r\n50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50\r\n', 'output': ['43\r\n689584957']}, {'input': '43 178\r\n50 50 100 100 100 50 100 100 50 100 100 100 50 100 50 100 50 50 100 100 50 100 100 50 50 50 100 50 50 50 100 50 100 100 100 50 100 50 50 50 50 100 100\r\n', 'output': ['63\r\n503334985']}, {'input': '36 250\r\n50 100 100 50 100 100 100 50 50 100 50 50 50 50 50 50 100 50 100 100 100 100 100 100 100 50 50 100 50 50 100 100 100 100 100 50\r\n', 'output': ['27\r\n77447096']}, {'input': '1 2994\r\n100\r\n', 'output': ['1\r\n1']}, {'input': '50 110\r\n50 100 100 50 50 50 50 50 50 50 100 100 50 100 50 50 50 50 100 50 100 100 100 100 50 100 100 100 100 50 50 50 50 50 100 100 50 100 50 100 100 50 50 100 50 100 50 50 100 100\r\n', 'output': ['143\r\n105841088']}] | 100 | 100 | 100 | 100 | 100 | 100 | 97.56 | 97.56 | 97.56 | 97.56 | 100 | 97.37 | 97.37 | 97.37 | 97.37 | 37 | 100 | 98.048 | 97.896 |
["7 3 7 3 20", "7 9 3 1 8", "10 10 10 10 10"] | The only line of the input contains five integers t1, t2, t3, t4 and t5 (1ββ€βtiββ€β100)Β β numbers written on cards. | a9c17ce5fd5f39ffd70917127ce3408a | #include<stdio.h>
int minimo(int a, int b);
int main(){
int v[5], i, j, k, total = 0, min;
for(i = 0; i < 5; i++){
scanf("%d", &v[i]);
total = total + v[i];
}
min = total;
for(i = 0; i < 5; i++){
for(j = i + 1; j < 5; j++){
if(v[i] == v[j]){
if(total - 2*v[i] < min)
min = total - 2*v[i];
}
}
}
for(i = 0; i < 5; i++){
for(j = i + 1; j < 5; j++){
for(k = j + 1; k < 5; k++){
if(v[i] == v[j] && v[i] == v[k]){
if(total - 3*v[i] < min)
min = total - 3*v[i];
}
}
}
}
printf("%d", min);
}
| ["26", "28", "20"] | C | NoteIn the first sample, Limak has cards with numbers 7, 3, 7, 3 and 20. Limak can do one of the following. Do nothing and the sum would be 7β+β3β+β7β+β3β+β20β=β40. Remove two cards with a number 7. The remaining sum would be 3β+β3β+β20β=β26. Remove two cards with a number 3. The remaining sum would be 7β+β7β+β20β=β34. You are asked to minimize the sum so the answer is 26.In the second sample, it's impossible to find two or three cards with the same number. Hence, Limak does nothing and the sum is 7β+β9β+β1β+β3β+β8β=β28.In the third sample, all cards have the same number. It's optimal to discard any three cards. The sum of two remaining numbers is 10β+β10β=β20. | Print the minimum possible sum of numbers written on remaining cards. | A little bear Limak plays a game. He has five cards. There is one number written on each card. Each number is a positive integer.Limak can discard (throw out) some cards. His goal is to minimize the sum of numbers written on remaining (not discarded) cards.He is allowed to at most once discard two or three cards with the same number. Of course, he won't discard cards if it's impossible to choose two or three cards with the same number.Given five numbers written on cards, cay you find the minimum sum of numbers on remaining cards? | [{"input": "7 3 7 3 20\r\n", "output": ["26"]}, {"input": "7 9 3 1 8\r\n", "output": ["28"]}, {"input": "10 10 10 10 10\r\n", "output": ["20"]}, {"input": "8 7 1 8 7\r\n", "output": ["15"]}, {"input": "7 7 7 8 8\r\n", "output": ["16"]}, {"input": "8 8 8 2 2\r\n", "output": ["4"]}, {"input": "8 8 2 2 2\r\n", "output": ["6"]}, {"input": "5 50 5 5 60\r\n", "output": ["110"]}, {"input": "100 100 100 100 100\r\n", "output": ["200"]}, {"input": "1 1 1 1 1\r\n", "output": ["2"]}, {"input": "29 29 20 20 20\r\n", "output": ["58"]}, {"input": "20 29 20 29 20\r\n", "output": ["58"]}, {"input": "31 31 20 20 20\r\n", "output": ["60"]}, {"input": "20 20 20 31 31\r\n", "output": ["60"]}, {"input": "20 31 20 31 20\r\n", "output": ["60"]}, {"input": "20 20 20 30 30\r\n", "output": ["60"]}, {"input": "30 30 20 20 20\r\n", "output": ["60"]}, {"input": "8 1 8 8 8\r\n", "output": ["9"]}, {"input": "1 1 1 8 1\r\n", "output": ["9"]}, {"input": "1 2 3 4 5\r\n", "output": ["15"]}, {"input": "100 99 98 97 96\r\n", "output": ["490"]}, {"input": "1 1 100 100 100\r\n", "output": ["2"]}, {"input": "100 100 99 99 98\r\n", "output": ["296"]}, {"input": "98 99 100 99 100\r\n", "output": ["296"]}, {"input": "1 90 1 91 1\r\n", "output": ["181"]}, {"input": "60 1 75 1 92\r\n", "output": ["227"]}, {"input": "15 40 90 40 90\r\n", "output": ["95"]}, {"input": "1 1 15 20 20\r\n", "output": ["17"]}, {"input": "90 11 11 10 10\r\n", "output": ["110"]}, {"input": "20 21 22 23 24\r\n", "output": ["110"]}, {"input": "1 1 2 98 99\r\n", "output": ["199"]}, {"input": "3 7 7 7 10\r\n", "output": ["13"]}, {"input": "1 3 3 3 1\r\n", "output": ["2"]}, {"input": "1 9 9 9 10\r\n", "output": ["11"]}, {"input": "100 1 1 1 1\r\n", "output": ["101"]}, {"input": "2 2 2 100 100\r\n", "output": ["6"]}, {"input": "1 2 2 2 2\r\n", "output": ["3"]}, {"input": "1 1 2 2 5\r\n", "output": ["7"]}, {"input": "1 2 3 4 1\r\n", "output": ["9"]}, {"input": "11 10 10 10 10\r\n", "output": ["21"]}, {"input": "2 2 2 10 10\r\n", "output": ["6"]}, {"input": "1 1 1 1 4\r\n", "output": ["5"]}, {"input": "98 98 98 98 23\r\n", "output": ["121"]}, {"input": "1 2 3 100 100\r\n", "output": ["6"]}, {"input": "2 2 5 10 10\r\n", "output": ["9"]}, {"input": "2 2 3 3 3\r\n", "output": ["4"]}, {"input": "1 1 1 1 2\r\n", "output": ["3"]}, {"input": "12 12 7 7 7\r\n", "output": ["21"]}] | 100 | 100 | 100 | [{'input': '20 20 20 30 30\r\n', 'output': ['60']}, {'input': '100 99 98 97 96\r\n', 'output': ['490']}, {'input': '1 3 3 3 1\r\n', 'output': ['2']}, {'input': '20 21 22 23 24\r\n', 'output': ['110']}, {'input': '1 9 9 9 10\r\n', 'output': ['11']}] | [{'input': '20 21 22 23 24\r\n', 'output': ['110']}, {'input': '60 1 75 1 92\r\n', 'output': ['227']}, {'input': '2 2 3 3 3\r\n', 'output': ['4']}, {'input': '1 3 3 3 1\r\n', 'output': ['2']}, {'input': '1 1 2 2 5\r\n', 'output': ['7']}] | [{'input': '8 1 8 8 8\r\n', 'output': ['9']}, {'input': '7 7 7 8 8\r\n', 'output': ['16']}, {'input': '2 2 2 10 10\r\n', 'output': ['6']}, {'input': '2 2 5 10 10\r\n', 'output': ['9']}, {'input': '8 8 8 2 2\r\n', 'output': ['4']}] | [{'input': '8 8 2 2 2\r\n', 'output': ['6']}, {'input': '1 2 3 4 5\r\n', 'output': ['15']}, {'input': '7 7 7 8 8\r\n', 'output': ['16']}, {'input': '7 9 3 1 8\r\n', 'output': ['28']}, {'input': '8 1 8 8 8\r\n', 'output': ['9']}] | [{'input': '1 2 3 4 5\r\n', 'output': ['15']}, {'input': '7 9 3 1 8\r\n', 'output': ['28']}, {'input': '7 7 7 8 8\r\n', 'output': ['16']}, {'input': '100 99 98 97 96\r\n', 'output': ['490']}, {'input': '10 10 10 10 10\r\n', 'output': ['20']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 95.45 | 100 | 100 | 100 | 38 | 100 | 100 | 99.09 |
["0 2 0 4", "0 2 1 1", "0 2 0 1"] | The first line contains four space-separated integers β x1, x2, a and b (x1ββ βx2, aββ€βb, β-β109ββ€βx1,βx2,βa,βbββ€β109) β coordinates of the points where the first and the second participant start, and the numbers that determine the players' moves, correspondingly. | 4ea8cc3305a0ee2c1e580b43e5bc46c6 | #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main(){
int i,j,k,l,m,n;
int x1, x2, a, b, fg, fgg;
int mod;
int stone;
while(scanf("%d%d%d%d",&x1,&x2,&a,&b)==4){
stone = x2 - x1;
fg = 0;
if(stone < 0) stone *= -1, k = a, a = b, b = k, a *= -1, b *= -1, fg = 1;
if(b <= 0){ puts("DRAW"); continue; }
fgg = 0;
if(a <= 0) fgg = 1, a = 1;
mod = stone % (a+b);
if(mod == 0){
if(fgg) puts("DRAW"); else puts("SECOND");
continue;
}
if(mod < a || mod > b){
puts("DRAW");
continue;
}
if(stone > b && fgg){
puts("DRAW");
continue;
}
stone -= mod;
puts("FIRST");
if(fg==0) printf("%d\n",x2-stone);
else printf("%d\n",x2+stone);
}
return 0;
}
| ["FIRST\n2", "SECOND", "DRAW"] | C | NoteIn the first sample the first player can win in one move.In the second sample the first participant must go to point 1, where the second participant immediately goes and wins. In the third sample changing the position isn't profitable to either participant, so nobody wins. | On the first line print the outcome of the battle as "FIRST" (without the quotes), if both players play optimally and the first player wins. Print "SECOND" (without the quotes) if the second player wins and print "DRAW" (without the quotes), if nobody is able to secure the victory. If the first player wins, print on the next line the single integer x β the coordinate of the point where the first player should transfer to win. The indicated move should be valid, that is, it should meet the following condition: x1β+βaββ€βxββ€βx1β+βb. If there are several winning moves, print any of them. If the first participant can't secure the victory, then you do not have to print anything. | The King of Flatland will organize a knights' tournament! The winner will get half the kingdom and the favor of the princess of legendary beauty and wisdom. The final test of the applicants' courage and strength will be a fencing tournament. The tournament is held by the following rules: the participants fight one on one, the winner (or rather, the survivor) transfers to the next round.Before the battle both participants stand at the specified points on the Ox axis with integer coordinates. Then they make moves in turn. The first participant moves first, naturally. During a move, the first participant can transfer from the point x to any integer point of the interval [xβ+βa; xβ+βb]. The second participant can transfer during a move to any integer point of the interval [xβ-βb; xβ-βa]. That is, the options for the players' moves are symmetric (note that the numbers a and b are not required to be positive, and if aββ€β0ββ€βb, then staying in one place is a correct move). At any time the participants can be located arbitrarily relative to each other, that is, it is allowed to "jump" over the enemy in any direction. A participant wins if he uses his move to transfer to the point where his opponent is.Of course, the princess has already chosen a husband and now she wants to make her sweetheart win the tournament. He has already reached the tournament finals and he is facing the last battle. The princess asks the tournament manager to arrange the tournament finalists in such a way that her sweetheart wins the tournament, considering that both players play optimally. However, the initial location of the participants has already been announced, and we can only pull some strings and determine which participant will be first and which one will be second. But how do we know which participant can secure the victory? Alas, the princess is not learned in the military affairs... Therefore, she asks you to determine how the battle will end considering that both opponents play optimally. Also, if the first player wins, your task is to determine his winning move. | [{"input": "0 2 0 4\r\n", "output": ["FIRST\r\n2"]}, {"input": "0 2 1 1\r\n", "output": ["SECOND"]}, {"input": "0 2 0 1\r\n", "output": ["DRAW"]}, {"input": "3 1 -2 2\r\n", "output": ["FIRST\r\n1"]}, {"input": "3 10 1 6\r\n", "output": ["SECOND"]}, {"input": "1 2 2 2\r\n", "output": ["DRAW"]}, {"input": "0 10 -1 1\r\n", "output": ["DRAW"]}, {"input": "0 15 5 5\r\n", "output": ["FIRST\r\n5"]}, {"input": "20 1 -5 -1\r\n", "output": ["FIRST\r\n19"]}, {"input": "0 100 2 31\r\n", "output": ["DRAW"]}, {"input": "31 39 0 8\r\n", "output": ["FIRST\r\n39"]}, {"input": "75 37 9 33\r\n", "output": ["DRAW"]}, {"input": "-44 -17 12 13\r\n", "output": ["DRAW"]}, {"input": "-80 60 17 23\r\n", "output": ["FIRST\r\n-60"]}, {"input": "-343 -119 -194 -60\r\n", "output": ["DRAW"]}, {"input": "439 722 206 325\r\n", "output": ["FIRST\r\n722"]}, {"input": "1621 733 -732 -156\r\n", "output": ["SECOND"]}, {"input": "2062 4167 2 2\r\n", "output": ["DRAW"]}, {"input": "45390 21963 -2047 -1023\r\n", "output": ["FIRST\r\n43453"]}, {"input": "258358 241272 -2 -1\r\n", "output": ["FIRST\r\n258357"]}, {"input": "965398 678942 -6666 -666\r\n", "output": ["DRAW"]}, {"input": "1234577 1234573 -3 3\r\n", "output": ["DRAW"]}, {"input": "-186611 -745388 -776721 -308073\r\n", "output": ["FIRST\r\n-745388"]}, {"input": "2408736 -3517525 413342 557733\r\n", "output": ["DRAW"]}, {"input": "-8006393 7731100 -478756 3592795\r\n", "output": ["DRAW"]}, {"input": "-48549196 47782227 17235 109857\r\n", "output": ["DRAW"]}, {"input": "61190539 -40142693 -666666 -666666\r\n", "output": ["SECOND"]}, {"input": "25882413 -80674370 -999999 -9\r\n", "output": ["FIRST\r\n25326478"]}, {"input": "48011031 230545656 12345 67890\r\n", "output": ["SECOND"]}, {"input": "-730305467 -514687698 2 7\r\n", "output": ["DRAW"]}, {"input": "411443207 739161876 -1 0\r\n", "output": ["DRAW"]}, {"input": "402211447 260733897 -52 275\r\n", "output": ["DRAW"]}, {"input": "35406031 214492689 -307333182 -305473200\r\n", "output": ["DRAW"]}, {"input": "44789577 44789576 -1 0\r\n", "output": ["FIRST\r\n44789576"]}, {"input": "434676805 434676075 -878 345\r\n", "output": ["FIRST\r\n434676075"]}, {"input": "547686188 61562151 -496372503 -115242932\r\n", "output": ["FIRST\r\n61562151"]}, {"input": "775517456 -869957101 -1 -1\r\n", "output": ["FIRST\r\n775517455"]}, {"input": "637107829 -403198378 -2 -2\r\n", "output": ["DRAW"]}, {"input": "-318865784 794140986 2 3\r\n", "output": ["SECOND"]}, {"input": "999763526 -998481439 -815 -157\r\n", "output": ["FIRST\r\n999762965"]}, {"input": "416100128 -709112339 -190811 -190811\r\n", "output": ["FIRST\r\n415909317"]}, {"input": "183003032 -631999413 -1000002 -1\r\n", "output": ["SECOND"]}, {"input": "847094637 -152905363 -1000000000 -1000000000\r\n", "output": ["FIRST\r\n-152905363"]}, {"input": "-1000000000 1000000000 1 1\r\n", "output": ["SECOND"]}, {"input": "-1000000000 1000000000 0 0\r\n", "output": ["DRAW"]}, {"input": "1000000000 999999999 -1000000000 -2\r\n", "output": ["DRAW"]}, {"input": "0 1 -1000000000 1000000000\r\n", "output": ["FIRST\r\n1"]}, {"input": "-1000000000 1000000000 1230987 9871231\r\n", "output": ["FIRST\r\n-998399240"]}, {"input": "-1000000000 1000000000 0 1000000000\r\n", "output": ["DRAW"]}, {"input": "-1000000000 1000000000 1 999999999\r\n", "output": ["SECOND"]}, {"input": "-1000000000 1000000000 499999999 500000000\r\n", "output": ["DRAW"]}, {"input": "-1000000000 1000000000 1000000000 1000000000\r\n", "output": ["SECOND"]}, {"input": "1000000000 -1000000000 1000000000 1000000000\r\n", "output": ["DRAW"]}, {"input": "0 6 2 5\r\n", "output": ["DRAW"]}] | 100 | 100 | 100 | [{'input': '402211447 260733897 -52 275\r\n', 'output': ['DRAW']}, {'input': '-44 -17 12 13\r\n', 'output': ['DRAW']}, {'input': '1000000000 999999999 -1000000000 -2\r\n', 'output': ['DRAW']}, {'input': '-1000000000 1000000000 1 999999999\r\n', 'output': ['SECOND']}, {'input': '434676805 434676075 -878 345\r\n', 'output': ['FIRST\r\n434676075']}] | [{'input': '0 2 1 1\r\n', 'output': ['SECOND']}, {'input': '0 2 0 1\r\n', 'output': ['DRAW']}, {'input': '2062 4167 2 2\r\n', 'output': ['DRAW']}, {'input': '775517456 -869957101 -1 -1\r\n', 'output': ['FIRST\r\n775517455']}, {'input': '45390 21963 -2047 -1023\r\n', 'output': ['FIRST\r\n43453']}] | [{'input': '3 10 1 6\r\n', 'output': ['SECOND']}, {'input': '-730305467 -514687698 2 7\r\n', 'output': ['DRAW']}, {'input': '3 1 -2 2\r\n', 'output': ['FIRST\r\n1']}, {'input': '31 39 0 8\r\n', 'output': ['FIRST\r\n39']}, {'input': '775517456 -869957101 -1 -1\r\n', 'output': ['FIRST\r\n775517455']}] | [{'input': '-1000000000 1000000000 0 1000000000\r\n', 'output': ['DRAW']}, {'input': '61190539 -40142693 -666666 -666666\r\n', 'output': ['SECOND']}, {'input': '25882413 -80674370 -999999 -9\r\n', 'output': ['FIRST\r\n25326478']}, {'input': '35406031 214492689 -307333182 -305473200\r\n', 'output': ['DRAW']}, {'input': '402211447 260733897 -52 275\r\n', 'output': ['DRAW']}] | [{'input': '434676805 434676075 -878 345\r\n', 'output': ['FIRST\r\n434676075']}, {'input': '0 1 -1000000000 1000000000\r\n', 'output': ['FIRST\r\n1']}, {'input': '1621 733 -732 -156\r\n', 'output': ['SECOND']}, {'input': '402211447 260733897 -52 275\r\n', 'output': ['DRAW']}, {'input': '-1000000000 1000000000 1 999999999\r\n', 'output': ['SECOND']}] | 100 | 100 | 100 | 100 | 100 | 100 | 91.3 | 91.3 | 91.3 | 91.3 | 77.27 | 77.27 | 81.82 | 77.27 | 77.27 | 39 | 100 | 93.04 | 78.18 |
["1 5", "3 6"] | The first line contains two integers a and m (1ββ€βa,βmββ€β105). | f726133018e2149ec57e113860ec498a | #include <stdio.h>
int a,m,k,r;
int main() {
scanf("%d",&a);
scanf("%d",&m);
r=a%m;
while(k<20) {
if(r%m==0) {
printf("Yes\n");
return 0;
}
else {
r*=2;
++k;
}
}
printf("No\n");
return 0;
} | ["No", "Yes"] | C | null | Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No". | One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be Π° moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment. | [{"input": "1 5\r\n", "output": ["No"]}, {"input": "3 6\r\n", "output": ["Yes"]}, {"input": "1 8\r\n", "output": ["Yes"]}, {"input": "2 3\r\n", "output": ["No"]}, {"input": "3 24\r\n", "output": ["Yes"]}, {"input": "1 1\r\n", "output": ["Yes"]}, {"input": "100000 100000\r\n", "output": ["Yes"]}, {"input": "1 99989\r\n", "output": ["No"]}, {"input": "512 2\r\n", "output": ["Yes"]}, {"input": "100 24\r\n", "output": ["No"]}, {"input": "1 100000\r\n", "output": ["No"]}, {"input": "100000 1\r\n", "output": ["Yes"]}, {"input": "3 99929\r\n", "output": ["No"]}, {"input": "99961 99971\r\n", "output": ["No"]}, {"input": "1 65536\r\n", "output": ["Yes"]}, {"input": "4 65536\r\n", "output": ["Yes"]}, {"input": "3 65536\r\n", "output": ["Yes"]}, {"input": "32768 65536\r\n", "output": ["Yes"]}, {"input": "65535 65536\r\n", "output": ["Yes"]}, {"input": "1 65535\r\n", "output": ["No"]}, {"input": "98812 100000\r\n", "output": ["No"]}, {"input": "10 5\r\n", "output": ["Yes"]}, {"input": "6 8\r\n", "output": ["Yes"]}] | 100 | 100 | 100 | [{'input': '65535 65536\r\n', 'output': ['Yes']}, {'input': '1 1\r\n', 'output': ['Yes']}, {'input': '100000 100000\r\n', 'output': ['Yes']}, {'input': '3 24\r\n', 'output': ['Yes']}, {'input': '10 5\r\n', 'output': ['Yes']}] | [{'input': '1 65535\r\n', 'output': ['No']}, {'input': '3 65536\r\n', 'output': ['Yes']}, {'input': '4 65536\r\n', 'output': ['Yes']}, {'input': '3 6\r\n', 'output': ['Yes']}, {'input': '3 99929\r\n', 'output': ['No']}] | [{'input': '100000 1\r\n', 'output': ['Yes']}, {'input': '1 99989\r\n', 'output': ['No']}, {'input': '98812 100000\r\n', 'output': ['No']}, {'input': '3 99929\r\n', 'output': ['No']}, {'input': '1 8\r\n', 'output': ['Yes']}] | [{'input': '4 65536\r\n', 'output': ['Yes']}, {'input': '6 8\r\n', 'output': ['Yes']}, {'input': '512 2\r\n', 'output': ['Yes']}, {'input': '1 99989\r\n', 'output': ['No']}, {'input': '1 100000\r\n', 'output': ['No']}] | [{'input': '10 5\r\n', 'output': ['Yes']}, {'input': '512 2\r\n', 'output': ['Yes']}, {'input': '1 65535\r\n', 'output': ['No']}, {'input': '4 65536\r\n', 'output': ['Yes']}, {'input': '100000 100000\r\n', 'output': ['Yes']}] | 100 | 100 | 100 | 100 | 100 | 83.33 | 100 | 100 | 100 | 100 | 75 | 100 | 100 | 100 | 100 | 40 | 100 | 96.666 | 95 |
["5", "1"] | The input contains the only integer n (1ββ€βnββ€β106). | 75739f77378b21c331b46b1427226fa1 | #include <stdio.h>
int gcm(int a, int b) // a<=bγ§γγγγ¨οΌ
{
if(a == 0)
return b;
else
return gcm(b%a, a);
}
int rec(int a, int b) // a<bγ§γγγγ¨οΌ
{
if(a == 1)
return b-1;
return b/a + rec(b%a, a);
}
int main (int argc, const char * argv[]) {
int i, a, b, min;
scanf("%d", &a);
min = a-1;
for(i = 2; i <= a/2; i++){
if(gcm(a, i) != 1)
continue;
if((b = rec(i, a)) < min)
min = b;
}
printf("%d\n", min);
return 0;
}
| ["3", "0"] | C | NoteThe pair (1,1) can be transformed into a pair containing 5 in three moves: (1,1) βββ (1,2) βββ (3,2) βββ (5,2). | Print the only integer k. | Let's assume that we have a pair of numbers (a,βb). We can get a new pair (aβ+βb,βb) or (a,βaβ+βb) from the given pair in a single step.Let the initial pair of numbers be (1,1). Your task is to find number k, that is, the least number of steps needed to transform (1,1) into the pair where at least one number equals n. | [{"input": "5\r\n", "output": ["3"]}, {"input": "1\r\n", "output": ["0"]}, {"input": "2\r\n", "output": ["1"]}, {"input": "3\r\n", "output": ["2"]}, {"input": "4\r\n", "output": ["3"]}, {"input": "10\r\n", "output": ["5"]}, {"input": "1009\r\n", "output": ["15"]}, {"input": "2009\r\n", "output": ["17"]}, {"input": "7009\r\n", "output": ["19"]}, {"input": "9009\r\n", "output": ["20"]}, {"input": "19009\r\n", "output": ["21"]}, {"input": "29009\r\n", "output": ["22"]}, {"input": "12434\r\n", "output": ["21"]}, {"input": "342342\r\n", "output": ["28"]}, {"input": "342235\r\n", "output": ["28"]}, {"input": "362235\r\n", "output": ["28"]}, {"input": "762235\r\n", "output": ["30"]}, {"input": "878235\r\n", "output": ["30"]}, {"input": "978235\r\n", "output": ["30"]}, {"input": "1000000\r\n", "output": ["30"]}, {"input": "6\r\n", "output": ["5"]}, {"input": "10000\r\n", "output": ["20"]}, {"input": "999999\r\n", "output": ["30"]}, {"input": "524287\r\n", "output": ["29"]}, {"input": "777777\r\n", "output": ["30"]}, {"input": "123756\r\n", "output": ["26"]}, {"input": "976438\r\n", "output": ["30"]}, {"input": "434563\r\n", "output": ["28"]}, {"input": "345634\r\n", "output": ["28"]}, {"input": "65457\r\n", "output": ["24"]}, {"input": "123456\r\n", "output": ["26"]}, {"input": "999997\r\n", "output": ["30"]}, {"input": "98989\r\n", "output": ["25"]}, {"input": "8\r\n", "output": ["4"]}, {"input": "123455\r\n", "output": ["26"]}, {"input": "990001\r\n", "output": ["30"]}, {"input": "123141\r\n", "output": ["26"]}, {"input": "998\r\n", "output": ["16"]}, {"input": "453422\r\n", "output": ["28"]}, {"input": "623423\r\n", "output": ["29"]}, {"input": "89\r\n", "output": ["9"]}, {"input": "24234\r\n", "output": ["23"]}, {"input": "999879\r\n", "output": ["30"]}, {"input": "345612\r\n", "output": ["28"]}, {"input": "998756\r\n", "output": ["30"]}, {"input": "999989\r\n", "output": ["30"]}, {"input": "999998\r\n", "output": ["30"]}, {"input": "999912\r\n", "output": ["30"]}, {"input": "100000\r\n", "output": ["25"]}] | 100 | 100 | 100 | [{'input': '98989\r\n', 'output': ['25']}, {'input': '29009\r\n', 'output': ['22']}, {'input': '123756\r\n', 'output': ['26']}, {'input': '342342\r\n', 'output': ['28']}, {'input': '1009\r\n', 'output': ['15']}] | [{'input': '434563\r\n', 'output': ['28']}, {'input': '100000\r\n', 'output': ['25']}, {'input': '12434\r\n', 'output': ['21']}, {'input': '623423\r\n', 'output': ['29']}, {'input': '1000000\r\n', 'output': ['30']}] | [{'input': '999997\r\n', 'output': ['30']}, {'input': '6\r\n', 'output': ['5']}, {'input': '100000\r\n', 'output': ['25']}, {'input': '89\r\n', 'output': ['9']}, {'input': '978235\r\n', 'output': ['30']}] | [{'input': '10000\r\n', 'output': ['20']}, {'input': '98989\r\n', 'output': ['25']}, {'input': '2009\r\n', 'output': ['17']}, {'input': '123456\r\n', 'output': ['26']}, {'input': '777777\r\n', 'output': ['30']}] | [{'input': '999989\r\n', 'output': ['30']}, {'input': '10000\r\n', 'output': ['20']}, {'input': '999999\r\n', 'output': ['30']}, {'input': '978235\r\n', 'output': ['30']}, {'input': '123756\r\n', 'output': ['26']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 41 | 100 | 100 | 100 |
["3 7 6", "7 2 4"] | A single line contains three integers x,βy,βn (1ββ€βx,βy,βnββ€β105). | 827bc6f120aff6a6f04271bc84e863ee | #include <math.h>
#include <float.h>
#include <stdio.h>
#include <stdlib.h>
int main (void) {
int x, y, n, a = 0, b = 1, i, j;
double t;
scanf ("%d %d %d", &x, &y, &n);
t = (double)x / y;
for (j = 1; j <= n; ++j) {
double A[] = {floor (t*j), ceil (t*j)};
for (i = 0; (unsigned)i < sizeof A / sizeof *A; ++i) {
if (fabs (t - A[i]/j) + DBL_EPSILON < fabs (t - (double)a/b)) {
a = A[i];
b = j;
}
}
}
printf ("%d/%d\n", a, b);
exit (EXIT_SUCCESS);
}
| ["2/5", "7/2"] | C | null | Print the required fraction in the format "a/b" (without quotes). | You are given three positive integers x,βy,βn. Your task is to find the nearest fraction to fraction whose denominator is no more than n. Formally, you should find such pair of integers a,βb (1ββ€βbββ€βn;Β 0ββ€βa) that the value is as minimal as possible.If there are multiple "nearest" fractions, choose the one with the minimum denominator. If there are multiple "nearest" fractions with the minimum denominator, choose the one with the minimum numerator. | [{"input": "3 7 6\r\n", "output": ["2/5"]}, {"input": "7 2 4\r\n", "output": ["7/2"]}, {"input": "1 1 1\r\n", "output": ["1/1"]}, {"input": "1 2 1\r\n", "output": ["0/1"]}, {"input": "1 2 2\r\n", "output": ["1/2"]}, {"input": "17708 35362 1558\r\n", "output": ["328/655"]}, {"input": "72657 93778 50943\r\n", "output": ["38236/49351"]}, {"input": "1000 7 3\r\n", "output": ["143/1"]}, {"input": "1000 11 20\r\n", "output": ["1000/11"]}, {"input": "100000 2 100000\r\n", "output": ["50000/1"]}, {"input": "99999 2 1\r\n", "output": ["49999/1"]}, {"input": "38133 49787 9840\r\n", "output": ["3295/4302"]}, {"input": "76730 91851 71438\r\n", "output": ["49039/58703"]}, {"input": "7487 17563 1102\r\n", "output": ["107/251"]}, {"input": "46084 75979 30535\r\n", "output": ["11637/19186"]}, {"input": "60489 34395 34632\r\n", "output": ["20163/11465"]}, {"input": "91245 43755 27191\r\n", "output": ["6083/2917"]}, {"input": "29842 2171 245\r\n", "output": ["811/59"]}, {"input": "44247 27883 24673\r\n", "output": ["34667/21846"]}, {"input": "89781 34400 19222\r\n", "output": ["49972/19147"]}, {"input": "36890 92817 22772\r\n", "output": ["5951/14973"]}, {"input": "75486 2177 1983\r\n", "output": ["58877/1698"]}, {"input": "6243 60593 42244\r\n", "output": ["3565/34601"]}, {"input": "20648 86305 73795\r\n", "output": ["15543/64967"]}, {"input": "59245 44721 45425\r\n", "output": ["59245/44721"]}, {"input": "90002 86785 57380\r\n", "output": ["23109/22283"]}, {"input": "28598 12497 10464\r\n", "output": ["23710/10361"]}, {"input": "43003 70913 71178\r\n", "output": ["43003/70913"]}, {"input": "14304 96625 53803\r\n", "output": ["7934/53595"]}, {"input": "35646 27334 23417\r\n", "output": ["17823/13667"]}, {"input": "99997 99999 99996\r\n", "output": ["49999/50000"]}, {"input": "100000 10 10\r\n", "output": ["10000/1"]}, {"input": "7 6 3\r\n", "output": ["1/1"]}] | 100 | 100 | 100 | [{'input': '60489 34395 34632\r\n', 'output': ['20163/11465']}, {'input': '17708 35362 1558\r\n', 'output': ['328/655']}, {'input': '20648 86305 73795\r\n', 'output': ['15543/64967']}, {'input': '100000 2 100000\r\n', 'output': ['50000/1']}, {'input': '43003 70913 71178\r\n', 'output': ['43003/70913']}] | [{'input': '99999 2 1\r\n', 'output': ['49999/1']}, {'input': '29842 2171 245\r\n', 'output': ['811/59']}, {'input': '1000 11 20\r\n', 'output': ['1000/11']}, {'input': '35646 27334 23417\r\n', 'output': ['17823/13667']}, {'input': '44247 27883 24673\r\n', 'output': ['34667/21846']}] | [{'input': '75486 2177 1983\r\n', 'output': ['58877/1698']}, {'input': '7 2 4\r\n', 'output': ['7/2']}, {'input': '89781 34400 19222\r\n', 'output': ['49972/19147']}, {'input': '1000 11 20\r\n', 'output': ['1000/11']}, {'input': '7 6 3\r\n', 'output': ['1/1']}] | [{'input': '1 1 1\r\n', 'output': ['1/1']}, {'input': '1 2 2\r\n', 'output': ['1/2']}, {'input': '1000 11 20\r\n', 'output': ['1000/11']}, {'input': '1000 7 3\r\n', 'output': ['143/1']}, {'input': '36890 92817 22772\r\n', 'output': ['5951/14973']}] | [{'input': '14304 96625 53803\r\n', 'output': ['7934/53595']}, {'input': '90002 86785 57380\r\n', 'output': ['23109/22283']}, {'input': '46084 75979 30535\r\n', 'output': ['11637/19186']}, {'input': '100000 2 100000\r\n', 'output': ['50000/1']}, {'input': '29842 2171 245\r\n', 'output': ['811/59']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 42 | 100 | 100 | 100 |
["13\n12", "16\n11311", "20\n999", "17\n2016"] | The first line contains the integer n (2ββ€βnββ€β109). The second line contains the integer k (0ββ€βkβ<β1060), it is guaranteed that the number k contains no more than 60 symbols. All digits in the second line are strictly less than n. Alexander guarantees that the answer exists and does not exceed 1018. The number k doesn't contain leading zeros. | be66399c558c96566a6bb0a63d2503e5 | #include <stdio.h>
#include <string.h>
#define INF ((long long) 1e18)
int main() {
static char s[128];
static long long dp[128][128];
int n, h, i, j, l;
long long min;
scanf("%d", &n);
scanf("%s", s);
l = strlen(s);
for (i = 0; i <= l; i++)
for (j = 0; j <= l; j++)
dp[i][j] = INF;
dp[0][0] = 0;
for (i = 0; i < l; i++)
for (j = 0; j < l; j++)
if (dp[i][j] < INF) {
long long x = dp[i][j];
if (s[i] == '0') {
if ((double) x * n <= INF)
if (dp[i + 1][j + 1] > x * n)
dp[i + 1][j + 1] = x * n;
} else {
long long y = 0;
for (h = i; h < l; h++) {
y = y * 10 + (s[h] - '0');
if (y >= n)
break;
if ((double) x * n + y <= INF)
if (dp[h + 1][j + 1] > x * n + y)
dp[h + 1][j + 1] = x * n + y;
}
}
}
min = INF;
for (j = 0; j <= l; j++)
if (min > dp[l][j])
min = dp[l][j];
printf("%lld\n", min);
return 0;
}
| ["12", "475", "3789", "594"] | C | NoteIn the first example 12 could be obtained by converting two numbers to the system with base 13: 12β=β12Β·130 or 15β=β1Β·131β+β2Β·130. | Print the number x (0ββ€βxββ€β1018)Β β the answer to the problem. | Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets 11311 (475β=β1Β·162β+β13Β·161β+β11Β·160). Alexander lived calmly until he tried to convert the number back to the decimal number system.Alexander remembers that he worked with little numbers so he asks to find the minimum decimal number so that by converting it to the system with the base n he will get the number k. | [{"input": "13\r\n12\r\n", "output": ["12"]}, {"input": "16\r\n11311\r\n", "output": ["475"]}, {"input": "20\r\n999\r\n", "output": ["3789"]}, {"input": "17\r\n2016\r\n", "output": ["594"]}, {"input": "1000\r\n1001\r\n", "output": ["100001"]}, {"input": "1000\r\n1000\r\n", "output": ["100000"]}, {"input": "2\r\n110111100000101101101011001110100111011001000000000000000000\r\n", "output": ["1000000000000000000"]}, {"input": "500\r\n29460456244280453288\r\n", "output": ["467528530570226788"]}, {"input": "1000000000\r\n17289468142098080\r\n", "output": ["17289468142098080"]}, {"input": "123\r\n7719\r\n", "output": ["9490"]}, {"input": "25\r\n2172214240\r\n", "output": ["26524975"]}, {"input": "2\r\n1110110101111000010001011110101001011001110000000010111010\r\n", "output": ["267367244641009850"]}, {"input": "3\r\n1210020121011022121222022012121212020\r\n", "output": ["268193483524125978"]}, {"input": "4\r\n32323300000100133222012211322\r\n", "output": ["269019726702209402"]}, {"input": "5\r\n4230423222300004320404110\r\n", "output": ["269845965585325530"]}, {"input": "6\r\n20201051430024130310350\r\n", "output": ["270672213058376250"]}, {"input": "7\r\n325503632564034033331\r\n", "output": ["271498451941492378"]}, {"input": "8\r\n17073735641412635372\r\n", "output": ["272324690824608506"]}, {"input": "9\r\n1733607167155630041\r\n", "output": ["273150934002691930"]}, {"input": "10\r\n996517375802030516\r\n", "output": ["996517375802030516"]}, {"input": "11\r\n1107835458761401923\r\n", "output": ["997343614685146644"]}, {"input": "20\r\n905191218118181710131111\r\n", "output": ["738505167292405431"]}, {"input": "50\r\n303521849112318129\r\n", "output": ["59962796634170079"]}, {"input": "100\r\n7226127039816418\r\n", "output": ["7226127039816418"]}, {"input": "1000\r\n839105509657869885\r\n", "output": ["839105509657869885"]}, {"input": "7501\r\n2542549323761022905\r\n", "output": ["805176557484307547"]}, {"input": "10981\r\n5149151039259677113\r\n", "output": ["748054672922159638"]}, {"input": "123358\r\n458270676485260235\r\n", "output": ["860152492903254335"]}, {"input": "2567853\r\n5247911636981396703\r\n", "output": ["346042641011647808"]}, {"input": "56132425\r\n3102369282985322\r\n", "output": ["10027171005317597"]}, {"input": "378135456\r\n42831383491941211\r\n", "output": ["582652156959951259"]}, {"input": "3\r\n110021012201002100122001102110010002\r\n", "output": ["68193483524125904"]}, {"input": "23\r\n12007622911918220\r\n", "output": ["1781911903273803"]}, {"input": "456\r\n82103391245145170\r\n", "output": ["1621222691867186"]}, {"input": "7897\r\n14412516641926184\r\n", "output": ["6062228032315859"]}, {"input": "23156\r\n27612518525717145\r\n", "output": ["3433598652149101"]}, {"input": "467879\r\n333380108424158040\r\n", "output": ["72980519445207316"]}, {"input": "7982154\r\n129530518193255487\r\n", "output": ["82535003403725833"]}, {"input": "21354646\r\n47160699363858581\r\n", "output": ["21776150370291089"]}, {"input": "315464878\r\n113635473256292967\r\n", "output": ["35848000882710261"]}, {"input": "1000000000\r\n17289468142098026\r\n", "output": ["17289468142098026"]}, {"input": "4\r\n200002312103012003212121020\r\n", "output": ["9019726702208584"]}, {"input": "46\r\n342836241940392925\r\n", "output": ["694167817136539"]}, {"input": "145\r\n357987665524124\r\n", "output": ["330396354354854"]}, {"input": "1344\r\n2498394521019605\r\n", "output": ["814487257688093"]}, {"input": "57974\r\n3619236326439503\r\n", "output": ["7079242212325439"]}, {"input": "215467\r\n2082791630100848\r\n", "output": ["966934630351661"]}, {"input": "7956123\r\n6718643712272358\r\n", "output": ["4255926011071634"]}, {"input": "13568864\r\n2513398972677784\r\n", "output": ["4621032639107192"]}, {"input": "789765212\r\n1039927282755769\r\n", "output": ["821298450375293"]}, {"input": "1000000000\r\n7289468142097485\r\n", "output": ["7289468142097485"]}, {"input": "5\r\n22011100004310232330\r\n", "output": ["45965585242840"]}, {"input": "98\r\n11291073236468\r\n", "output": ["10007394522984"]}, {"input": "364\r\n284155255182196\r\n", "output": ["4993183241788"]}, {"input": "8742\r\n111445644633405\r\n", "output": ["74498130012303"]}, {"input": "11346\r\n573275516211238\r\n", "output": ["83675287784142"]}, {"input": "442020\r\n13825031303078\r\n", "output": ["26973736400898"]}, {"input": "1740798\r\n321470190942028\r\n", "output": ["99531390411376"]}, {"input": "25623752\r\n25636131538378\r\n", "output": ["65689385274354"]}, {"input": "814730652\r\n56899767577002\r\n", "output": ["46358126945150"]}, {"input": "6\r\n5543321344052\r\n", "output": ["12975669536"]}, {"input": "79\r\n9653454753\r\n", "output": ["27953623755"]}, {"input": "158\r\n25832612364\r\n", "output": ["15908078858"]}, {"input": "1675\r\n11480678916\r\n", "output": ["8852883441"]}, {"input": "12650\r\n25380755475\r\n", "output": ["40587846725"]}, {"input": "165726\r\n465015206\r\n", "output": ["770641106"]}, {"input": "2015054\r\n30501583737\r\n", "output": ["6147498437"]}, {"input": "98000000\r\n19440834812\r\n", "output": ["19052834812"]}, {"input": "157137373\r\n525141766938\r\n", "output": ["82638887763"]}, {"input": "7\r\n441214552\r\n", "output": ["26508694"]}, {"input": "294\r\n2251151163\r\n", "output": ["72564361"]}, {"input": "2707\r\n11341512\r\n", "output": ["3071250"]}, {"input": "76559\r\n100147383\r\n", "output": ["76682942"]}, {"input": "124849\r\n6172319\r\n", "output": ["7688108"]}, {"input": "7014809\r\n73084644\r\n", "output": ["52188307"]}, {"input": "10849219\r\n65200749\r\n", "output": ["70296063"]}, {"input": "905835986\r\n371320\r\n", "output": ["371320"]}, {"input": "1000000000\r\n69204007\r\n", "output": ["69204007"]}, {"input": "8\r\n2670\r\n", "output": ["1464"]}, {"input": "25\r\n71610\r\n", "output": ["4785"]}, {"input": "1468\r\n21107\r\n", "output": ["4043"]}, {"input": "5723\r\n4907\r\n", "output": ["4907"]}, {"input": "251546\r\n7278\r\n", "output": ["7278"]}, {"input": "9\r\n78\r\n", "output": ["71"]}, {"input": "13\r\n41\r\n", "output": ["53"]}, {"input": "34\r\n13\r\n", "output": ["13"]}, {"input": "45\r\n22\r\n", "output": ["22"]}, {"input": "67\r\n29\r\n", "output": ["29"]}, {"input": "130\r\n100\r\n", "output": ["100"]}, {"input": "2\r\n1\r\n", "output": ["1"]}, {"input": "4\r\n1\r\n", "output": ["1"]}, {"input": "9\r\n3\r\n", "output": ["3"]}, {"input": "13\r\n9\r\n", "output": ["9"]}, {"input": "3215\r\n3\r\n", "output": ["3"]}, {"input": "1000000000\r\n6\r\n", "output": ["6"]}, {"input": "2\r\n0\r\n", "output": ["0"]}, {"input": "1000000000\r\n0\r\n", "output": ["0"]}, {"input": "378\r\n1378\r\n", "output": ["4992"]}, {"input": "378\r\n380378377\r\n", "output": ["65568783041"]}, {"input": "2\r\n10000000000000000000000000\r\n", "output": ["33554432"]}, {"input": "2\r\n10000000000000000000000000000\r\n", "output": ["268435456"]}, {"input": "2\r\n100000000000000000000000\r\n", "output": ["8388608"]}] | 100 | 100 | 100 | [{'input': '2\r\n10000000000000000000000000000\r\n', 'output': ['268435456']}, {'input': '130\r\n100\r\n', 'output': ['100']}, {'input': '7501\r\n2542549323761022905\r\n', 'output': ['805176557484307547']}, {'input': '11\r\n1107835458761401923\r\n', 'output': ['997343614685146644']}, {'input': '50\r\n303521849112318129\r\n', 'output': ['59962796634170079']}] | [{'input': '124849\r\n6172319\r\n', 'output': ['7688108']}, {'input': '215467\r\n2082791630100848\r\n', 'output': ['966934630351661']}, {'input': '13\r\n41\r\n', 'output': ['53']}, {'input': '5\r\n22011100004310232330\r\n', 'output': ['45965585242840']}, {'input': '315464878\r\n113635473256292967\r\n', 'output': ['35848000882710261']}] | [{'input': '7501\r\n2542549323761022905\r\n', 'output': ['805176557484307547']}, {'input': '7014809\r\n73084644\r\n', 'output': ['52188307']}, {'input': '2\r\n1110110101111000010001011110101001011001110000000010111010\r\n', 'output': ['267367244641009850']}, {'input': '13\r\n12\r\n', 'output': ['12']}, {'input': '165726\r\n465015206\r\n', 'output': ['770641106']}] | [{'input': '9\r\n78\r\n', 'output': ['71']}, {'input': '9\r\n1733607167155630041\r\n', 'output': ['273150934002691930']}, {'input': '2\r\n100000000000000000000000\r\n', 'output': ['8388608']}, {'input': '25\r\n71610\r\n', 'output': ['4785']}, {'input': '7014809\r\n73084644\r\n', 'output': ['52188307']}] | [{'input': '67\r\n29\r\n', 'output': ['29']}, {'input': '6\r\n5543321344052\r\n', 'output': ['12975669536']}, {'input': '10849219\r\n65200749\r\n', 'output': ['70296063']}, {'input': '4\r\n32323300000100133222012211322\r\n', 'output': ['269019726702209402']}, {'input': '25\r\n2172214240\r\n', 'output': ['26524975']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 96.43 | 100 | 43 | 100 | 100 | 99.286 |
["1 1", "1 2", "2 1"] | The single line contains two integers r,βh (1ββ€βr,βhββ€β107). | ae883bf16842c181ea4bd123dee12ef9 | #include<stdio.h>
#include<math.h>
int r,h,vol;
int main()
{
scanf(" %d %d",&r,&h);
vol = h / r * 2;
h %= r;
if (2*h<r)
vol++;
else if(h*2 >= sqrt(3)*r)
vol += 3;
else
vol += 2;
printf("%d",vol);
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': '100 50\r\n', 'output': ['2']}, {'input': '100 199\r\n', 'output': ['5']}, {'input': '5 11\r\n', 'output': ['5']}, {'input': '2 3\r\n', 'output': ['4']}, {'input': '10000000 8660255\r\n', 'output': ['3']}] | [{'input': '5 11\r\n', 'output': ['5']}, {'input': '667586 5534221\r\n', 'output': ['17']}, {'input': '2000000 1999999\r\n', 'output': ['3']}, {'input': '1000000 1999999\r\n', 'output': ['5']}, {'input': '2 2\r\n', 'output': ['3']}] | [{'input': '5 2\r\n', 'output': ['1']}, {'input': '2377906 4774524\r\n', 'output': ['5']}, {'input': '5 5\r\n', 'output': ['3']}, {'input': '5 10\r\n', 'output': ['5']}, {'input': '3983458 7761504\r\n', 'output': ['5']}] | [{'input': '874 9131511\r\n', 'output': ['20897']}, {'input': '1000000 1999999\r\n', 'output': ['5']}, {'input': '10 19\r\n', 'output': ['5']}, {'input': '5 11\r\n', 'output': ['5']}, {'input': '2 2\r\n', 'output': ['3']}] | [{'input': '10000000 866254\r\n', 'output': ['1']}, {'input': '667586 5534221\r\n', 'output': ['17']}, {'input': '874 9131511\r\n', 'output': ['20897']}, {'input': '1 1\r\n', 'output': ['3']}, {'input': '5 1\r\n', 'output': ['1']}] | 100 | 100 | 100 | 100 | 100 | 100 | 90.91 | 90.91 | 90.91 | 90.91 | 100 | 75 | 75 | 75 | 75 | 44 | 100 | 92.728 | 80 |
["10 30\n10 35\n05:20", "60 120\n24 100\n13:00"] | The first line contains two integers a,βta (1ββ€βa,βtaββ€β120) β the frequency of the buses from the city A to the city B and the travel time. Both values are given in minutes. The second line contains two integers b,βtb (1ββ€βb,βtbββ€β120) β the frequency of the buses from the city B to the city A and the travel time. Both values are given in minutes. The last line contains the departure time of Simion from the city A in the format hh:mm. It is guaranteed that there are a bus from the city A at that time. Note that the hours and the minutes are given with exactly two digits. | 1c4cf1c3cb464a483511a8a61f8685a7 | #include<stdio.h>
int main()
{
int a,ta;
scanf("%d%d",&a,&ta);
int b,tb;
scanf("%d%d",&b,&tb);
int h,m;
scanf("%d:%d",&h,&m);
int x,y,w=0,z=300;
x=60*h+m;
y=60*h+m+ta;
jump:
if(z+tb<x)
{
z=z+b;
goto jump;
}
else if(z+tb>x && z<y && z<1440)
{
w+=1;
z=z+b;
goto jump;
}
else if(z>y)
{
goto temp;
}
else if(z+tb==x || z==y)
{
z=z+b;
goto jump;
}
temp:
printf("%d\n",w);
return 0;
} | ["5", "9"] | C | NoteIn the first example Simion departs form the city A at 05:20 AM and arrives to the city B at 05:50 AM. He will meet the first 5 buses from the city B that departed in the period [05:00 AM - 05:40 AM]. Also Simion will meet a bus in the city B at 05:50 AM, but he will not count it.Also note that the first encounter will be between 05:26 AM and 05:27 AM (if we suggest that the buses are go with the sustained speed). | Print the only integer z β the number of buses Simion will meet on the way. Note that you should not count the encounters in cities A and B. | Buses run between the cities A and B, the first one is at 05:00 AM and the last one departs not later than at 11:59 PM. A bus from the city A departs every a minutes and arrives to the city B in a ta minutes, and a bus from the city B departs every b minutes and arrives to the city A in a tb minutes.The driver Simion wants to make his job diverse, so he counts the buses going towards him. Simion doesn't count the buses he meet at the start and finish.You know the time when Simion departed from the city A to the city B. Calculate the number of buses Simion will meet to be sure in his counting. | [{"input": "10 30\r\n10 35\r\n05:20\r\n", "output": ["5"]}, {"input": "60 120\r\n24 100\r\n13:00\r\n", "output": ["9"]}, {"input": "30 60\r\n60 60\r\n22:30\r\n", "output": ["2"]}, {"input": "30 60\r\n10 60\r\n23:30\r\n", "output": ["8"]}, {"input": "5 45\r\n4 60\r\n21:00\r\n", "output": ["26"]}, {"input": "1 1\r\n1 1\r\n10:28\r\n", "output": ["1"]}, {"input": "4 1\r\n5 4\r\n18:40\r\n", "output": ["1"]}, {"input": "8 8\r\n1 1\r\n13:24\r\n", "output": ["8"]}, {"input": "20 4\r\n1 20\r\n06:20\r\n", "output": ["23"]}, {"input": "15 24\r\n23 6\r\n21:15\r\n", "output": ["1"]}, {"input": "30 19\r\n21 4\r\n10:30\r\n", "output": ["1"]}, {"input": "31 15\r\n36 25\r\n07:04\r\n", "output": ["1"]}, {"input": "24 3\r\n54 9\r\n18:12\r\n", "output": ["0"]}, {"input": "18 69\r\n62 54\r\n08:00\r\n", "output": ["2"]}, {"input": "33 58\r\n70 78\r\n22:36\r\n", "output": ["2"]}, {"input": "68 34\r\n84 78\r\n10:40\r\n", "output": ["1"]}, {"input": "15 14\r\n32 65\r\n05:45\r\n", "output": ["2"]}, {"input": "40 74\r\n100 42\r\n05:40\r\n", "output": ["2"]}, {"input": "65 49\r\n24 90\r\n07:10\r\n", "output": ["6"]}, {"input": "1 1\r\n1 1\r\n23:59\r\n", "output": ["1"]}, {"input": "23 118\r\n118 20\r\n23:24\r\n", "output": ["0"]}, {"input": "3 88\r\n17 38\r\n22:33\r\n", "output": ["8"]}, {"input": "3 1\r\n2 3\r\n05:03\r\n", "output": ["1"]}, {"input": "1 1\r\n3 2\r\n08:44\r\n", "output": ["0"]}, {"input": "1 3\r\n1 2\r\n21:43\r\n", "output": ["4"]}, {"input": "2 28\r\n2 12\r\n05:12\r\n", "output": ["19"]}, {"input": "60 120\r\n17 120\r\n23:00\r\n", "output": ["11"]}, {"input": "1 55\r\n1 54\r\n23:59\r\n", "output": ["54"]}, {"input": "66 75\r\n1 82\r\n06:06\r\n", "output": ["141"]}, {"input": "1 90\r\n1 88\r\n23:59\r\n", "output": ["88"]}, {"input": "1 120\r\n1 100\r\n23:59\r\n", "output": ["100"]}] | 100 | 100 | 100 | [{'input': '30 60\r\n60 60\r\n22:30\r\n', 'output': ['2']}, {'input': '18 69\r\n62 54\r\n08:00\r\n', 'output': ['2']}, {'input': '5 45\r\n4 60\r\n21:00\r\n', 'output': ['26']}, {'input': '66 75\r\n1 82\r\n06:06\r\n', 'output': ['141']}, {'input': '24 3\r\n54 9\r\n18:12\r\n', 'output': ['0']}] | [{'input': '3 88\r\n17 38\r\n22:33\r\n', 'output': ['8']}, {'input': '24 3\r\n54 9\r\n18:12\r\n', 'output': ['0']}, {'input': '1 120\r\n1 100\r\n23:59\r\n', 'output': ['100']}, {'input': '20 4\r\n1 20\r\n06:20\r\n', 'output': ['23']}, {'input': '8 8\r\n1 1\r\n13:24\r\n', 'output': ['8']}] | [{'input': '1 1\r\n1 1\r\n23:59\r\n', 'output': ['1']}, {'input': '1 1\r\n3 2\r\n08:44\r\n', 'output': ['0']}, {'input': '24 3\r\n54 9\r\n18:12\r\n', 'output': ['0']}, {'input': '60 120\r\n17 120\r\n23:00\r\n', 'output': ['11']}, {'input': '15 24\r\n23 6\r\n21:15\r\n', 'output': ['1']}] | [{'input': '68 34\r\n84 78\r\n10:40\r\n', 'output': ['1']}, {'input': '1 1\r\n1 1\r\n10:28\r\n', 'output': ['1']}, {'input': '30 60\r\n60 60\r\n22:30\r\n', 'output': ['2']}, {'input': '31 15\r\n36 25\r\n07:04\r\n', 'output': ['1']}, {'input': '30 19\r\n21 4\r\n10:30\r\n', 'output': ['1']}] | [{'input': '1 1\r\n1 1\r\n10:28\r\n', 'output': ['1']}, {'input': '33 58\r\n70 78\r\n22:36\r\n', 'output': ['2']}, {'input': '30 60\r\n60 60\r\n22:30\r\n', 'output': ['2']}, {'input': '1 1\r\n3 2\r\n08:44\r\n', 'output': ['0']}, {'input': '3 88\r\n17 38\r\n22:33\r\n', 'output': ['8']}] | 100 | 100 | 100 | 100 | 100 | 95.65 | 100 | 100 | 95.65 | 95.65 | 85.71 | 100 | 100 | 85.71 | 85.71 | 45 | 100 | 97.39 | 91.426 |
["........\n........\n.B....B.\n....W...\n........\n..W.....\n........\n........", "..B.....\n..W.....\n......B.\n........\n.....W..\n......B.\n........\n........"] | The input consists of the board description given in eight lines, each line contains eight characters. Character 'B' is used to denote a black pawn, and character 'W' represents a white pawn. Empty cell is marked with '.'. It's guaranteed that there will not be white pawns on the first row neither black pawns on the last row. | 0ddc839e17dee20e1a954c1289de7fbd | #include<stdio.h>
typedef unsigned u;
u A[8],B[8];
int main()
{
u i,j,a,b;char c;
for(a=b=i=-1;++i<8;)A[i]=B[i]=-1;
for(i=-1;++i<8;)for(j=-1;++j<8;)
{
while((c=getchar())<=' ');
if(c=='B')B[j]=i;
if(c=='W'&&A[j]==-1u)
{
if(B[j]==-1u)A[j]=i;
else B[j]=-1u;
}
}
for(i=-1;++i<8;)
{
if(a>A[i])a=A[i];
if(B[i]!=-1u&&b>7-B[i])b=7-B[i];
}
printf(a>b?"B\n":"A\n");
return 0;
}
| ["A", "B"] | C | NoteIn the first sample player A is able to complete his goal in 3 steps by always moving a pawn initially located at (4,β5). Player B needs at least 5 steps for any of his pawns to reach the row 8. Hence, player A will be the winner. | Print 'A' if player A wins the game on the given board, and 'B' if player B will claim the victory. Again, it's guaranteed that there will always be a winner on the given board. | Galois is one of the strongest chess players of Byteforces. He has even invented a new variant of chess, which he named Β«PawnChessΒ».This new game is played on a board consisting of 8 rows and 8 columns. At the beginning of every game some black and white pawns are placed on the board. The number of black pawns placed is not necessarily equal to the number of white pawns placed. Lets enumerate rows and columns with integers from 1 to 8. Rows are numbered from top to bottom, while columns are numbered from left to right. Now we denote as (r,βc) the cell located at the row r and at the column c.There are always two players A and B playing the game. Player A plays with white pawns, while player B plays with black ones. The goal of player A is to put any of his pawns to the row 1, while player B tries to put any of his pawns to the row 8. As soon as any of the players completes his goal the game finishes immediately and the succeeded player is declared a winner.Player A moves first and then they alternate turns. On his move player A must choose exactly one white pawn and move it one step upward and player B (at his turn) must choose exactly one black pawn and move it one step down. Any move is possible only if the targeted cell is empty. It's guaranteed that for any scenario of the game there will always be at least one move available for any of the players.Moving upward means that the pawn located in (r,βc) will go to the cell (rβ-β1,βc), while moving down means the pawn located in (r,βc) will go to the cell (rβ+β1,βc). Again, the corresponding cell must be empty, i.e. not occupied by any other pawn of any color.Given the initial disposition of the board, determine who wins the game if both players play optimally. Note that there will always be a winner due to the restriction that for any game scenario both players will have some moves available. | [{"input": "........\r\n........\r\n.B....B.\r\n....W...\r\n........\r\n..W.....\r\n........\r\n........\r\n", "output": ["A"]}, {"input": "..B.....\r\n..W.....\r\n......B.\r\n........\r\n.....W..\r\n......B.\r\n........\r\n........\r\n", "output": ["B"]}, {"input": ".BB.B.B.\r\nB..B..B.\r\n.B.BB...\r\nBB.....B\r\nBBB....B\r\nB..BB...\r\nBB.B...B\r\n....WWW.\r\n", "output": ["B"]}, {"input": "..BB....\r\n........\r\nWW.W..WW\r\nW...W...\r\n.W...W..\r\n.W..W.WW\r\nW.....WW\r\nWW......\r\n", "output": ["A"]}, {"input": "BB....B.\r\nB.....B.\r\n.....B..\r\n..B...BB\r\n.W.BWBWB\r\n....W...\r\nWW.WWW..\r\n....W...\r\n", "output": ["B"]}, {"input": "B.B.BB.B\r\nW.WWW.WW\r\n.WWWWW.W\r\nW.BB.WBW\r\n.W..BBWB\r\nBB.WWBBB\r\n.W.W.WWB\r\nWWW..WW.\r\n", "output": ["A"]}, {"input": "BB..BB..\r\nBW.W.W.B\r\n..B.....\r\n.....BB.\r\n.B..B..B\r\n........\r\n...BB.B.\r\nW.WWWW.W\r\n", "output": ["A"]}, {"input": "BB......\r\nW....BBW\r\n........\r\n.B.B.BBB\r\n....BB..\r\nB....BB.\r\n...WWWW.\r\n....WW..\r\n", "output": ["A"]}, {"input": ".B.B..B.\r\nB.B....B\r\n...B.B.B\r\n..B.W..B\r\n.BBB.B.B\r\nB.BB.B.B\r\nBB..BBBB\r\nW.W.W.WW\r\n", "output": ["B"]}, {"input": "..BB....\r\n.B.B.B.B\r\n..B.B...\r\n..B..B.B\r\nWWWBWWB.\r\n.BB...B.\r\n..BBB...\r\n......W.\r\n", "output": ["B"]}, {"input": "..BB....\r\n.WBWBWBB\r\n.....BBB\r\n..WW....\r\n.W.W...W\r\nWWW...W.\r\n.W....W.\r\nW...W.W.\r\n", "output": ["A"]}, {"input": "B...BB..\r\nWWBBW.BB\r\n.W.W....\r\nWWWW....\r\nW....W..\r\nW..WW...\r\n...W....\r\nWW.W....\r\n", "output": ["A"]}, {"input": "B..BB..B\r\n..B.B...\r\nBW..BBW.\r\n...B.BBB\r\n.B..BB..\r\n..B.B.BB\r\n........\r\n........\r\n", "output": ["A"]}, {"input": "....BB..\r\nBB......\r\n.B.....B\r\nWW..WWW.\r\n...BB.B.\r\nB...BB..\r\n..W..WWW\r\n...W...W\r\n", "output": ["B"]}, {"input": "B...BBBB\r\n...BBB..\r\nBBWBWW.W\r\n.B..BB.B\r\nW..W..WW\r\nW.WW....\r\n........\r\nWW.....W\r\n", "output": ["A"]}, {"input": ".BB..B..\r\n.B.....B\r\n.B......\r\n.B...B..\r\n.......B\r\n.WWB.WWB\r\nW.....W.\r\n...W....\r\n", "output": ["B"]}, {"input": ".B......\r\n.B....B.\r\n...W....\r\n......W.\r\nW.WWWW.W\r\nW.WW....\r\n..WWW...\r\n..W...WW\r\n", "output": ["A"]}, {"input": "B.......\r\nBBB.....\r\n.B....B.\r\n.W.BWB.W\r\n......B.\r\nW..WW...\r\n...W....\r\nW...W..W\r\n", "output": ["A"]}, {"input": ".B......\r\n.B...B.B\r\n.B..B.BB\r\nW.......\r\n..W.....\r\n..WWW...\r\n.......W\r\n........\r\n", "output": ["A"]}, {"input": ".....B..\r\n........\r\n........\r\n.BB..B..\r\n..BB....\r\n........\r\n....WWW.\r\n......W.\r\n", "output": ["B"]}, {"input": "B.B...B.\r\n...BBBBB\r\n....B...\r\n...B...B\r\nB.B.B..B\r\n........\r\n........\r\nWWW..WW.\r\n", "output": ["B"]}, {"input": "B.B...B.\r\n........\r\n.......B\r\n.BB....B\r\n.....W..\r\n.W.WW.W.\r\n...W.WW.\r\nW..WW..W\r\n", "output": ["A"]}, {"input": "......B.\r\nB....B..\r\n...B.BB.\r\n...B....\r\n........\r\n..W....W\r\nWW......\r\n.W....W.\r\n", "output": ["B"]}, {"input": ".BBB....\r\nB.B.B...\r\nB.BB.B..\r\nB.BB.B.B\r\n........\r\n........\r\nW.....W.\r\n..WW..W.\r\n", "output": ["B"]}, {"input": "..B..BBB\r\n........\r\n........\r\n........\r\n...W.W..\r\n...W..W.\r\nW.......\r\n..W...W.\r\n", "output": ["A"]}, {"input": "........\r\n.B.B....\r\n...B..BB\r\n........\r\n........\r\nW...W...\r\nW...W...\r\nW.WW.W..\r\n", "output": ["A"]}, {"input": "...B..BB\r\n.B..B..B\r\n........\r\n........\r\n........\r\nW..W....\r\n.....WW.\r\n.W......\r\n", "output": ["A"]}, {"input": "B....BB.\r\n...B...B\r\n.B......\r\n........\r\n........\r\n........\r\n........\r\n....W..W\r\n", "output": ["B"]}, {"input": "...BB.BB\r\nBB...B..\r\n........\r\n........\r\n........\r\n........\r\n..W..W..\r\n......W.\r\n", "output": ["A"]}, {"input": "...BB...\r\n........\r\n........\r\n........\r\n........\r\n........\r\n......W.\r\nWW...WW.\r\n", "output": ["A"]}, {"input": "...B.B..\r\n........\r\n........\r\n........\r\n........\r\n........\r\n........\r\nWWW...WW\r\n", "output": ["A"]}, {"input": "BBBBBBB.\r\n........\r\n........\r\n........\r\n........\r\n........\r\n........\r\n.WWWWWWW\r\n", "output": ["A"]}, {"input": ".BBBBBB.\r\nB.......\r\n........\r\n........\r\n........\r\n........\r\n........\r\n.WWWWWWW\r\n", "output": ["B"]}, {"input": ".BBBBBBB\r\n........\r\n........\r\n........\r\n........\r\n........\r\n........\r\nWWWWWWW.\r\n", "output": ["A"]}, {"input": ".BBBBBB.\r\n.......B\r\n........\r\n........\r\n........\r\n........\r\n........\r\nWWWWWWW.\r\n", "output": ["B"]}, {"input": "B..BB...\r\n..B...B.\r\n.WBB...B\r\nBW......\r\nW.B...W.\r\n..BBW.B.\r\nBW..BB..\r\n......W.\r\n", "output": ["B"]}, {"input": "BBB.BBBB\r\nWB.W..B.\r\nBBBB...B\r\nB..B....\r\n.......W\r\n.BWB..BB\r\nB..BW.BW\r\n.W......\r\n", "output": ["A"]}, {"input": "B.BBBBBB\r\nB..BBB.B\r\nW.BB.W.B\r\nB.BWBB.B\r\nBWBWBBBB\r\n...BBBBB\r\nB.B...BB\r\nWW..WW.W\r\n", "output": ["B"]}, {"input": "BBBB.BBB\r\nBBBB.B.B\r\nB.B..BBB\r\nB.BB.BWW\r\nB.BB.BBB\r\nB.BB.BBB\r\n..BW.BB.\r\nW.WWWWWW\r\n", "output": ["B"]}, {"input": "BBBB.BBB\r\n.B....WB\r\nBB.B...B\r\nWWWW.WWB\r\nBB...BWW\r\nWWW..BBB\r\nW.BW.BB.\r\nWWWWWWW.\r\n", "output": ["B"]}, {"input": "B.BBBBBB\r\nW.WWBBBW\r\nW.BB.WBB\r\nW.W.BBBW\r\nW.BWW.WB\r\nB..B..BB\r\nB.B.W.BB\r\nWWWWW.WW\r\n", "output": ["B"]}, {"input": "BBBBBB.B\r\n.BBWBB.B\r\nWWW..B.W\r\n..WW.W.W\r\nBWB..W.W\r\n..BW.B.W\r\nB..B....\r\nWWWW.WWW\r\n", "output": ["B"]}, {"input": ".B...BB.\r\nWBB.BWBB\r\n.BWBW...\r\n..W...B.\r\nWB.BWW..\r\nWBW.....\r\n.W..W.B.\r\n.W.W.WW.\r\n", "output": ["A"]}, {"input": ".B..BBBB\r\nBB...WWB\r\nB..B.W.B\r\nWB.W...B\r\n...W.WW.\r\nW.....W.\r\nWB.W.W.W\r\n.WW...WW\r\n", "output": ["A"]}, {"input": "B.BBBBBB\r\nW.BB.W.B\r\nW.BBW...\r\n..WWWW.B\r\n....W..B\r\n.WW.W..W\r\n.W..WW.W\r\nW.W....W\r\n", "output": ["A"]}, {"input": "........\r\n.......W\r\n........\r\n........\r\n........\r\n........\r\n.......B\r\n........\r\n", "output": ["A"]}, {"input": "..B.....\r\n..W.....\r\n.W....B.\r\n........\r\n.B...W..\r\n......B.\r\n.W......\r\n........\r\n", "output": ["A"]}, {"input": "........\r\nB.......\r\n........\r\n........\r\n........\r\n........\r\n.......W\r\n........\r\n", "output": ["A"]}, {"input": "........\r\n........\r\n........\r\n.W......\r\n......B.\r\n........\r\n........\r\n........\r\n", "output": ["A"]}, {"input": "........\r\nB.......\r\nW.......\r\n.......B\r\n........\r\n........\r\n........\r\n...W....\r\n", "output": ["B"]}, {"input": "........\r\n.B......\r\n.W......\r\n........\r\n....B...\r\n........\r\n........\r\n.......W\r\n", "output": ["B"]}, {"input": "........\r\n..B.....\r\n..W...B.\r\n........\r\n.....W..\r\n......B.\r\n........\r\n........\r\n", "output": ["B"]}, {"input": "........\r\nW.......\r\n........\r\n........\r\n........\r\n........\r\n.......B\r\n........\r\n", "output": ["A"]}, {"input": "........\r\n........\r\n........\r\n........\r\nW.......\r\nB.......\r\n........\r\n........\r\n", "output": ["B"]}, {"input": "........\r\n........\r\n.W......\r\n........\r\n........\r\n........\r\n.B......\r\n........\r\n", "output": ["B"]}, {"input": "........\r\nB.......\r\nW.......\r\n.W......\r\n........\r\nB.......\r\n........\r\n........\r\n", "output": ["B"]}] | 100 | 100 | 100 | [{'input': '........\r\n.B.B....\r\n...B..BB\r\n........\r\n........\r\nW...W...\r\nW...W...\r\nW.WW.W..\r\n', 'output': ['A']}, {'input': 'B.BBBBBB\r\nB..BBB.B\r\nW.BB.W.B\r\nB.BWBB.B\r\nBWBWBBBB\r\n...BBBBB\r\nB.B...BB\r\nWW..WW.W\r\n', 'output': ['B']}, {'input': '....BB..\r\nBB......\r\n.B.....B\r\nWW..WWW.\r\n...BB.B.\r\nB...BB..\r\n..W..WWW\r\n...W...W\r\n', 'output': ['B']}, {'input': '........\r\n.......W\r\n........\r\n........\r\n........\r\n........\r\n.......B\r\n........\r\n', 'output': ['A']}, {'input': '.B...BB.\r\nWBB.BWBB\r\n.BWBW...\r\n..W...B.\r\nWB.BWW..\r\nWBW.....\r\n.W..W.B.\r\n.W.W.WW.\r\n', 'output': ['A']}] | [{'input': 'BBBB.BBB\r\nBBBB.B.B\r\nB.B..BBB\r\nB.BB.BWW\r\nB.BB.BBB\r\nB.BB.BBB\r\n..BW.BB.\r\nW.WWWWWW\r\n', 'output': ['B']}, {'input': '...BB.BB\r\nBB...B..\r\n........\r\n........\r\n........\r\n........\r\n..W..W..\r\n......W.\r\n', 'output': ['A']}, {'input': '........\r\n........\r\n.W......\r\n........\r\n........\r\n........\r\n.B......\r\n........\r\n', 'output': ['B']}, {'input': 'B..BB..B\r\n..B.B...\r\nBW..BBW.\r\n...B.BBB\r\n.B..BB..\r\n..B.B.BB\r\n........\r\n........\r\n', 'output': ['A']}, {'input': '........\r\n..B.....\r\n..W...B.\r\n........\r\n.....W..\r\n......B.\r\n........\r\n........\r\n', 'output': ['B']}] | [{'input': '..BB....\r\n........\r\nWW.W..WW\r\nW...W...\r\n.W...W..\r\n.W..W.WW\r\nW.....WW\r\nWW......\r\n', 'output': ['A']}, {'input': '........\r\n........\r\n........\r\n.W......\r\n......B.\r\n........\r\n........\r\n........\r\n', 'output': ['A']}, {'input': '........\r\n.B......\r\n.W......\r\n........\r\n....B...\r\n........\r\n........\r\n.......W\r\n', 'output': ['B']}, {'input': 'B.B.BB.B\r\nW.WWW.WW\r\n.WWWWW.W\r\nW.BB.WBW\r\n.W..BBWB\r\nBB.WWBBB\r\n.W.W.WWB\r\nWWW..WW.\r\n', 'output': ['A']}, {'input': '.B...BB.\r\nWBB.BWBB\r\n.BWBW...\r\n..W...B.\r\nWB.BWW..\r\nWBW.....\r\n.W..W.B.\r\n.W.W.WW.\r\n', 'output': ['A']}] | [{'input': '...B.B..\r\n........\r\n........\r\n........\r\n........\r\n........\r\n........\r\nWWW...WW\r\n', 'output': ['A']}, {'input': 'B.B...B.\r\n........\r\n.......B\r\n.BB....B\r\n.....W..\r\n.W.WW.W.\r\n...W.WW.\r\nW..WW..W\r\n', 'output': ['A']}, {'input': 'BBBB.BBB\r\nBBBB.B.B\r\nB.B..BBB\r\nB.BB.BWW\r\nB.BB.BBB\r\nB.BB.BBB\r\n..BW.BB.\r\nW.WWWWWW\r\n', 'output': ['B']}, {'input': 'B.B...B.\r\n...BBBBB\r\n....B...\r\n...B...B\r\nB.B.B..B\r\n........\r\n........\r\nWWW..WW.\r\n', 'output': ['B']}, {'input': 'BB....B.\r\nB.....B.\r\n.....B..\r\n..B...BB\r\n.W.BWBWB\r\n....W...\r\nWW.WWW..\r\n....W...\r\n', 'output': ['B']}] | [{'input': 'B..BB...\r\n..B...B.\r\n.WBB...B\r\nBW......\r\nW.B...W.\r\n..BBW.B.\r\nBW..BB..\r\n......W.\r\n', 'output': ['B']}, {'input': 'B....BB.\r\n...B...B\r\n.B......\r\n........\r\n........\r\n........\r\n........\r\n....W..W\r\n', 'output': ['B']}, {'input': '........\r\nW.......\r\n........\r\n........\r\n........\r\n........\r\n.......B\r\n........\r\n', 'output': ['A']}, {'input': '........\r\n........\r\n........\r\n.W......\r\n......B.\r\n........\r\n........\r\n........\r\n', 'output': ['A']}, {'input': 'BBBB.BBB\r\n.B....WB\r\nBB.B...B\r\nWWWW.WWB\r\nBB...BWW\r\nWWW..BBB\r\nW.BW.BB.\r\nWWWWWWW.\r\n', 'output': ['B']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 96.15 | 100 | 100 | 100 | 46 | 100 | 100 | 99.23 |
["3\n141 592 653", "5\n10 21 10 21 10"] | Input will begin with an integer N (1ββ€βNββ€β50), the number of slices of pie. Following this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out. | 414540223db9d4cfcec6a973179a0216 | #include<stdio.h>
int max(int a,int b)
{
if(a>=b)return a;
else return b;
}
int main()
{
int ca[52];
int n;scanf("%d",&n);
int sumi[52];
int sum=0;
int dp[52]={-1};
int i=0;
for(i=0;i<n;i++)
{
scanf("%d",&ca[i]);
sum += ca[i];
sumi[i] = sum;
}
dp[n-1]=ca[n-1];
for(i=n-2;i>=0;i--)
{
dp[i]=max((ca[i]+(sumi[n-1]-dp[i+1]-sumi[i])),dp[i+1]);
}
int ans = dp[0];
int ans1 = sumi[n-1]-dp[0];
printf("%d %d\n",ans1,ans);
return 0;
}
| ["653 733", "31 41"] | C | NoteIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself. | Print two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally. | You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.The way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the "decider" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.All of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive? | [{"input": "3\r\n141 592 653\r\n", "output": ["653 733"]}, {"input": "5\r\n10 21 10 21 10\r\n", "output": ["31 41"]}, {"input": "1\r\n100000\r\n", "output": ["0 100000"]}, {"input": "50\r\n100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000\r\n", "output": ["2500000 2500000"]}, {"input": "2\r\n1 100000\r\n", "output": ["1 100000"]}, {"input": "17\r\n1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536\r\n", "output": ["65535 65536"]}, {"input": "15\r\n3026 3027 4599 4854 7086 29504 38709 40467 40663 58674 61008 70794 77517 85547 87320\r\n", "output": ["306375 306420"]}, {"input": "30\r\n2351 14876 66138 87327 29940 73204 19925 50198 13441 54751 1383 92120 90236 13525 3920 16669 80637 94428 54890 71321 77670 57080 82145 39778 69967 38722 46902 82127 1142 21792\r\n", "output": ["724302 724303"]}, {"input": "1\r\n59139\r\n", "output": ["0 59139"]}, {"input": "2\r\n9859 48096\r\n", "output": ["9859 48096"]}, {"input": "3\r\n25987 64237 88891\r\n", "output": ["88891 90224"]}, {"input": "4\r\n9411 13081 2149 19907\r\n", "output": ["19907 24641"]}, {"input": "5\r\n25539 29221 6895 82089 18673\r\n", "output": ["80328 82089"]}, {"input": "6\r\n76259 10770 87448 3054 67926 81667\r\n", "output": ["158428 168696"]}, {"input": "7\r\n92387 35422 24898 32532 92988 84636 99872\r\n", "output": ["192724 270011"]}, {"input": "8\r\n8515 51563 5451 94713 9537 30709 63343 41819\r\n", "output": ["138409 167241"]}, {"input": "9\r\n91939 407 10197 24191 58791 9486 68030 25807 11\r\n", "output": ["102429 186430"]}, {"input": "10\r\n30518 96518 74071 59971 50121 4862 43967 73607 19138 90754\r\n", "output": ["252317 291210"]}, {"input": "11\r\n46646 21171 78816 89449 99375 50934 15950 90299 18702 62232 12657\r\n", "output": ["288850 297381"]}, {"input": "12\r\n30070 37311 92074 18927 91732 29711 12126 41583 52857 99118 73097 33928\r\n", "output": ["296580 315954"]}, {"input": "13\r\n13494 86155 96820 72596 40986 99976 16813 25571 87013 3301 832 26376 83769\r\n", "output": ["325890 327812"]}, {"input": "14\r\n96918 67704 10077 34778 90239 11457 80284 42263 53872 74779 93976 53416 83860 74518\r\n", "output": ["414474 453667"]}, {"input": "15\r\n13046 83844 14823 64255 15301 90234 84972 93547 88028 11665 54415 13159 83950 951 42336\r\n", "output": ["362168 392358"]}, {"input": "16\r\n29174 32688 95377 26437 64554 60498 56955 10239 22183 15847 47559 40199 92552 70488 4147 73082\r\n", "output": ["370791 371188"]}, {"input": "17\r\n79894 24637 8634 80107 81104 39275 53130 94227 56339 87326 7999 75751 92642 96921 74470 20999 69688\r\n", "output": ["492038 551105"]}, {"input": "18\r\n96022 73481 13380 42288 6166 85348 25113 78215 23198 24212 44246 35494 92733 66459 44793 68916 82818 3967\r\n", "output": ["436157 470692"]}, {"input": "19\r\n79446 55030 93934 39062 88123 88317 21289 62203 57354 28394 37390 95238 92823 92892 39308 16833 54733 51525 58759\r\n", "output": ["538648 614005"]}, {"input": "20\r\n5440 88704 61481 72140 15810 58854 43034 5150 80684 61360 50516 54301 78790 43678 46138 79893 89899 60260 2881 66499\r\n", "output": ["506639 558873"]}, {"input": "21\r\n21569 37548 74739 25809 65063 37631 71913 89138 47543 65542 10956 14045 78880 70111 73357 27810 70326 40523 899 6547 87440\r\n", "output": ["506467 510922"]}, {"input": "22\r\n72289 86393 79484 55287 14317 83704 11192 73126 81699 2429 4100 41085 87482 72352 10976 75727 42240 79569 31621 3492 51189 25936\r\n", "output": ["513496 572193"]}, {"input": "23\r\n88417 11045 92742 84765 6675 86673 40072 57114 15854 6611 40347 76636 87572 66082 38195 56348 89962 59831 29640 43541 14937 73713 52755\r\n", "output": ["602650 616877"]}, {"input": "24\r\n71841 27185 73295 46946 55928 65450 12055 73806 82714 78089 787 36380 87663 68323 75814 4265 94581 31581 51850 40486 11390 21491 27560 22678\r\n", "output": ["560664 601494"]}, {"input": "25\r\n87969 76030 78041 616 13694 11522 84038 25090 16869 14975 61226 96124 20457 62052 70329 76374 42303 11844 15276 37430 99330 77781 35069 64358 45168\r\n", "output": ["586407 637558"]}, {"input": "26\r\n71393 24874 91299 30093 62947 14491 80214 41782 51025 19158 21666 23163 20547 64293 40653 24291 46922 92106 13294 77479 63079 25559 42579 62933 24433 39507\r\n", "output": ["569885 599895"]}, {"input": "27\r\n54817 73719 96044 92275 12201 60564 84901 25770 17884 90636 14810 82907 20637 58023 10976 72208 94644 63856 11312 74424 26828 40632 58600 37316 38290 82420 48297\r\n", "output": ["716531 728460"]}, {"input": "28\r\n70945 22563 76598 21753 4558 39341 48372 77054 52039 27522 75249 18459 96536 60264 5491 20125 42367 44118 42034 38665 47472 88410 66109 78995 52147 68436 9814 71112\r\n", "output": ["669482 697066"]}, {"input": "29\r\n54369 14511 14048 83934 53812 75014 20356 17938 86195 31704 68393 78202 96626 86697 75814 746 46985 15868 40052 11417 11221 44700 40915 53378 98708 78644 4035 20164 37165\r\n", "output": ["678299 683312"]}, {"input": "30\r\n4555 13594 57403 75796 14203 12847 66292 60885 9525 40478 57327 69970 15297 37483 39540 31102 14855 412 84174 57684 65591 19837 80431 18385 3107 87740 15433 24854 73472 88205\r\n", "output": ["620095 620382"]}, {"input": "31\r\n20683 29734 37957 37978 63456 58920 70980 44873 76385 44661 17767 97009 15387 63916 77159 79019 86770 4866 14897 63141 86236 67614 87940 60064 16964 97948 9654 49714 30888 88075 63792\r\n", "output": ["825663 838784"]}, {"input": "32\r\n71403 78578 75406 67455 12710 37697 67155 28861 10540 48843 10911 56753 15477 33453 4378 26936 34492 19720 12915 27382 49984 91200 95449 34448 63525 83964 3875 98767 77905 63753 83018 58084\r\n", "output": ["770578 774459"]}, {"input": "33\r\n87531 27423 55960 53829 37771 40665 39138 12849 77399 53025 71350 83793 48271 59887 41997 74854 14919 24175 43637 24327 13733 38978 2959 319 10086 26876 65393 56332 68025 63623 93732 68354 83938\r\n", "output": ["741185 823963"]}, {"input": "34\r\n70955 19371 60706 50603 54321 86738 11122 29541 11555 57207 31790 19344 24170 29424 36512 22771 86833 4437 41655 64376 34378 19459 86276 74702 23943 69789 59614 48489 49634 63494 12958 11328 69333 1736\r\n", "output": ["693927 744637"]}, {"input": "35\r\n54379 920 41259 12784 3574 98219 40001 80825 45710 61390 24933 79088 24260 23153 6835 94880 67260 76187 39673 28616 98126 10341 26489 49085 37800 55805 86539 97542 39754 30660 32184 64703 11625 77872 63584\r\n", "output": ["823487 862568"]}, {"input": "36\r\n37803 17060 78709 42262 28636 68484 79280 97517 12570 98276 52669 6128 57054 58098 68646 75501 39174 56449 3099 1369 94579 58119 1295 90764 51657 66013 48056 55107 54066 30530 75602 74973 21212 21304 22589 4895\r\n", "output": ["872694 876851"]}, {"input": "37\r\n53932 65904 91967 4443 77890 47261 8160 81505 46725 69754 21621 65871 24440 51828 71673 23418 86896 4008 1117 65610 82519 5897 8804 65148 98218 76221 42277 79968 68379 30401 62125 61052 96207 64737 24698 99495 70720\r\n", "output": ["989044 1011845"]}, {"input": "38\r\n70060 14749 72520 58113 2951 26037 80143 32789 80881 73936 82060 92911 24531 78261 9292 71335 91515 8462 31839 62555 46268 29482 92121 31019 12075 94942 36498 96317 58499 30271 81351 71322 81602 8169 26807 69903 38154 20539\r\n", "output": ["977736 1012543"]}, {"input": "39\r\n20780 30889 9970 87591 19501 96302 76318 49481 47740 10823 42500 61167 57325 47798 36511 19252 39237 23316 29857 2603 10016 9964 99630 5402 82828 5150 98015 53882 72811 97437 57473 57400 91189 84305 85811 64503 40179 50614 52044\r\n", "output": ["954593 973021"]}, {"input": "40\r\n3670 5779 20621 87964 12595 34136 98063 92429 38366 43789 88330 52934 19100 22776 43342 82312 74404 64756 73980 14278 21283 85101 63339 70409 63034 14245 33606 58571 84927 14931 25355 15452 46072 4671 5838 69121 18243 87783 29748 84047\r\n", "output": ["909877 959523"]}, {"input": "41\r\n87094 21920 58071 41634 29145 45616 94239 76417 5226 47971 48770 79974 19190 25017 37857 30229 11726 12314 71998 54327 85032 8687 46656 12088 9595 24454 27827 7624 66535 14801 44581 25723 55659 48103 75242 39529 52973 17858 16985 41454 44182\r\n", "output": ["799467 864856"]}, {"input": "42\r\n70518 70764 38625 3816 78399 48585 66222 60405 72085 52153 85018 39717 51984 51451 8180 78146 59448 16768 2720 51272 48780 56464 21461 86471 23452 10470 22048 65189 56655 90480 31103 11801 73758 91536 10055 34129 20407 47933 4223 98861 84475 52291\r\n", "output": ["1012190 1036128"]}, {"input": "43\r\n86646 19609 43370 33293 3460 94658 95101 44393 6241 56335 78161 66757 52074 53692 2695 58767 31363 64326 738 15513 69425 4242 28971 60855 37309 53382 16269 57346 70968 90350 74522 22072 83345 67672 69060 4537 55137 78008 91461 32075 33280 70405 71607\r\n", "output": ["1039942 1109548"]}, {"input": "44\r\n70070 68453 23924 95475 52714 73435 34380 61085 40396 60518 38601 26501 52165 47421 73018 6684 79085 68781 31460 88265 33173 52020 44992 2534 8062 96295 77786 39103 85280 24812 93748 75446 92932 11105 71169 66433 89866 75379 11402 22186 73572 31624 70092 10734\r\n", "output": ["1141992 1210184"]}, {"input": "45\r\n53494 93105 37182 24953 1967 43700 39068 12369 7256 64700 31744 62052 84959 49662 34829 78793 51000 16339 29478 52506 96922 75606 52501 1109 21919 6503 72007 63964 75400 24682 45678 18420 67928 87241 73278 69545 24596 29646 65936 55401 89673 49738 35873 45189 3622\r\n", "output": ["1052557 1068976"]}, {"input": "46\r\n36918 9246 74631 78622 94325 22476 35243 96357 41411 68882 92184 21796 28153 43392 37856 26710 64130 20793 60200 16747 84862 23383 60010 42788 68480 92519 66229 56121 57009 24553 89096 4499 53323 30673 75386 31442 92030 59721 53173 45511 29966 67853 77462 12347 61811 81517\r\n", "output": ["1199490 1212346"]}, {"input": "47\r\n53046 58090 55185 8100 43578 1253 7226 13049 75567 73065 19920 48836 28243 45633 75475 74628 11853 68351 90922 89500 81315 71161 34816 49875 82337 2727 27746 37878 79833 24423 75618 82065 95614 82618 34391 1850 94056 57092 73115 70214 46067 29071 75947 46802 95807 42600 11211\r\n", "output": ["1214201 1233568"]}, {"input": "48\r\n69174 6934 59931 70281 68640 47326 3402 64333 42426 77247 13063 8579 61038 39362 2694 22545 83767 15909 88940 86445 45063 27451 18133 91555 28898 45640 21967 62738 61441 24293 19036 68144 5201 26050 69204 29154 85681 19871 60352 36133 86359 47186 74432 5448 53996 27876 58022 80559\r\n", "output": ["1096672 1115247"]}, {"input": "49\r\n19894 55779 73188 99759 17893 50295 8089 81025 76582 81429 73503 35619 61128 41603 40313 3166 31490 87660 19662 59197 8812 75229 25642 65938 42755 31656 16188 87599 51562 91460 38262 11118 90596 69482 71313 66858 87707 17242 14886 93539 35164 32596 83317 72606 12185 21664 80642 72099 7525\r\n", "output": ["1233007 1259909"]}, {"input": "50\r\n70081 97965 40736 24325 2476 20832 54026 23972 91400 47099 95141 27386 79799 49285 4039 818 23552 72203 55273 38168 52783 50365 89351 30945 47154 8047 27586 49184 20573 8953 38849 36466 45479 89848 82827 71475 74283 87115 92590 28903 97800 74550 74140 82514 10849 6786 67881 63456 53022 25051\r\n", "output": ["1251581 1255820"]}, {"input": "4\r\n10 3 2 1\r\n", "output": ["4 12"]}, {"input": "6\r\n5245 1414 21632 12159 31783 7412\r\n", "output": ["38442 41203"]}, {"input": "46\r\n1666 17339 9205 20040 30266 12751 11329 7951 9000 14465 11771 7600 19480 15993 19453 7470 1361 7922 27747 17347 4727 11280 403 16338 6064 11124 25723 18717 26118 271 9242 16952 26381 31795 28226 3646 27589 31472 30108 28354 25281 22429 30956 32264 14729 21685\r\n", "output": ["379808 392222"]}, {"input": "3\r\n100 90 80\r\n", "output": ["90 180"]}, {"input": "5\r\n10 9 8 7 6\r\n", "output": ["16 24"]}, {"input": "4\r\n100 40 50 10\r\n", "output": ["50 150"]}, {"input": "6\r\n5 4 3 2 1 1\r\n", "output": ["7 9"]}, {"input": "33\r\n30274 12228 26670 31244 5457 2643 27275 4380 30954 23407 8387 6669 25229 31591 27518 30261 25670 20962 31316 8992 8324 26216 10812 28467 15401 23077 10311 24975 14046 12010 11406 22841 7593\r\n", "output": ["299163 327443"]}, {"input": "3\r\n4 2 1\r\n", "output": ["2 5"]}, {"input": "3\r\n10 5 5\r\n", "output": ["5 15"]}, {"input": "6\r\n6 5 4 3 2 1\r\n", "output": ["9 12"]}, {"input": "4\r\n5 2 7 3\r\n", "output": ["7 10"]}] | 100 | 100 | 100 | [{'input': '47\r\n53046 58090 55185 8100 43578 1253 7226 13049 75567 73065 19920 48836 28243 45633 75475 74628 11853 68351 90922 89500 81315 71161 34816 49875 82337 2727 27746 37878 79833 24423 75618 82065 95614 82618 34391 1850 94056 57092 73115 70214 46067 29071 75947 46802 95807 42600 11211\r\n', 'output': ['1214201 1233568']}, {'input': '28\r\n70945 22563 76598 21753 4558 39341 48372 77054 52039 27522 75249 18459 96536 60264 5491 20125 42367 44118 42034 38665 47472 88410 66109 78995 52147 68436 9814 71112\r\n', 'output': ['669482 697066']}, {'input': '15\r\n13046 83844 14823 64255 15301 90234 84972 93547 88028 11665 54415 13159 83950 951 42336\r\n', 'output': ['362168 392358']}, {'input': '27\r\n54817 73719 96044 92275 12201 60564 84901 25770 17884 90636 14810 82907 20637 58023 10976 72208 94644 63856 11312 74424 26828 40632 58600 37316 38290 82420 48297\r\n', 'output': ['716531 728460']}, {'input': '6\r\n5245 1414 21632 12159 31783 7412\r\n', 'output': ['38442 41203']}] | [{'input': '49\r\n19894 55779 73188 99759 17893 50295 8089 81025 76582 81429 73503 35619 61128 41603 40313 3166 31490 87660 19662 59197 8812 75229 25642 65938 42755 31656 16188 87599 51562 91460 38262 11118 90596 69482 71313 66858 87707 17242 14886 93539 35164 32596 83317 72606 12185 21664 80642 72099 7525\r\n', 'output': ['1233007 1259909']}, {'input': '45\r\n53494 93105 37182 24953 1967 43700 39068 12369 7256 64700 31744 62052 84959 49662 34829 78793 51000 16339 29478 52506 96922 75606 52501 1109 21919 6503 72007 63964 75400 24682 45678 18420 67928 87241 73278 69545 24596 29646 65936 55401 89673 49738 35873 45189 3622\r\n', 'output': ['1052557 1068976']}, {'input': '30\r\n2351 14876 66138 87327 29940 73204 19925 50198 13441 54751 1383 92120 90236 13525 3920 16669 80637 94428 54890 71321 77670 57080 82145 39778 69967 38722 46902 82127 1142 21792\r\n', 'output': ['724302 724303']}, {'input': '7\r\n92387 35422 24898 32532 92988 84636 99872\r\n', 'output': ['192724 270011']}, {'input': '48\r\n69174 6934 59931 70281 68640 47326 3402 64333 42426 77247 13063 8579 61038 39362 2694 22545 83767 15909 88940 86445 45063 27451 18133 91555 28898 45640 21967 62738 61441 24293 19036 68144 5201 26050 69204 29154 85681 19871 60352 36133 86359 47186 74432 5448 53996 27876 58022 80559\r\n', 'output': ['1096672 1115247']}] | [{'input': '30\r\n2351 14876 66138 87327 29940 73204 19925 50198 13441 54751 1383 92120 90236 13525 3920 16669 80637 94428 54890 71321 77670 57080 82145 39778 69967 38722 46902 82127 1142 21792\r\n', 'output': ['724302 724303']}, {'input': '25\r\n87969 76030 78041 616 13694 11522 84038 25090 16869 14975 61226 96124 20457 62052 70329 76374 42303 11844 15276 37430 99330 77781 35069 64358 45168\r\n', 'output': ['586407 637558']}, {'input': '43\r\n86646 19609 43370 33293 3460 94658 95101 44393 6241 56335 78161 66757 52074 53692 2695 58767 31363 64326 738 15513 69425 4242 28971 60855 37309 53382 16269 57346 70968 90350 74522 22072 83345 67672 69060 4537 55137 78008 91461 32075 33280 70405 71607\r\n', 'output': ['1039942 1109548']}, {'input': '21\r\n21569 37548 74739 25809 65063 37631 71913 89138 47543 65542 10956 14045 78880 70111 73357 27810 70326 40523 899 6547 87440\r\n', 'output': ['506467 510922']}, {'input': '44\r\n70070 68453 23924 95475 52714 73435 34380 61085 40396 60518 38601 26501 52165 47421 73018 6684 79085 68781 31460 88265 33173 52020 44992 2534 8062 96295 77786 39103 85280 24812 93748 75446 92932 11105 71169 66433 89866 75379 11402 22186 73572 31624 70092 10734\r\n', 'output': ['1141992 1210184']}] | [{'input': '8\r\n8515 51563 5451 94713 9537 30709 63343 41819\r\n', 'output': ['138409 167241']}, {'input': '9\r\n91939 407 10197 24191 58791 9486 68030 25807 11\r\n', 'output': ['102429 186430']}, {'input': '40\r\n3670 5779 20621 87964 12595 34136 98063 92429 38366 43789 88330 52934 19100 22776 43342 82312 74404 64756 73980 14278 21283 85101 63339 70409 63034 14245 33606 58571 84927 14931 25355 15452 46072 4671 5838 69121 18243 87783 29748 84047\r\n', 'output': ['909877 959523']}, {'input': '48\r\n69174 6934 59931 70281 68640 47326 3402 64333 42426 77247 13063 8579 61038 39362 2694 22545 83767 15909 88940 86445 45063 27451 18133 91555 28898 45640 21967 62738 61441 24293 19036 68144 5201 26050 69204 29154 85681 19871 60352 36133 86359 47186 74432 5448 53996 27876 58022 80559\r\n', 'output': ['1096672 1115247']}, {'input': '45\r\n53494 93105 37182 24953 1967 43700 39068 12369 7256 64700 31744 62052 84959 49662 34829 78793 51000 16339 29478 52506 96922 75606 52501 1109 21919 6503 72007 63964 75400 24682 45678 18420 67928 87241 73278 69545 24596 29646 65936 55401 89673 49738 35873 45189 3622\r\n', 'output': ['1052557 1068976']}] | [{'input': '45\r\n53494 93105 37182 24953 1967 43700 39068 12369 7256 64700 31744 62052 84959 49662 34829 78793 51000 16339 29478 52506 96922 75606 52501 1109 21919 6503 72007 63964 75400 24682 45678 18420 67928 87241 73278 69545 24596 29646 65936 55401 89673 49738 35873 45189 3622\r\n', 'output': ['1052557 1068976']}, {'input': '13\r\n13494 86155 96820 72596 40986 99976 16813 25571 87013 3301 832 26376 83769\r\n', 'output': ['325890 327812']}, {'input': '33\r\n30274 12228 26670 31244 5457 2643 27275 4380 30954 23407 8387 6669 25229 31591 27518 30261 25670 20962 31316 8992 8324 26216 10812 28467 15401 23077 10311 24975 14046 12010 11406 22841 7593\r\n', 'output': ['299163 327443']}, {'input': '33\r\n87531 27423 55960 53829 37771 40665 39138 12849 77399 53025 71350 83793 48271 59887 41997 74854 14919 24175 43637 24327 13733 38978 2959 319 10086 26876 65393 56332 68025 63623 93732 68354 83938\r\n', 'output': ['741185 823963']}, {'input': '3\r\n100 90 80\r\n', 'output': ['90 180']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 47 | 100 | 100 | 100 |
["4\n1 3 2 0", "7\n1 3 3 2 1 2 3", "2\n2 2"] | The first line contains a positive integer n (1ββ€βnββ€β100) β the number of days of Vasya's vacations. The second line contains the sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β3) separated by space, where: ai equals 0, if on the i-th day of vacations the gym is closed and the contest is not carried out; ai equals 1, if on the i-th day of vacations the gym is closed, but the contest is carried out; ai equals 2, if on the i-th day of vacations the gym is open and the contest is not carried out; ai equals 3, if on the i-th day of vacations the gym is open and the contest is carried out. | 08f1ba79ced688958695a7cfcfdda035 | //DURING CONTEST: http://www.codeforces.com/contest/699/submission/19246509
#include <stdio.h>
#include <stdint.h>
int main() {
/**
* Variables are stored as follows:
* whatWeCouldDoYesterday -- data & 0b11
* whatWeCanDoToday -- (data & 0b1100) >> 2
* answer -- (data & 0xff00) >> 8
* numDays -- (data & 0xff0000) >> 16
* todayCode -- (data & 0xff000000) >> 24
*/
//whatWeDidYesterday = whatWeCanDoToday = answer = numDays = todayCode = 0;
uint32_t data = 0;
//scanf("%i", &numDays);
scanf("%hhi", ((signed char*)&data)+2);
//whatWeCouldDoYesterday = 3;
data += 3;
//while ((numDays -= 1), numDays+1) {
while ((data -= 0x10000), ((data+0x10000) & 0xff0000) >> 16) {
//scanf("%i", &todayCode);
scanf("%hhi", ((signed char*)&data)+3);
//if ((whatWeCouldDoYesterday & 2) && (todayCode & 1)) whatWeCanDoToday += 1;
if ((data & 2) && (data & 0x1000000) >> 24) data += 1 << 2;
//if ((whatWeCouldDoYesterday & 1) && (todayCode & 2)) whatWeCanDoToday += 2;
if ((data & 1) && (data & 0x2000000) >> 24) data += 2 << 2;
//if (!whatWeCanDoToday) answer += 1, whatWeCanDoToday = 3;
if (!(data & 0b1100)) data += 1 << 8, data += 3 << 2;
//whatWeCouldDoYesterday = whatWeCanDoToday, whatWeCanDoToday = 0;
*((signed char*)&data) >>= 2;
}
//printf("%i\n", answer);
printf("%li\n", (data & 0xff00) >> 8);
} | ["2", "0", "1"] | C | NoteIn the first test Vasya can write the contest on the day number 1 and do sport on the day number 3. Thus, he will have a rest for only 2 days.In the second test Vasya should write contests on days number 1, 3, 5 and 7, in other days do sport. Thus, he will not have a rest for a single day.In the third test Vasya can do sport either on a day number 1 or number 2. He can not do sport in two days, because it will be contrary to the his limitation. Thus, he will have a rest for only one day. | Print the minimum possible number of days on which Vasya will have a rest. Remember that Vasya refuses: to do sport on any two consecutive days, to write the contest on any two consecutive days. | Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options: on this day the gym is closed and the contest is not carried out; on this day the gym is closed and the contest is carried out; on this day the gym is open and the contest is not carried out; on this day the gym is open and the contest is carried out. On each of days Vasya can either have a rest or write the contest (if it is carried out on this day), or do sport (if the gym is open on this day).Find the minimum number of days on which Vasya will have a rest (it means, he will not do sport and write the contest at the same time). The only limitation that Vasya has β he does not want to do the same activity on two consecutive days: it means, he will not do sport on two consecutive days, and write the contest on two consecutive days. | [{"input": "4\r\n1 3 2 0\r\n", "output": ["2"]}, {"input": "7\r\n1 3 3 2 1 2 3\r\n", "output": ["0"]}, {"input": "2\r\n2 2\r\n", "output": ["1"]}, {"input": "1\r\n0\r\n", "output": ["1"]}, {"input": "10\r\n0 0 1 1 0 0 0 0 1 0\r\n", "output": ["8"]}, {"input": "100\r\n3 2 3 3 3 2 3 1 3 2 2 3 2 3 3 3 3 3 3 1 2 2 3 1 3 3 2 2 2 3 1 0 3 3 3 2 3 3 1 1 3 1 3 3 3 1 3 1 3 0 1 3 2 3 2 1 1 3 2 3 3 3 2 3 1 3 3 3 3 2 2 2 1 3 1 3 3 3 3 1 3 2 3 3 0 3 3 3 3 3 1 0 2 1 3 3 0 2 3 3\r\n", "output": ["16"]}, {"input": "10\r\n2 3 0 1 3 1 2 2 1 0\r\n", "output": ["3"]}, {"input": "45\r\n3 3 2 3 2 3 3 3 0 3 3 3 3 3 3 3 1 3 2 3 2 3 2 2 2 3 2 3 3 3 3 3 1 2 3 3 2 2 2 3 3 3 3 1 3\r\n", "output": ["6"]}, {"input": "1\r\n1\r\n", "output": ["0"]}, {"input": "1\r\n2\r\n", "output": ["0"]}, {"input": "1\r\n3\r\n", "output": ["0"]}, {"input": "2\r\n1 1\r\n", "output": ["1"]}, {"input": "2\r\n1 3\r\n", "output": ["0"]}, {"input": "2\r\n0 1\r\n", "output": ["1"]}, {"input": "2\r\n0 0\r\n", "output": ["2"]}, {"input": "2\r\n3 3\r\n", "output": ["0"]}, {"input": "3\r\n3 3 3\r\n", "output": ["0"]}, {"input": "2\r\n3 2\r\n", "output": ["0"]}, {"input": "2\r\n0 2\r\n", "output": ["1"]}, {"input": "10\r\n2 2 3 3 3 3 2 1 3 2\r\n", "output": ["2"]}, {"input": "15\r\n0 1 0 0 0 2 0 1 0 0 0 2 0 0 0\r\n", "output": ["11"]}, {"input": "15\r\n1 3 2 2 2 3 3 3 3 2 3 2 2 1 1\r\n", "output": ["4"]}, {"input": "15\r\n3 1 3 2 3 2 2 2 3 3 3 3 2 3 2\r\n", "output": ["3"]}, {"input": "20\r\n0 2 0 1 0 0 0 1 2 0 1 1 1 0 1 1 0 1 1 0\r\n", "output": ["12"]}, {"input": "20\r\n2 3 2 3 3 3 3 2 0 3 1 1 2 3 0 3 2 3 0 3\r\n", "output": ["5"]}, {"input": "20\r\n3 3 3 3 2 3 3 2 1 3 3 2 2 2 3 2 2 2 2 2\r\n", "output": ["4"]}, {"input": "25\r\n0 0 1 0 0 1 0 0 1 0 0 1 0 2 0 0 2 0 0 1 0 2 0 1 1\r\n", "output": ["16"]}, {"input": "25\r\n1 3 3 2 2 3 3 3 3 3 1 2 2 3 2 0 2 1 0 1 3 2 2 3 3\r\n", "output": ["5"]}, {"input": "25\r\n2 3 1 3 3 2 1 3 3 3 1 3 3 1 3 2 3 3 1 3 3 3 2 3 3\r\n", "output": ["3"]}, {"input": "30\r\n0 0 1 0 1 0 1 1 0 0 0 0 0 0 1 0 0 1 1 0 0 2 0 0 1 1 2 0 0 0\r\n", "output": ["22"]}, {"input": "30\r\n1 1 3 2 2 0 3 2 3 3 1 2 0 1 1 2 3 3 2 3 1 3 2 3 0 2 0 3 3 2\r\n", "output": ["9"]}, {"input": "30\r\n1 2 3 2 2 3 3 3 3 3 3 3 3 3 3 1 2 2 3 2 3 3 3 2 1 3 3 3 1 3\r\n", "output": ["2"]}, {"input": "35\r\n0 1 1 0 0 2 0 0 1 0 0 0 1 0 1 0 1 0 0 0 1 2 1 0 2 2 1 0 1 0 1 1 1 0 0\r\n", "output": ["21"]}, {"input": "35\r\n2 2 0 3 2 2 0 3 3 1 1 3 3 1 2 2 0 2 2 2 2 3 1 0 2 1 3 2 2 3 2 3 3 1 2\r\n", "output": ["11"]}, {"input": "35\r\n1 2 2 3 3 3 3 3 2 2 3 3 2 3 3 2 3 2 3 3 2 2 2 3 3 2 3 3 3 1 3 3 2 2 2\r\n", "output": ["7"]}, {"input": "40\r\n2 0 1 1 0 0 0 0 2 0 1 1 1 0 0 1 0 0 0 0 0 2 0 0 0 2 1 1 1 3 0 0 0 0 0 0 0 1 1 0\r\n", "output": ["28"]}, {"input": "40\r\n2 2 3 2 0 2 3 2 1 2 3 0 2 3 2 1 1 3 1 1 0 2 3 1 3 3 1 1 3 3 2 2 1 3 3 3 2 3 3 1\r\n", "output": ["10"]}, {"input": "40\r\n1 3 2 3 3 2 3 3 2 2 3 1 2 1 2 2 3 1 2 2 1 2 2 2 1 2 2 3 2 3 2 3 2 3 3 3 1 3 2 3\r\n", "output": ["8"]}, {"input": "45\r\n2 1 0 0 0 2 1 0 1 0 0 2 2 1 1 0 0 2 0 0 0 0 0 0 1 0 0 2 0 0 1 1 0 0 1 0 0 1 1 2 0 0 2 0 2\r\n", "output": ["29"]}, {"input": "45\r\n3 3 2 3 3 3 2 2 3 2 3 1 3 2 3 2 2 1 1 3 2 3 2 1 3 1 2 3 2 2 0 3 3 2 3 2 3 2 3 2 0 3 1 1 3\r\n", "output": ["8"]}, {"input": "50\r\n3 0 0 0 2 0 0 0 0 0 0 0 2 1 0 2 0 1 0 1 3 0 2 1 1 0 0 1 1 0 0 1 2 1 1 2 1 1 0 0 0 0 0 0 0 1 2 2 0 0\r\n", "output": ["32"]}, {"input": "50\r\n3 3 3 3 1 0 3 3 0 2 3 1 1 1 3 2 3 3 3 3 3 1 0 1 2 2 3 3 2 3 0 0 0 2 1 0 1 2 2 2 2 0 2 2 2 1 2 3 3 2\r\n", "output": ["16"]}, {"input": "50\r\n3 2 3 1 2 1 2 3 3 2 3 3 2 1 3 3 3 3 3 3 2 3 2 3 2 2 3 3 3 2 3 3 3 3 2 3 1 2 3 3 2 3 3 1 2 2 1 1 3 3\r\n", "output": ["7"]}, {"input": "55\r\n0 0 1 1 0 1 0 0 1 0 1 0 0 0 2 0 0 1 0 0 0 1 0 0 0 0 3 1 0 0 0 1 0 0 0 0 2 0 0 0 2 0 2 1 0 0 0 0 0 0 0 0 2 0 0\r\n", "output": ["40"]}, {"input": "55\r\n3 0 3 3 3 2 0 2 3 0 3 2 3 3 0 3 3 1 3 3 1 2 3 2 0 3 3 2 1 2 3 2 3 0 3 2 2 1 2 3 2 2 1 3 2 2 3 1 3 2 2 3 3 2 2\r\n", "output": ["13"]}, {"input": "55\r\n3 3 1 3 2 3 2 3 2 2 3 3 3 3 3 1 1 3 3 2 3 2 3 2 0 1 3 3 3 3 2 3 2 3 1 1 2 2 2 3 3 3 3 3 2 2 2 3 2 3 3 3 3 1 3\r\n", "output": ["7"]}, {"input": "60\r\n0 1 0 0 0 0 0 0 0 2 1 1 3 0 0 0 0 0 1 0 1 1 0 0 0 3 0 1 0 1 0 2 0 0 0 0 0 1 0 0 0 0 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 0 0\r\n", "output": ["44"]}, {"input": "60\r\n3 2 1 3 2 2 3 3 3 1 1 3 2 2 3 3 1 3 2 2 3 3 2 2 2 2 0 2 2 3 2 3 0 3 3 3 2 3 3 0 1 3 2 1 3 1 1 2 1 3 1 1 2 2 1 3 3 3 2 2\r\n", "output": ["15"]}, {"input": "60\r\n3 2 2 3 2 3 2 3 3 2 3 2 3 3 2 3 3 3 3 3 3 2 3 3 1 2 3 3 3 2 1 3 3 1 3 1 3 0 3 3 3 2 3 2 3 2 3 3 1 1 2 3 3 3 3 2 1 3 2 3\r\n", "output": ["8"]}, {"input": "65\r\n1 0 2 1 1 0 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 1 2 0 2 1 0 2 1 0 1 0 1 1 0 1 1 1 2 1 0 1 0 0 0 0 1 2 2 1 0 0 1 2 1 2 0 2 0 0 0 1 1\r\n", "output": ["35"]}, {"input": "65\r\n2 2 2 3 0 2 1 2 3 3 1 3 1 2 1 3 2 3 2 2 2 1 2 0 3 1 3 1 1 3 1 3 3 3 3 3 1 3 0 3 1 3 1 2 2 3 2 0 3 1 3 2 1 2 2 2 3 3 2 3 3 3 2 2 3\r\n", "output": ["13"]}, {"input": "65\r\n3 2 3 3 3 2 3 2 3 3 3 3 3 3 3 3 3 2 3 2 3 2 2 3 3 3 3 3 2 2 2 3 3 2 3 3 2 3 3 3 3 2 3 3 3 2 2 3 3 3 3 3 3 2 2 3 3 2 3 3 1 3 3 3 3\r\n", "output": ["6"]}, {"input": "70\r\n1 0 0 0 1 0 1 0 0 0 1 1 0 1 0 0 1 1 1 0 1 1 0 0 1 1 1 3 1 1 0 1 2 0 2 1 0 0 0 1 1 1 1 1 0 0 1 0 0 0 1 1 1 3 0 0 1 0 0 0 1 0 0 0 0 0 1 0 1 1\r\n", "output": ["43"]}, {"input": "70\r\n2 3 3 3 1 3 3 1 2 1 1 2 2 3 0 2 3 3 1 3 3 2 2 3 3 3 2 2 2 2 1 3 3 0 2 1 1 3 2 3 3 2 2 3 1 3 1 2 3 2 3 3 2 2 2 3 1 1 2 1 3 3 2 2 3 3 3 1 1 1\r\n", "output": ["16"]}, {"input": "70\r\n3 3 2 2 1 2 1 2 2 2 2 2 3 3 2 3 3 3 3 2 2 2 2 3 3 3 1 3 3 3 2 3 3 3 3 2 3 3 1 3 1 3 2 3 3 2 3 3 3 2 3 2 3 3 1 2 3 3 2 2 2 3 2 3 3 3 3 3 3 1\r\n", "output": ["10"]}, {"input": "75\r\n1 0 0 1 1 0 0 1 0 1 2 0 0 2 1 1 0 0 0 0 0 0 2 1 1 0 0 0 0 1 0 1 0 1 1 1 0 1 0 0 1 0 0 0 0 0 0 1 1 0 0 1 2 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 1 1 0 1 0\r\n", "output": ["51"]}, {"input": "75\r\n1 3 3 3 1 1 3 2 3 3 1 3 3 3 2 1 3 2 2 3 1 1 1 1 1 1 2 3 3 3 3 3 3 2 3 3 3 3 3 2 3 3 2 2 2 1 2 3 3 2 2 3 0 1 1 3 3 0 0 1 1 3 2 3 3 3 3 1 2 2 3 3 3 3 1\r\n", "output": ["16"]}, {"input": "75\r\n3 3 3 3 2 2 3 2 2 3 2 2 1 2 3 3 2 2 3 3 1 2 2 2 1 3 3 3 1 2 2 3 3 3 2 3 2 2 2 3 3 1 3 2 2 3 3 3 0 3 2 1 3 3 2 3 3 3 3 1 2 3 3 3 2 2 3 3 3 3 2 2 3 3 1\r\n", "output": ["11"]}, {"input": "80\r\n0 0 0 0 2 0 1 1 1 1 1 0 0 0 0 2 0 0 1 0 0 0 0 1 1 0 2 2 1 1 0 1 0 1 0 1 1 1 0 1 2 1 1 0 0 0 1 1 0 1 1 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 2 2 0 1 1 0 0 0 0 0 0 0 0 1\r\n", "output": ["56"]}, {"input": "80\r\n2 2 3 3 2 1 0 1 0 3 2 2 3 2 1 3 1 3 3 2 3 3 3 2 3 3 3 2 1 3 3 1 3 3 3 3 3 3 2 2 2 1 3 2 1 3 2 1 1 0 1 1 2 1 3 0 1 2 3 2 2 3 2 3 1 3 3 2 1 1 0 3 3 3 3 1 2 1 2 0\r\n", "output": ["17"]}, {"input": "80\r\n2 3 3 2 2 2 3 3 2 3 3 3 3 3 2 3 2 3 2 3 3 3 3 3 3 3 3 3 2 3 1 3 2 3 3 0 3 1 2 3 3 1 2 3 2 3 3 2 3 3 3 3 3 2 2 3 0 3 3 3 3 3 2 2 3 2 3 3 3 3 3 2 3 2 3 3 3 3 2 3\r\n", "output": ["9"]}, {"input": "85\r\n0 1 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 2 0 1 0 0 2 0 1 1 0 0 0 0 2 2 0 0 0 1 0 0 0 1 2 0 1 0 0 0 2 1 1 2 0 3 1 0 2 2 1 0 0 1 1 0 0 0 0 1 0 2 1 1 2 1 0 0 1 2 1 2 0 0 1 0 1 0\r\n", "output": ["54"]}, {"input": "85\r\n2 3 1 3 2 3 1 3 3 2 1 2 1 2 2 3 2 2 3 2 0 3 3 2 1 2 2 2 3 3 2 3 3 3 2 1 1 3 1 3 2 2 2 3 3 2 3 2 3 1 1 3 2 3 1 3 3 2 3 3 2 2 3 0 1 1 2 2 2 2 1 2 3 1 3 3 1 3 2 2 3 2 3 3 3\r\n", "output": ["19"]}, {"input": "85\r\n1 2 1 2 3 2 3 3 3 3 3 3 3 2 1 3 2 3 3 3 3 2 3 3 3 1 3 3 3 3 2 3 3 3 3 3 3 2 2 1 3 3 3 3 2 2 3 1 1 2 3 3 3 2 3 3 3 3 3 2 3 3 3 2 2 3 3 1 1 1 3 3 3 3 1 3 3 3 1 3 3 1 3 2 3\r\n", "output": ["9"]}, {"input": "90\r\n2 0 1 0 0 0 0 0 0 1 1 2 0 0 0 0 0 0 0 2 2 0 2 0 0 2 1 0 2 0 1 0 1 0 0 1 2 2 0 0 1 0 0 1 0 1 0 2 0 1 1 1 0 1 1 0 1 0 2 0 1 0 1 0 0 0 1 0 0 1 2 0 0 0 1 0 0 2 2 0 0 0 0 0 1 3 1 1 0 1\r\n", "output": ["57"]}, {"input": "90\r\n2 3 3 3 2 3 2 1 3 0 3 2 3 3 2 1 3 3 2 3 2 3 3 2 1 3 1 3 3 1 2 2 3 3 2 1 2 3 2 3 0 3 3 2 2 3 1 0 3 3 1 3 3 3 3 2 1 2 2 1 3 2 1 3 3 1 2 0 2 2 3 2 2 3 3 3 1 3 2 1 2 3 3 2 3 2 3 3 2 1\r\n", "output": ["17"]}, {"input": "90\r\n2 3 2 3 2 2 3 3 2 3 2 1 2 3 3 3 2 3 2 3 3 2 3 3 3 1 3 3 1 3 2 3 2 2 1 3 3 3 3 3 3 3 3 3 3 2 3 2 3 2 1 3 3 3 3 2 2 3 3 3 3 3 3 3 3 3 3 3 3 2 2 3 3 3 3 1 3 2 3 3 3 2 2 3 2 3 2 1 3 2\r\n", "output": ["9"]}, {"input": "95\r\n0 0 3 0 2 0 1 0 0 2 0 0 0 0 0 0 0 1 0 0 0 2 0 0 0 0 0 1 0 0 2 1 0 0 1 0 0 0 1 0 0 0 0 1 0 1 0 0 1 0 1 2 0 1 2 2 0 0 1 0 2 0 0 0 1 0 2 1 2 1 0 1 0 0 0 1 0 0 1 1 2 1 1 1 1 2 0 0 0 0 0 1 1 0 1\r\n", "output": ["61"]}, {"input": "95\r\n2 3 3 2 1 1 3 3 3 2 3 3 3 2 3 2 3 3 3 2 3 2 2 3 3 2 1 2 3 3 3 1 3 0 3 3 1 3 3 1 0 1 3 3 3 0 2 1 3 3 3 3 0 1 3 2 3 3 2 1 3 1 2 1 1 2 3 0 3 3 2 1 3 2 1 3 3 3 2 2 3 2 3 3 3 2 1 3 3 3 2 3 3 1 2\r\n", "output": ["15"]}, {"input": "95\r\n2 3 3 2 3 2 2 1 3 1 2 1 2 3 1 2 3 3 1 3 3 3 1 2 3 2 2 2 2 3 3 3 2 2 3 3 3 3 3 1 2 2 3 3 3 3 2 3 2 2 2 3 3 2 3 3 3 3 3 3 3 0 3 2 0 3 3 1 3 3 3 2 3 2 3 2 3 3 3 3 2 2 1 1 3 3 3 3 3 1 3 3 3 3 2\r\n", "output": ["14"]}, {"input": "100\r\n1 0 2 0 0 0 0 2 0 0 0 1 0 1 0 0 1 0 1 2 0 1 1 0 0 1 0 1 1 0 0 0 2 0 1 0 0 2 0 0 0 0 0 1 1 1 0 0 1 0 2 0 0 0 0 1 0 1 0 1 0 1 0 1 2 2 0 0 2 0 1 0 1 0 1 0 0 0 1 0 0 2 1 1 1 0 0 1 0 0 0 2 0 0 2 1 1 0 0 2\r\n", "output": ["63"]}, {"input": "100\r\n3 2 1 3 2 3 2 3 2 2 3 1 3 3 3 3 3 2 2 3 2 2 3 2 3 3 3 2 3 1 2 1 3 3 3 3 1 3 3 3 3 3 2 3 2 1 3 3 1 2 2 3 1 3 3 1 2 2 1 3 1 3 2 2 3 3 1 3 2 3 1 2 1 2 3 3 2 2 1 2 3 3 3 3 3 1 3 3 3 3 2 1 3 0 3 3 3 2 3 3\r\n", "output": ["15"]}, {"input": "100\r\n1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2\r\n", "output": ["0"]}, {"input": "100\r\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\r\n", "output": ["0"]}, {"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": ["50"]}, {"input": "100\r\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\r\n", "output": ["50"]}, {"input": "99\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\r\n", "output": ["49"]}, {"input": "100\r\n2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1\r\n", "output": ["0"]}, {"input": "100\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n", "output": ["100"]}, {"input": "2\r\n0 3\r\n", "output": ["1"]}, {"input": "2\r\n1 0\r\n", "output": ["1"]}, {"input": "2\r\n1 2\r\n", "output": ["0"]}, {"input": "2\r\n2 0\r\n", "output": ["1"]}, {"input": "2\r\n2 1\r\n", "output": ["0"]}, {"input": "2\r\n2 3\r\n", "output": ["0"]}, {"input": "2\r\n3 0\r\n", "output": ["1"]}, {"input": "2\r\n3 1\r\n", "output": ["0"]}, {"input": "100\r\n3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0\r\n", "output": ["50"]}] | 100 | 100 | 100 | [{'input': '100\r\n1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2\r\n', 'output': ['0']}, {'input': '85\r\n1 2 1 2 3 2 3 3 3 3 3 3 3 2 1 3 2 3 3 3 3 2 3 3 3 1 3 3 3 3 2 3 3 3 3 3 3 2 2 1 3 3 3 3 2 2 3 1 1 2 3 3 3 2 3 3 3 3 3 2 3 3 3 2 2 3 3 1 1 1 3 3 3 3 1 3 3 3 1 3 3 1 3 2 3\r\n', 'output': ['9']}, {'input': '25\r\n0 0 1 0 0 1 0 0 1 0 0 1 0 2 0 0 2 0 0 1 0 2 0 1 1\r\n', 'output': ['16']}, {'input': '75\r\n1 0 0 1 1 0 0 1 0 1 2 0 0 2 1 1 0 0 0 0 0 0 2 1 1 0 0 0 0 1 0 1 0 1 1 1 0 1 0 0 1 0 0 0 0 0 0 1 1 0 0 1 2 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 1 1 0 1 0\r\n', 'output': ['51']}, {'input': '80\r\n2 2 3 3 2 1 0 1 0 3 2 2 3 2 1 3 1 3 3 2 3 3 3 2 3 3 3 2 1 3 3 1 3 3 3 3 3 3 2 2 2 1 3 2 1 3 2 1 1 0 1 1 2 1 3 0 1 2 3 2 2 3 2 3 1 3 3 2 1 1 0 3 3 3 3 1 2 1 2 0\r\n', 'output': ['17']}] | [{'input': '25\r\n0 0 1 0 0 1 0 0 1 0 0 1 0 2 0 0 2 0 0 1 0 2 0 1 1\r\n', 'output': ['16']}, {'input': '75\r\n1 0 0 1 1 0 0 1 0 1 2 0 0 2 1 1 0 0 0 0 0 0 2 1 1 0 0 0 0 1 0 1 0 1 1 1 0 1 0 0 1 0 0 0 0 0 0 1 1 0 0 1 2 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 1 1 0 1 0\r\n', 'output': ['51']}, {'input': '90\r\n2 3 2 3 2 2 3 3 2 3 2 1 2 3 3 3 2 3 2 3 3 2 3 3 3 1 3 3 1 3 2 3 2 2 1 3 3 3 3 3 3 3 3 3 3 2 3 2 3 2 1 3 3 3 3 2 2 3 3 3 3 3 3 3 3 3 3 3 3 2 2 3 3 3 3 1 3 2 3 3 3 2 2 3 2 3 2 1 3 2\r\n', 'output': ['9']}, {'input': '1\r\n3\r\n', 'output': ['0']}, {'input': '95\r\n2 3 3 2 3 2 2 1 3 1 2 1 2 3 1 2 3 3 1 3 3 3 1 2 3 2 2 2 2 3 3 3 2 2 3 3 3 3 3 1 2 2 3 3 3 3 2 3 2 2 2 3 3 2 3 3 3 3 3 3 3 0 3 2 0 3 3 1 3 3 3 2 3 2 3 2 3 3 3 3 2 2 1 1 3 3 3 3 3 1 3 3 3 3 2\r\n', 'output': ['14']}] | [{'input': '55\r\n3 3 1 3 2 3 2 3 2 2 3 3 3 3 3 1 1 3 3 2 3 2 3 2 0 1 3 3 3 3 2 3 2 3 1 1 2 2 2 3 3 3 3 3 2 2 2 3 2 3 3 3 3 1 3\r\n', 'output': ['7']}, {'input': '2\r\n1 1\r\n', 'output': ['1']}, {'input': '20\r\n2 3 2 3 3 3 3 2 0 3 1 1 2 3 0 3 2 3 0 3\r\n', 'output': ['5']}, {'input': '2\r\n2 2\r\n', 'output': ['1']}, {'input': '75\r\n3 3 3 3 2 2 3 2 2 3 2 2 1 2 3 3 2 2 3 3 1 2 2 2 1 3 3 3 1 2 2 3 3 3 2 3 2 2 2 3 3 1 3 2 2 3 3 3 0 3 2 1 3 3 2 3 3 3 3 1 2 3 3 3 2 2 3 3 3 3 2 2 3 3 1\r\n', 'output': ['11']}] | [{'input': '4\r\n1 3 2 0\r\n', 'output': ['2']}, {'input': '95\r\n2 3 3 2 3 2 2 1 3 1 2 1 2 3 1 2 3 3 1 3 3 3 1 2 3 2 2 2 2 3 3 3 2 2 3 3 3 3 3 1 2 2 3 3 3 3 2 3 2 2 2 3 3 2 3 3 3 3 3 3 3 0 3 2 0 3 3 1 3 3 3 2 3 2 3 2 3 3 3 3 2 2 1 1 3 3 3 3 3 1 3 3 3 3 2\r\n', 'output': ['14']}, {'input': '2\r\n3 3\r\n', 'output': ['0']}, {'input': '2\r\n1 3\r\n', 'output': ['0']}, {'input': '30\r\n1 2 3 2 2 3 3 3 3 3 3 3 3 3 3 1 2 2 3 2 3 3 3 2 1 3 3 3 1 3\r\n', 'output': ['2']}] | [{'input': '10\r\n0 0 1 1 0 0 0 0 1 0\r\n', 'output': ['8']}, {'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': ['50']}, {'input': '2\r\n3 2\r\n', 'output': ['0']}, {'input': '4\r\n1 3 2 0\r\n', 'output': ['2']}, {'input': '80\r\n2 3 3 2 2 2 3 3 2 3 3 3 3 3 2 3 2 3 2 3 3 3 3 3 3 3 3 3 2 3 1 3 2 3 3 0 3 1 2 3 3 1 2 3 2 3 3 2 3 3 3 3 3 2 2 3 0 3 3 3 3 3 2 2 3 2 3 3 3 3 3 2 3 2 3 3 3 3 2 3\r\n', 'output': ['9']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 48 | 100 | 100 | 100 |
["1990 1", "300 0", "1034 2", "9090000078001234 6"] | The single line contains two integers a and k (1ββ€βaββ€β1018;Β 0ββ€βkββ€β100). | e56f6c343167745821f0b18dcf0d0cde | #include<stdio.h>
#include<string.h>
int main()
{
char a[500],temp,max;
int c,n,i,j,k,x,f=1,h=4,m;
scanf("%s",a);
scanf("%d",&k);
c=0;
n=strlen(a);
while(c!=n)
{
max='0';
for(j=c;j<k+c+1;j++)
{
if(j==n)
break;
if(a[j]>max)
{
max=a[j];
x=j;
}
}
for(j=x;j>c;j--)
{
/*if(c==x)
break;*/
if(k==0)
{
f=0;
break;
}
temp=a[j-1];
a[j-1]=a[j];
a[j]=temp;
k--;
}
c++;
// printf("%d ",k);
if(f==0)
break;
}
printf("%s",a);
return 0;
}
| ["9190", "300", "3104", "9907000008001234"] | C | null | Print the maximum number that Pasha can get if he makes at most k swaps. | Pasha has a positive integer a without leading zeroes. Today he decided that the number is too small and he should make it larger. Unfortunately, the only operation Pasha can do is to swap two adjacent decimal digits of the integer.Help Pasha count the maximum number he can get if he has the time to make at most k swaps. | [{"input": "1990 1\r\n", "output": ["9190"]}, {"input": "300 0\r\n", "output": ["300"]}, {"input": "1034 2\r\n", "output": ["3104"]}, {"input": "9090000078001234 6\r\n", "output": ["9907000008001234"]}, {"input": "1234 3\r\n", "output": ["4123"]}, {"input": "5 100\r\n", "output": ["5"]}, {"input": "1234 5\r\n", "output": ["4312"]}, {"input": "1234 6\r\n", "output": ["4321"]}, {"input": "9022 2\r\n", "output": ["9220"]}, {"input": "66838 4\r\n", "output": ["86863"]}, {"input": "39940894417248510 10\r\n", "output": ["99984304417248510"]}, {"input": "5314 4\r\n", "output": ["5431"]}, {"input": "1026 9\r\n", "output": ["6210"]}, {"input": "4529 8\r\n", "output": ["9542"]}, {"input": "83811284 3\r\n", "output": ["88321184"]}, {"input": "92153348 6\r\n", "output": ["98215334"]}, {"input": "5846059 3\r\n", "output": ["8654059"]}, {"input": "521325125110071928 4\r\n", "output": ["552132125110071928"]}, {"input": "39940894417248510 10\r\n", "output": ["99984304417248510"]}, {"input": "77172428736634377 29\r\n", "output": ["87777764122363437"]}, {"input": "337775999910796051 37\r\n", "output": ["999997733751076051"]}, {"input": "116995340392134308 27\r\n", "output": ["999654331120134308"]}, {"input": "10120921290110921 20\r\n", "output": ["99221010120110921"]}, {"input": "929201010190831892 30\r\n", "output": ["999928201010103182"]}, {"input": "111111111111111119 8\r\n", "output": ["111111111911111111"]}, {"input": "219810011901120912 100\r\n", "output": ["999822211111110000"]}, {"input": "191919191919119911 100\r\n", "output": ["999999991111111111"]}, {"input": "801211288881101019 22\r\n", "output": ["982111028888110101"]}, {"input": "619911311932347059 3\r\n", "output": ["969111311932347059"]}, {"input": "620737553540689123 2\r\n", "output": ["672037553540689123"]}, {"input": "621563797296514835 3\r\n", "output": ["662153797296514835"]}, {"input": "915277434701161 9\r\n", "output": ["977541234701161"]}, {"input": "15603712376708 28\r\n", "output": ["87761503123670"]}, {"input": "784069392990841 0\r\n", "output": ["784069392990841"]}, {"input": "787464780004 2\r\n", "output": ["877644780004"]}, {"input": "74604713975 29\r\n", "output": ["97776544310"]}, {"input": "901000000954321789 5\r\n", "output": ["910009000054321789"]}, {"input": "901000000954321789 10\r\n", "output": ["991000000504321789"]}, {"input": "901000000954321789 28\r\n", "output": ["999100050000432178"]}, {"input": "901000000954321789 40\r\n", "output": ["999810000050043217"]}, {"input": "901000000954321789 70\r\n", "output": ["999875410000300021"]}, {"input": "1234567891234567 99\r\n", "output": ["9877665544332211"]}, {"input": "123456789123456789 100\r\n", "output": ["998877665544213123"]}, {"input": "12345670123456789 100\r\n", "output": ["98776655443322101"]}, {"input": "12 100\r\n", "output": ["21"]}, {"input": "11223344556677889 47\r\n", "output": ["98821213344556677"]}] | 100 | 100 | 100 | [{'input': '92153348 6\r\n', 'output': ['98215334']}, {'input': '801211288881101019 22\r\n', 'output': ['982111028888110101']}, {'input': '66838 4\r\n', 'output': ['86863']}, {'input': '620737553540689123 2\r\n', 'output': ['672037553540689123']}, {'input': '10120921290110921 20\r\n', 'output': ['99221010120110921']}] | [{'input': '10120921290110921 20\r\n', 'output': ['99221010120110921']}, {'input': '901000000954321789 70\r\n', 'output': ['999875410000300021']}, {'input': '5846059 3\r\n', 'output': ['8654059']}, {'input': '11223344556677889 47\r\n', 'output': ['98821213344556677']}, {'input': '1034 2\r\n', 'output': ['3104']}] | [{'input': '901000000954321789 40\r\n', 'output': ['999810000050043217']}, {'input': '901000000954321789 5\r\n', 'output': ['910009000054321789']}, {'input': '1034 2\r\n', 'output': ['3104']}, {'input': '15603712376708 28\r\n', 'output': ['87761503123670']}, {'input': '5 100\r\n', 'output': ['5']}] | [{'input': '801211288881101019 22\r\n', 'output': ['982111028888110101']}, {'input': '4529 8\r\n', 'output': ['9542']}, {'input': '5314 4\r\n', 'output': ['5431']}, {'input': '11223344556677889 47\r\n', 'output': ['98821213344556677']}, {'input': '10120921290110921 20\r\n', 'output': ['99221010120110921']}] | [{'input': '300 0\r\n', 'output': ['300']}, {'input': '74604713975 29\r\n', 'output': ['97776544310']}, {'input': '77172428736634377 29\r\n', 'output': ['87777764122363437']}, {'input': '784069392990841 0\r\n', 'output': ['784069392990841']}, {'input': '15603712376708 28\r\n', 'output': ['87761503123670']}] | 100 | 100 | 100 | 100 | 100 | 88.89 | 100 | 100 | 88.89 | 88.89 | 85.71 | 100 | 100 | 85.71 | 85.71 | 49 | 100 | 93.334 | 91.426 |
["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<stdio.h>
main()
{
long long i=1000000007;
long long n,k,j;
scanf("%lld%lld",&n,&k);
long long x=n-k,m=1,y=1;
for(j=1;j<=x;j++)
m=(m*x)%i;
for(j=1;j<k;j++)
y=(y*k)%i;
m=(m*y)%i;
printf("%I64d",m);
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': '1000 6\r\n', 'output': ['834332109']}, {'input': '1000 3\r\n', 'output': ['330155123']}, {'input': '8 8\r\n', 'output': ['2097152']}, {'input': '1000 4\r\n', 'output': ['660270610']}, {'input': '3 3\r\n', 'output': ['9']}] | [{'input': '657 3\r\n', 'output': ['771999480']}, {'input': '685 7\r\n', 'output': ['840866481']}, {'input': '876 8\r\n', 'output': ['703293724']}, {'input': '10 7\r\n', 'output': ['3176523']}, {'input': '1000 5\r\n', 'output': ['583047503']}] | [{'input': '1000 6\r\n', 'output': ['834332109']}, {'input': '137 5\r\n', 'output': ['160909830']}, {'input': '10 7\r\n', 'output': ['3176523']}, {'input': '1000 4\r\n', 'output': ['660270610']}, {'input': '12 8\r\n', 'output': ['536870912']}] | [{'input': '8 8\r\n', 'output': ['2097152']}, {'input': '1 1\r\n', 'output': ['1']}, {'input': '3 3\r\n', 'output': ['9']}, {'input': '137 5\r\n', 'output': ['160909830']}, {'input': '1000 6\r\n', 'output': ['834332109']}] | [{'input': '1000 3\r\n', 'output': ['330155123']}, {'input': '1000 6\r\n', 'output': ['834332109']}, {'input': '1 1\r\n', 'output': ['1']}, {'input': '8 8\r\n', 'output': ['2097152']}, {'input': '999 7\r\n', 'output': ['490075342']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 50 | 100 | 100 | 100 |
["1 3 8 1 1", "4 2 9 4 2", "5 5 25 4 3", "100 100 1000000000000000000 100 100"] | The first and the only line contains five integers n, m, k, x and y (1ββ€βn,βmββ€β100,β1ββ€βkββ€β1018,β1ββ€βxββ€βn,β1ββ€βyββ€βm). | e61debcad37eaa9a6e21d7a2122b8b21 | #include <stdio.h>
#include <string.h>
#include <stdbool.h>
#define MAX 1000010
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)
long long len, n, m, k, x, y;
long long X[MAX], Y[MAX], counter[1010][1010];
int main(){
long long i, j, v, min_v, max_v;
while (scanf("%lld %lld %lld %lld %lld", &n, &m, &k, &x, &y) != EOF){
len = 0;
clr(counter);
for (i = 1; i < n; i++){
for (j = 1; j <= m; j++){
X[len] = i, Y[len++] = j;
}
}
for (i = n; i > 1; i--){
for (j = 1; j <= m; j++){
X[len] = i, Y[len++] = j;
}
}
if (n == 1){
for (i = 1; i <= m; i++) X[len] = 1, Y[len++] = i;
}
for (i = 0; i < len; i++) counter[X[i]][Y[i]] += (k / len);
k %= len;
for (i = 0; i < k; i++) counter[X[i]][Y[i]]++;
min_v = max_v = counter[1][1];
for (i = 1; i <= n; i++){
for (j = 1; j <= m; j++){
if (counter[i][j] < min_v) min_v = counter[i][j];
if (counter[i][j] > max_v) max_v = counter[i][j];
}
}
printf("%lld %lld %lld\n", max_v, min_v, counter[x][y]);
}
return 0;
}
| ["3 2 3", "2 1 1", "1 1 1", "101010101010101 50505050505051 50505050505051"] | C | NoteThe order of asking pupils in the first test: the pupil from the first row who seats at the first table, it means it is Sergei; the pupil from the first row who seats at the second table; the pupil from the first row who seats at the third table; the pupil from the first row who seats at the first table, it means it is Sergei; the pupil from the first row who seats at the second table; the pupil from the first row who seats at the third table; the pupil from the first row who seats at the first table, it means it is Sergei; the pupil from the first row who seats at the second table; The order of asking pupils in the second test: the pupil from the first row who seats at the first table; the pupil from the first row who seats at the second table; the pupil from the second row who seats at the first table; the pupil from the second row who seats at the second table; the pupil from the third row who seats at the first table; the pupil from the third row who seats at the second table; the pupil from the fourth row who seats at the first table; the pupil from the fourth row who seats at the second table, it means it is Sergei; the pupil from the third row who seats at the first table; | Print three integers: the maximum number of questions a particular pupil is asked, the minimum number of questions a particular pupil is asked, how many times the teacher asked Sergei. | On the Literature lesson Sergei noticed an awful injustice, it seems that some students are asked more often than others.Seating in the class looks like a rectangle, where n rows with m pupils in each. The teacher asks pupils in the following order: at first, she asks all pupils from the first row in the order of their seating, then she continues to ask pupils from the next row. If the teacher asked the last row, then the direction of the poll changes, it means that she asks the previous row. The order of asking the rows looks as follows: the 1-st row, the 2-nd row, ..., the nβ-β1-st row, the n-th row, the nβ-β1-st row, ..., the 2-nd row, the 1-st row, the 2-nd row, ...The order of asking of pupils on the same row is always the same: the 1-st pupil, the 2-nd pupil, ..., the m-th pupil.During the lesson the teacher managed to ask exactly k questions from pupils in order described above. Sergei seats on the x-th row, on the y-th place in the row. Sergei decided to prove to the teacher that pupils are asked irregularly, help him count three values: the maximum number of questions a particular pupil is asked, the minimum number of questions a particular pupil is asked, how many times the teacher asked Sergei. If there is only one row in the class, then the teacher always asks children from this row. | [{"input": "1 3 8 1 1\r\n", "output": ["3 2 3", "3 2 3"]}, {"input": "4 2 9 4 2\r\n", "output": ["2 1 1"]}, {"input": "5 5 25 4 3\r\n", "output": ["1 1 1"]}, {"input": "100 100 1000000000000000000 100 100\r\n", "output": ["101010101010101 50505050505051 50505050505051"]}, {"input": "3 2 15 2 2\r\n", "output": ["4 2 3"]}, {"input": "4 1 8 3 1\r\n", "output": ["3 1 2"]}, {"input": "3 2 8 2 1\r\n", "output": ["2 1 2"]}, {"input": "4 2 9 4 1\r\n", "output": ["2 1 1"]}, {"input": "1 3 7 1 1\r\n", "output": ["3 2 3", "3 2 3"]}, {"input": "2 2 8 2 1\r\n", "output": ["2 2 2"]}, {"input": "3 1 6 2 1\r\n", "output": ["3 1 3"]}, {"input": "5 6 30 5 4\r\n", "output": ["1 1 1"]}, {"input": "3 8 134010 3 4\r\n", "output": ["8376 4188 4188"]}, {"input": "10 10 25 5 1\r\n", "output": ["1 0 0"]}, {"input": "100 100 1000000000 16 32\r\n", "output": ["101011 50505 101010"]}, {"input": "100 100 1 23 39\r\n", "output": ["1 0 0"]}, {"input": "1 1 1000000000 1 1\r\n", "output": ["1000000000 1000000000 1000000000", "1000000000 1000000000 1000000000"]}, {"input": "1 1 1 1 1\r\n", "output": ["1 1 1", "1 1 1"]}, {"input": "47 39 1772512 1 37\r\n", "output": ["989 494 495"]}, {"input": "37 61 421692 24 49\r\n", "output": ["192 96 192"]}, {"input": "89 97 875341288 89 96\r\n", "output": ["102547 51273 51274"]}, {"input": "100 1 1000000000000 100 1\r\n", "output": ["10101010101 5050505051 5050505051"]}, {"input": "1 100 1000000000000 1 100\r\n", "output": ["10000000000 10000000000 10000000000", "10000000000 10000000000 10000000000"]}, {"input": "2 4 6 1 4\r\n", "output": ["1 0 1"]}, {"input": "2 4 6 1 3\r\n", "output": ["1 0 1"]}, {"input": "2 4 49 1 1\r\n", "output": ["7 6 7"]}, {"input": "3 3 26 1 1\r\n", "output": ["4 2 3"]}, {"input": "5 2 77 4 2\r\n", "output": ["10 5 10"]}, {"input": "2 5 73 2 3\r\n", "output": ["8 7 7"]}, {"input": "5 2 81 5 1\r\n", "output": ["10 5 5"]}, {"input": "4 5 93 1 2\r\n", "output": ["6 3 4"]}, {"input": "4 4 74 4 1\r\n", "output": ["6 3 3"]}, {"input": "5 3 47 2 1\r\n", "output": ["4 2 4"]}, {"input": "5 4 61 1 1\r\n", "output": ["4 2 2"]}, {"input": "4 4 95 1 1\r\n", "output": ["8 4 4"]}, {"input": "2 5 36 1 3\r\n", "output": ["4 3 4"]}, {"input": "5 2 9 5 1\r\n", "output": ["1 0 1"]}, {"input": "4 1 50 1 1\r\n", "output": ["17 8 9"]}, {"input": "3 2 83 1 2\r\n", "output": ["21 10 11"]}, {"input": "3 5 88 1 5\r\n", "output": ["9 4 5"]}, {"input": "4 2 89 1 2\r\n", "output": ["15 7 8"]}, {"input": "2 1 1 1 1\r\n", "output": ["1 0 1"]}, {"input": "5 3 100 2 1\r\n", "output": ["9 4 9"]}, {"input": "4 4 53 3 1\r\n", "output": ["5 2 4"]}, {"input": "4 3 1 3 3\r\n", "output": ["1 0 0"]}, {"input": "3 5 1 2 1\r\n", "output": ["1 0 0"]}, {"input": "5 2 2 4 1\r\n", "output": ["1 0 0"]}, {"input": "3 3 1 3 2\r\n", "output": ["1 0 0"]}, {"input": "1 1 100 1 1\r\n", "output": ["100 100 100", "100 100 100"]}, {"input": "4 30 766048376 1 23\r\n", "output": ["8511649 4255824 4255825"]}, {"input": "3 90 675733187 1 33\r\n", "output": ["3754073 1877036 1877037"]}, {"input": "11 82 414861345 1 24\r\n", "output": ["505929 252964 252965"]}, {"input": "92 10 551902461 1 6\r\n", "output": ["606487 303243 303244"]}, {"input": "18 83 706805205 1 17\r\n", "output": ["500925 250462 250463"]}, {"input": "1 12 943872212 1 1\r\n", "output": ["78656018 78656017 78656018", "78656018 78656017 78656018"]}, {"input": "91 15 237966754 78 6\r\n", "output": ["176272 88136 176272"]}, {"input": "58 66 199707458 15 9\r\n", "output": ["53086 26543 53085"]}, {"input": "27 34 77794947 24 4\r\n", "output": ["88004 44002 88004"]}, {"input": "22 89 981099971 16 48\r\n", "output": ["524934 262467 524933"]}, {"input": "10 44 222787770 9 25\r\n", "output": ["562596 281298 562596"]}, {"input": "9 64 756016805 7 55\r\n", "output": ["1476596 738298 1476595"]}, {"input": "91 86 96470485 12 43\r\n", "output": ["12464 6232 12464"]}, {"input": "85 53 576663715 13 1\r\n", "output": ["129530 64765 129529"]}, {"input": "2 21 196681588 2 18\r\n", "output": ["4682895 4682894 4682895"]}, {"input": "8 29 388254841 6 29\r\n", "output": ["1912586 956293 1912585"]}, {"input": "2 59 400923999 2 43\r\n", "output": ["3397662 3397661 3397661"]}, {"input": "3 71 124911502 1 67\r\n", "output": ["879658 439829 439829"]}, {"input": "1 17 523664480 1 4\r\n", "output": ["30803793 30803792 30803793", "30803793 30803792 30803793"]}, {"input": "11 27 151005021 3 15\r\n", "output": ["559278 279639 559278"]}, {"input": "7 32 461672865 4 11\r\n", "output": ["2404547 1202273 2404546"]}, {"input": "2 90 829288586 1 57\r\n", "output": ["4607159 4607158 4607159"]}, {"input": "17 5 370710486 2 1\r\n", "output": ["4633882 2316941 4633881"]}, {"input": "88 91 6317 70 16\r\n", "output": ["1 0 1"]}, {"input": "19 73 1193 12 46\r\n", "output": ["1 0 1"]}, {"input": "84 10 405 68 8\r\n", "output": ["1 0 0"]}, {"input": "92 80 20 9 69\r\n", "output": ["1 0 0"]}, {"input": "69 21 203 13 16\r\n", "output": ["1 0 0"]}, {"input": "63 22 1321 61 15\r\n", "output": ["1 0 0"]}, {"input": "56 83 4572 35 22\r\n", "output": ["1 0 1"]}, {"input": "36 19 684 20 15\r\n", "output": ["1 1 1"]}, {"input": "33 2 1 8 2\r\n", "output": ["1 0 0"]}, {"input": "76 74 1 38 39\r\n", "output": ["1 0 0"]}, {"input": "1 71 1000000000000000000 1 5\r\n", "output": ["14084507042253522 14084507042253521 14084507042253522", "14084507042253522 14084507042253521 14084507042253522"]}, {"input": "13 89 1000000000000000000 10 14\r\n", "output": ["936329588014982 468164794007491 936329588014982"]}, {"input": "1 35 1000000000000000000 1 25\r\n", "output": ["28571428571428572 28571428571428571 28571428571428571", "28571428571428572 28571428571428571 28571428571428571"]}, {"input": "81 41 1000000000000000000 56 30\r\n", "output": ["304878048780488 152439024390244 304878048780488"]}, {"input": "4 39 1000000000000000000 3 32\r\n", "output": ["8547008547008547 4273504273504273 8547008547008547"]}, {"input": "21 49 1000000000000000000 18 11\r\n", "output": ["1020408163265307 510204081632653 1020408163265306"]}, {"input": "91 31 1000000000000000000 32 7\r\n", "output": ["358422939068101 179211469534050 358422939068101"]}, {"input": "51 99 1000000000000000000 48 79\r\n", "output": ["202020202020203 101010101010101 202020202020202"]}, {"input": "5 99 1000000000000000000 4 12\r\n", "output": ["2525252525252526 1262626262626263 2525252525252525"]}, {"input": "100 100 1000000000000000000 1 1\r\n", "output": ["101010101010101 50505050505051 50505050505051"]}, {"input": "100 100 1000000000000000000 31 31\r\n", "output": ["101010101010101 50505050505051 101010101010101"]}, {"input": "1 100 1000000000000000000 1 1\r\n", "output": ["10000000000000000 10000000000000000 10000000000000000", "10000000000000000 10000000000000000 10000000000000000"]}, {"input": "1 100 1000000000000000000 1 35\r\n", "output": ["10000000000000000 10000000000000000 10000000000000000", "10000000000000000 10000000000000000 10000000000000000"]}, {"input": "100 1 1000000000000000000 1 1\r\n", "output": ["10101010101010101 5050505050505051 5050505050505051"]}, {"input": "100 1 1000000000000000000 35 1\r\n", "output": ["10101010101010101 5050505050505051 10101010101010101"]}, {"input": "1 1 1000000000000000000 1 1\r\n", "output": ["1000000000000000000 1000000000000000000 1000000000000000000", "1000000000000000000 1000000000000000000 1000000000000000000"]}, {"input": "3 2 5 1 1\r\n", "output": ["1 0 1"]}, {"input": "100 100 10001 1 1\r\n", "output": ["2 1 1"]}, {"input": "1 5 7 1 3\r\n", "output": ["2 1 1", "2 1 1"]}, {"input": "2 2 7 1 1\r\n", "output": ["2 1 2"]}, {"input": "4 1 5 3 1\r\n", "output": ["2 1 2"]}, {"input": "2 3 4 2 3\r\n", "output": ["1 0 0"]}, {"input": "3 5 21 1 2\r\n", "output": ["2 1 1"]}, {"input": "2 4 14 1 1\r\n", "output": ["2 1 2"]}, {"input": "5 9 8 5 4\r\n", "output": ["1 0 0"]}, {"input": "2 6 4 1 3\r\n", "output": ["1 0 1"]}, {"input": "1 5 9 1 1\r\n", "output": ["2 1 2", "2 1 2"]}, {"input": "1 5 3 1 2\r\n", "output": ["1 0 1", "1 0 1"]}] | 100 | 100 | 100 | [{'input': '4 2 9 4 1\r\n', 'output': ['2 1 1']}, {'input': '17 5 370710486 2 1\r\n', 'output': ['4633882 2316941 4633881']}, {'input': '27 34 77794947 24 4\r\n', 'output': ['88004 44002 88004']}, {'input': '92 10 551902461 1 6\r\n', 'output': ['606487 303243 303244']}, {'input': '2 3 4 2 3\r\n', 'output': ['1 0 0']}] | [{'input': '4 1 8 3 1\r\n', 'output': ['3 1 2']}, {'input': '5 2 9 5 1\r\n', 'output': ['1 0 1']}, {'input': '63 22 1321 61 15\r\n', 'output': ['1 0 0']}, {'input': '1 3 8 1 1\r\n', 'output': ['3 2 3', '3 2 3']}, {'input': '1 100 1000000000000 1 100\r\n', 'output': ['10000000000 10000000000 10000000000', '10000000000 10000000000 10000000000']}] | [{'input': '1 3 7 1 1\r\n', 'output': ['3 2 3', '3 2 3']}, {'input': '5 2 81 5 1\r\n', 'output': ['10 5 5']}, {'input': '100 1 1000000000000 100 1\r\n', 'output': ['10101010101 5050505051 5050505051']}, {'input': '3 8 134010 3 4\r\n', 'output': ['8376 4188 4188']}, {'input': '1 1 1000000000000000000 1 1\r\n', 'output': ['1000000000000000000 1000000000000000000 1000000000000000000', '1000000000000000000 1000000000000000000 1000000000000000000']}] | [{'input': '1 3 7 1 1\r\n', 'output': ['3 2 3', '3 2 3']}, {'input': '4 3 1 3 3\r\n', 'output': ['1 0 0']}, {'input': '3 5 1 2 1\r\n', 'output': ['1 0 0']}, {'input': '5 3 100 2 1\r\n', 'output': ['9 4 9']}, {'input': '1 3 8 1 1\r\n', 'output': ['3 2 3', '3 2 3']}] | [{'input': '5 2 9 5 1\r\n', 'output': ['1 0 1']}, {'input': '85 53 576663715 13 1\r\n', 'output': ['129530 64765 129529']}, {'input': '1 1 1 1 1\r\n', 'output': ['1 1 1', '1 1 1']}, {'input': '5 6 30 5 4\r\n', 'output': ['1 1 1']}, {'input': '1 100 1000000000000000000 1 35\r\n', 'output': ['10000000000000000 10000000000000000 10000000000000000', '10000000000000000 10000000000000000 10000000000000000']}] | 100 | 100 | 100 | 100 | 100 | 95.45 | 100 | 100 | 100 | 100 | 88.46 | 100 | 100 | 100 | 100 | 51 | 100 | 99.09 | 97.692 |
["3 5 6 1\n1 2 3", "4 40 50 10\n10 20 30 25", "5 25 35 10\n10 10 20 10 20"] | The first line contains four integers n, l, r, x (1ββ€βnββ€β15, 1ββ€βlββ€βrββ€β109, 1ββ€βxββ€β106) β the number of problems you have, the minimum and maximum value of total difficulty of the problemset and the minimum difference in difficulty between the hardest problem in the pack and the easiest one, respectively. The second line contains n integers c1,βc2,β...,βcn (1ββ€βciββ€β106) β the difficulty of each problem. | 0d43104a0de924cdcf8e4aced5aa825d | #include <stdio.h>
int main()
{
char n,i;
long l,r,x,j;
long min,max,sum,count=0;
char s;
scanf("%d%ld%ld%ld",&n,&l,&r,&x);
long c[n];
for(i=0;i<n;i++)
scanf("%ld",c+i);
long a=1L<<n;
for(j=1;j<a;j++){
min=1000000;
max=1;
sum=0;
s=0;
for(i=0;i<n;i++)
if(j&(1L<<i)){
if(c[i]<min)min=c[i];
if(c[i]>max)max=c[i];
sum+=c[i];
s++;
}
if(s>1 && sum>=l && sum<=r && (max-min)>=x)
count++;
}
printf("%ld\n",count);
return 0;
}
| ["2", "2", "6"] | C | NoteIn the first example two sets are suitable, one consisting of the second and third problem, another one consisting of all three problems.In the second example, two sets of problems are suitable β the set of problems with difficulties 10 and 30 as well as the set of problems with difficulties 20 and 30.In the third example any set consisting of one problem of difficulty 10 and one problem of difficulty 20 is suitable. | Print the number of ways to choose a suitable problemset for the contest. | You have n problems. You have estimated the difficulty of the i-th one as integer ci. Now you want to prepare a problemset for a contest, using some of the problems you've made.A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest must be at least l and at most r. Also, you think that the difference between difficulties of the easiest and the hardest of the chosen problems must be at least x.Find the number of ways to choose a problemset for the contest. | [{"input": "3 5 6 1\r\n1 2 3\r\n", "output": ["2"]}, {"input": "4 40 50 10\r\n10 20 30 25\r\n", "output": ["2"]}, {"input": "5 25 35 10\r\n10 10 20 10 20\r\n", "output": ["6"]}, {"input": "4 15 60 10\r\n10 20 30 25\r\n", "output": ["6"]}, {"input": "1 10 20 1\r\n15\r\n", "output": ["0"]}, {"input": "10 626451 11471247 246428\r\n369649 684428 303821 287098 422756 301599 720377 177567 515216 750602\r\n", "output": ["914"]}, {"input": "15 1415849 15540979 356865\r\n8352 960238 276753 259695 712845 945369 60023 920446 181269 392011 318488 857649 30681 740872 115749\r\n", "output": ["31485"]}, {"input": "7 1000 2000 1\r\n10 20 30 40 50 60 70\r\n", "output": ["0"]}, {"input": "4 10 20 1\r\n4 6 4 6\r\n", "output": ["9"]}, {"input": "4 10 20 1\r\n5 15 13 7\r\n", "output": ["4"]}, {"input": "2 10 20 5\r\n5 10\r\n", "output": ["1"]}, {"input": "5 1098816 3969849 167639\r\n85627 615007 794045 530104 7091\r\n", "output": ["15"]}, {"input": "13 700147 8713522 390093\r\n996812 94040 954140 545670 369698 423872 365802 784830 700267 960664 949252 84637 257447\r\n", "output": ["8026"]}, {"input": "15 4531977 20754263 137419\r\n637830 85299 755530 64382 896833 879525 331501 148182 741013 192101 112217 52165 702790 988594 587499\r\n", "output": ["6759"]}, {"input": "15 2572491 5084070 823435\r\n570344 78552 775918 501843 844935 71141 331498 636557 435494 715447 992666 831188 28969 171046 989614\r\n", "output": ["15078"]}, {"input": "15 4789415 23152928 233992\r\n502422 273992 449428 947379 700461 681985 857134 243310 478052 77769 936151 642380 464695 281772 964693\r\n", "output": ["10875"]}, {"input": "3 390224 390224 1\r\n264237 125987 288891\r\n", "output": ["1"]}, {"input": "7 1652707 1652707 1\r\n492387 684636 235422 332532 924898 499872 192988\r\n", "output": ["1"]}, {"input": "10 501107 501107 1\r\n843967 30518 196518 619138 204862 690754 274071 550121 173607 359971\r\n", "output": ["1"]}, {"input": "15 6627289 6627289 1\r\n683844 183950 184972 764255 211665 842336 790234 815301 914823 513046 93547 713159 554415 200951 388028\r\n", "output": ["1"]}, {"input": "15 5083470 5083470 1\r\n978510 643688 591921 723137 573784 346171 920030 352119 528857 365128 627302 308557 716247 263519 654230\r\n", "output": ["1"]}, {"input": "15 6558665 6558665 1\r\n572491 435494 916457 775918 823435 78552 501843 331498 71141 844935 636557 992666 570344 831188 715447\r\n", "output": ["1"]}, {"input": "10 159699 10967276 3542\r\n998862 999751 995306 992648 992661 991407 997503 998809 999740 997669\r\n", "output": ["942"]}, {"input": "5 2815840 8479687 4082\r\n991137 992161 997887 998891 994990\r\n", "output": ["14"]}, {"input": "15 2898377 6694755 721\r\n992733 999159 990076 996808 990975 993338 993234 994757 997873 993303 994409 993801 998027 990495 999287\r\n", "output": ["9819"]}, {"input": "6 20 70 1\r\n10 10 20 20 30 30\r\n", "output": ["35"]}, {"input": "6 20 70 1\r\n10 10 10 10 10 10\r\n", "output": ["0"]}, {"input": "15 1 1000000000 1\r\n10 20 30 40 50 60 70 80 90 100 110 120 130 140 150\r\n", "output": ["32752"]}, {"input": "6 30 40 1\r\n19 20 21 14 15 16\r\n", "output": ["13"]}, {"input": "4 5 234 2\r\n10 9 12 11\r\n", "output": ["8"]}] | 100 | 100 | 100 | [{'input': '15 6558665 6558665 1\r\n572491 435494 916457 775918 823435 78552 501843 331498 71141 844935 636557 992666 570344 831188 715447\r\n', 'output': ['1']}, {'input': '15 2572491 5084070 823435\r\n570344 78552 775918 501843 844935 71141 331498 636557 435494 715447 992666 831188 28969 171046 989614\r\n', 'output': ['15078']}, {'input': '13 700147 8713522 390093\r\n996812 94040 954140 545670 369698 423872 365802 784830 700267 960664 949252 84637 257447\r\n', 'output': ['8026']}, {'input': '3 390224 390224 1\r\n264237 125987 288891\r\n', 'output': ['1']}, {'input': '15 1415849 15540979 356865\r\n8352 960238 276753 259695 712845 945369 60023 920446 181269 392011 318488 857649 30681 740872 115749\r\n', 'output': ['31485']}] | [{'input': '1 10 20 1\r\n15\r\n', 'output': ['0']}, {'input': '15 1 1000000000 1\r\n10 20 30 40 50 60 70 80 90 100 110 120 130 140 150\r\n', 'output': ['32752']}, {'input': '3 390224 390224 1\r\n264237 125987 288891\r\n', 'output': ['1']}, {'input': '6 20 70 1\r\n10 10 20 20 30 30\r\n', 'output': ['35']}, {'input': '15 2898377 6694755 721\r\n992733 999159 990076 996808 990975 993338 993234 994757 997873 993303 994409 993801 998027 990495 999287\r\n', 'output': ['9819']}] | [{'input': '3 390224 390224 1\r\n264237 125987 288891\r\n', 'output': ['1']}, {'input': '7 1652707 1652707 1\r\n492387 684636 235422 332532 924898 499872 192988\r\n', 'output': ['1']}, {'input': '6 30 40 1\r\n19 20 21 14 15 16\r\n', 'output': ['13']}, {'input': '4 40 50 10\r\n10 20 30 25\r\n', 'output': ['2']}, {'input': '15 6558665 6558665 1\r\n572491 435494 916457 775918 823435 78552 501843 331498 71141 844935 636557 992666 570344 831188 715447\r\n', 'output': ['1']}] | [{'input': '4 40 50 10\r\n10 20 30 25\r\n', 'output': ['2']}, {'input': '2 10 20 5\r\n5 10\r\n', 'output': ['1']}, {'input': '10 626451 11471247 246428\r\n369649 684428 303821 287098 422756 301599 720377 177567 515216 750602\r\n', 'output': ['914']}, {'input': '4 15 60 10\r\n10 20 30 25\r\n', 'output': ['6']}, {'input': '15 2572491 5084070 823435\r\n570344 78552 775918 501843 844935 71141 331498 636557 435494 715447 992666 831188 28969 171046 989614\r\n', 'output': ['15078']}] | [{'input': '4 5 234 2\r\n10 9 12 11\r\n', 'output': ['8']}, {'input': '6 30 40 1\r\n19 20 21 14 15 16\r\n', 'output': ['13']}, {'input': '5 1098816 3969849 167639\r\n85627 615007 794045 530104 7091\r\n', 'output': ['15']}, {'input': '7 1652707 1652707 1\r\n492387 684636 235422 332532 924898 499872 192988\r\n', 'output': ['1']}, {'input': '10 159699 10967276 3542\r\n998862 999751 995306 992648 992661 991407 997503 998809 999740 997669\r\n', 'output': ['942']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 52 | 100 | 100 | 100 |
["2 2", "1 2"] | The first line contains two integers w and h (1ββ€βw,βhββ€β4000) β the rectangle's sizes. | 42454dcf7d073bf12030367eb094eb8c | #include<stdio.h>
int main()
{
long long int c=0,w,h,n,m;
scanf("%lld %lld",&w,&h);
if(w<2 || h<2)
{
printf("0\n");
return 0;
}
for(n=2;w>=n;n=n+2)
{
for(m=2;h>=m;m=m+2)
c=c+(h-(m-1))*(w-(n-1));
}
printf("%lld\n",c);
return 0;
}
| ["1", "0"] | C | NoteIn the first example there exists only one such rhombus. Its vertices are located at points (1,β0), (2,β1), (1,β2), (0,β1). | Print a single number β the number of sought rhombi. 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. | You have two positive integers w and h. Your task is to count the number of rhombi which have the following properties: Have positive area. With vertices at integer points. All vertices of the rhombi are located inside or on the border of the rectangle with vertices at points (0,β0), (w,β0), (w,βh), (0,βh). In other words, for all vertices (xi,βyi) of the rhombus the following conditions should fulfill: 0ββ€βxiββ€βw and 0ββ€βyiββ€βh. Its diagonals are parallel to the axis. Count the number of such rhombi.Let us remind you that a rhombus is a quadrilateral whose four sides all have the same length. | [{"input": "2 2\r\n", "output": ["1"]}, {"input": "1 2\r\n", "output": ["0"]}, {"input": "1 4000\r\n", "output": ["0"]}, {"input": "4000 1\r\n", "output": ["0"]}, {"input": "4000 4000\r\n", "output": ["16000000000000"]}, {"input": "15 10\r\n", "output": ["1400"]}, {"input": "7 9\r\n", "output": ["240"]}, {"input": "17 17\r\n", "output": ["5184"]}, {"input": "7 13\r\n", "output": ["504"]}, {"input": "9 14\r\n", "output": ["980"]}, {"input": "3 10\r\n", "output": ["50"]}, {"input": "14 2\r\n", "output": ["49"]}, {"input": "4 6\r\n", "output": ["36"]}, {"input": "18 2858\r\n", "output": ["165405321"]}, {"input": "14 1274\r\n", "output": ["19882681"]}, {"input": "25 2986\r\n", "output": ["347731644"]}, {"input": "13 1402\r\n", "output": ["20638842"]}, {"input": "2955 21\r\n", "output": ["240130660"]}, {"input": "1665 27\r\n", "output": ["126136192"]}, {"input": "3671 19\r\n", "output": ["303215400"]}, {"input": "2541 25\r\n", "output": ["251810520"]}, {"input": "1913 3980\r\n", "output": ["3623063809200"]}, {"input": "3727 2044\r\n", "output": ["3627108561888"]}, {"input": "2437 460\r\n", "output": ["78542851800"]}, {"input": "1499 2172\r\n", "output": ["662525703000"]}, {"input": "1 1\r\n", "output": ["0"]}] | 100 | 100 | 100 | [{'input': '2541 25\r\n', 'output': ['251810520']}, {'input': '2437 460\r\n', 'output': ['78542851800']}, {'input': '1665 27\r\n', 'output': ['126136192']}, {'input': '4 6\r\n', 'output': ['36']}, {'input': '1913 3980\r\n', 'output': ['3623063809200']}] | [{'input': '13 1402\r\n', 'output': ['20638842']}, {'input': '25 2986\r\n', 'output': ['347731644']}, {'input': '14 1274\r\n', 'output': ['19882681']}, {'input': '4000 4000\r\n', 'output': ['16000000000000']}, {'input': '7 13\r\n', 'output': ['504']}] | [{'input': '2955 21\r\n', 'output': ['240130660']}, {'input': '9 14\r\n', 'output': ['980']}, {'input': '25 2986\r\n', 'output': ['347731644']}, {'input': '2437 460\r\n', 'output': ['78542851800']}, {'input': '3727 2044\r\n', 'output': ['3627108561888']}] | [{'input': '1913 3980\r\n', 'output': ['3623063809200']}, {'input': '1499 2172\r\n', 'output': ['662525703000']}, {'input': '18 2858\r\n', 'output': ['165405321']}, {'input': '9 14\r\n', 'output': ['980']}, {'input': '25 2986\r\n', 'output': ['347731644']}] | [{'input': '2541 25\r\n', 'output': ['251810520']}, {'input': '25 2986\r\n', 'output': ['347731644']}, {'input': '13 1402\r\n', 'output': ['20638842']}, {'input': '4000 1\r\n', 'output': ['0']}, {'input': '7 13\r\n', 'output': ['504']}] | 100 | 100 | 100 | 100 | 100 | 81.82 | 81.82 | 81.82 | 81.82 | 100 | 75 | 75 | 75 | 75 | 87.5 | 53 | 100 | 85.456 | 77.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 | #include <stdio.h>
#define max(a, b) (((a) > (b)) ? (a) : (b))
int main(void) {
int i;
int c, wr, wb;
long long hr, hb;
long long ans;
scanf("%d %lld %lld %d %d", &c, &hr, &hb, &wr, &wb);
ans = 0;
for (i = 0; i <= c / wr && i * i <= c; i++)
ans = max(ans, hr * i + (c - wr * i) / wb * hb);
for (i = 0; i <= c / wb && i * i <= c; i++)
ans = max(ans, hb * i + (c - wb * i) / wr * hr);
printf("%lld\n", ans);
return 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': '977983517 9009 9108 1001 1012\r\n', 'output': ['8801851608']}, {'input': '962693577 967217455 967217455 2 2\r\n', 'output': ['465567015261784540']}, {'input': '983935533 33986 27367 59737 48104\r\n', 'output': ['559787479']}, {'input': '200000001 100000002 1 100000001 1\r\n', 'output': ['200000002']}, {'input': '999999999 999999998 5 999999999 5\r\n', 'output': ['999999998']}] | [{'input': '995503930 29205027 18903616 51333090 33226507\r\n', 'output': ['565303099']}, {'input': '1000000000 1 1 1 1000000000\r\n', 'output': ['1000000000']}, {'input': '901769477 367425909 220455545 5 3\r\n', 'output': ['66266693959035917']}, {'input': '903796108 270891702 270891702 1 1\r\n', 'output': ['244830865957095816']}, {'input': '947370735 115930744 347792233 1 3\r\n', 'output': ['109829394468167085']}] | [{'input': '910943911 38162 31949 67084 56162\r\n', 'output': ['518210503']}, {'input': '942733698 9180 9072 1020 1008\r\n', 'output': ['8484603228']}, {'input': '1000000000 2 1 3 4\r\n', 'output': ['666666666']}, {'input': '200000001 100000002 1 100000001 1\r\n', 'output': ['200000002']}, {'input': '983935533 115 108 65 61\r\n', 'output': ['1742049794']}] | [{'input': '911525551 740437472 740437472 3 3\r\n', 'output': ['224975891301803200']}, {'input': '1000000000 1000 999 100 1000000000\r\n', 'output': ['10000000000']}, {'input': '1000000000 1000 1000 1 1\r\n', 'output': ['1000000000000']}, {'input': '977983517 9009 9108 1001 1012\r\n', 'output': ['8801851608']}, {'input': '994040035 740285170 246761723 3 1\r\n', 'output': ['245291032098926983']}] | [{'input': '1000000000 1 1 11 11\r\n', 'output': ['90909090']}, {'input': '949164751 36679609 23634069 64467968 41539167\r\n', 'output': ['537909080']}, {'input': '911525551 740437472 740437472 3 3\r\n', 'output': ['224975891301803200']}, {'input': '910943911 107 105 60 59\r\n', 'output': ['1624516635']}, {'input': '907995862 367493085 293994468 5 4\r\n', 'output': ['66736440098722854']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 87.5 | 100 | 54 | 100 | 100 | 97.5 |
["1", "2", "3", "8"] | The first line of the input will contain a single integer, n (1ββ€βnββ€β100β000). | 757cd804aba01dc4bc108cb0722f68dc | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
scanf("%d",&n);
int a[110]={0};
int i;
for(i=1;;i++)
{
if(n==1) {break;}
int yushu,deshu;
yushu=n%2;
n=n/2;
a[i]=yushu;
if(n==1) {i++;break;}
}
printf("%d",i);
i--;
for(;i>=0;i--)
if(a[i]) printf(" %d",i);
printf("\n");
}
| ["1", "2", "2 1", "4"] | C | NoteIn the first sample, we only have a single slime with value 1. The final state of the board is just a single slime with value 1.In the second sample, we perform the following steps:Initially we place a single slime in a row by itself. Thus, row is initially 1.Then, we will add another slime. The row is now 1 1. Since two rightmost slimes have the same values, we should replace these slimes with one with value 2. Thus, the final state of the board is 2.In the third sample, after adding the first two slimes, our row is 2. After adding one more slime, the row becomes 2 1.In the last sample, the steps look as follows: 1 2 2 1 3 3 1 3 2 3 2 1 4 | Output a single line with k integers, where k is the number of slimes in the row after you've finished the procedure described in the problem statement. The i-th of these numbers should be the value of the i-th slime from the left. | Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other nβ-β1 slimes one by one. When you add a slime, you place it at the right of all already placed slimes. Then, while the last two slimes in the row have the same value v, you combine them together to create a slime with value vβ+β1.You would like to see what the final state of the row is after you've added all n slimes. Please print the values of the slimes in the row from left to right. | [{"input": "1\r\n", "output": ["1"]}, {"input": "2\r\n", "output": ["2"]}, {"input": "3\r\n", "output": ["2 1", "2 1"]}, {"input": "8\r\n", "output": ["4"]}, {"input": "100000\r\n", "output": ["17 16 11 10 8 6", "17 16 11 10 8 6"]}, {"input": "12345\r\n", "output": ["14 13 6 5 4 1", "14 13 6 5 4 1"]}, {"input": "32\r\n", "output": ["6"]}, {"input": "70958\r\n", "output": ["17 13 11 9 6 4 3 2", "17 13 11 9 6 4 3 2"]}, {"input": "97593\r\n", "output": ["17 15 14 13 12 11 9 6 5 4 1", "17 15 14 13 12 11 9 6 5 4 1"]}, {"input": "91706\r\n", "output": ["17 15 14 11 10 6 5 4 2", "17 15 14 11 10 6 5 4 2"]}, {"input": "85371\r\n", "output": ["17 15 12 11 9 7 6 5 4 2 1", "17 15 12 11 9 7 6 5 4 2 1"]}, {"input": "97205\r\n", "output": ["17 15 14 13 12 10 9 8 6 5 3 1", "17 15 14 13 12 10 9 8 6 5 3 1"]}, {"input": "34768\r\n", "output": ["16 11 10 9 8 7 5", "16 11 10 9 8 7 5"]}, {"input": "12705\r\n", "output": ["14 13 9 8 6 1", "14 13 9 8 6 1"]}, {"input": "30151\r\n", "output": ["15 14 13 11 9 8 7 3 2 1", "15 14 13 11 9 8 7 3 2 1"]}, {"input": "4974\r\n", "output": ["13 10 9 7 6 4 3 2", "13 10 9 7 6 4 3 2"]}, {"input": "32728\r\n", "output": ["15 14 13 12 11 10 9 8 7 5 4", "15 14 13 12 11 10 9 8 7 5 4"]}, {"input": "8192\r\n", "output": ["14"]}, {"input": "65536\r\n", "output": ["17"]}, {"input": "32\r\n", "output": ["6"]}, {"input": "256\r\n", "output": ["9"]}, {"input": "4096\r\n", "output": ["13"]}, {"input": "33301\r\n", "output": ["16 10 5 3 1", "16 10 5 3 1"]}, {"input": "16725\r\n", "output": ["15 9 7 5 3 1", "15 9 7 5 3 1"]}, {"input": "149\r\n", "output": ["8 5 3 1", "8 5 3 1"]}, {"input": "16277\r\n", "output": ["14 13 12 11 10 9 8 5 3 1", "14 13 12 11 10 9 8 5 3 1"]}, {"input": "99701\r\n", "output": ["17 16 11 9 7 6 5 3 1", "17 16 11 9 7 6 5 3 1"]}] | 100 | 100 | 100 | [{'input': '4974\r\n', 'output': ['13 10 9 7 6 4 3 2', '13 10 9 7 6 4 3 2']}, {'input': '70958\r\n', 'output': ['17 13 11 9 6 4 3 2', '17 13 11 9 6 4 3 2']}, {'input': '32\r\n', 'output': ['6']}, {'input': '3\r\n', 'output': ['2 1', '2 1']}, {'input': '8192\r\n', 'output': ['14']}] | [{'input': '97593\r\n', 'output': ['17 15 14 13 12 11 9 6 5 4 1', '17 15 14 13 12 11 9 6 5 4 1']}, {'input': '32\r\n', 'output': ['6']}, {'input': '3\r\n', 'output': ['2 1', '2 1']}, {'input': '4096\r\n', 'output': ['13']}, {'input': '33301\r\n', 'output': ['16 10 5 3 1', '16 10 5 3 1']}] | [{'input': '100000\r\n', 'output': ['17 16 11 10 8 6', '17 16 11 10 8 6']}, {'input': '2\r\n', 'output': ['2']}, {'input': '32\r\n', 'output': ['6']}, {'input': '97205\r\n', 'output': ['17 15 14 13 12 10 9 8 6 5 3 1', '17 15 14 13 12 10 9 8 6 5 3 1']}, {'input': '4096\r\n', 'output': ['13']}] | [{'input': '1\r\n', 'output': ['1']}, {'input': '85371\r\n', 'output': ['17 15 12 11 9 7 6 5 4 2 1', '17 15 12 11 9 7 6 5 4 2 1']}, {'input': '34768\r\n', 'output': ['16 11 10 9 8 7 5', '16 11 10 9 8 7 5']}, {'input': '16277\r\n', 'output': ['14 13 12 11 10 9 8 5 3 1', '14 13 12 11 10 9 8 5 3 1']}, {'input': '97593\r\n', 'output': ['17 15 14 13 12 11 9 6 5 4 1', '17 15 14 13 12 11 9 6 5 4 1']}] | [{'input': '3\r\n', 'output': ['2 1', '2 1']}, {'input': '100000\r\n', 'output': ['17 16 11 10 8 6', '17 16 11 10 8 6']}, {'input': '12705\r\n', 'output': ['14 13 9 8 6 1', '14 13 9 8 6 1']}, {'input': '30151\r\n', 'output': ['15 14 13 11 9 8 7 3 2 1', '15 14 13 11 9 8 7 3 2 1']}, {'input': '34768\r\n', 'output': ['16 11 10 9 8 7 5', '16 11 10 9 8 7 5']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 87.5 | 87.5 | 87.5 | 100 | 87.5 | 55 | 100 | 100 | 90 |
["2 3", "3 1"] | In the only line you are given two integers a, b (0ββ€βa,βbββ€β100) β the number of even and odd steps, accordingly. | ec5e3b3f5ee6a13eaf01b9a9a66ff037 | #include <stdio.h>
int main(void) {
// your code goes here
int i,j;
scanf("%d%d",&i,&j);
if(i==0&&j==0)
{
printf("NO");
}
else
{
if((i-j)==1||(j-i)==1||i==j)
{
printf("YES");
}
else
{
printf("NO");
}
}
return 0;
}
| ["YES", "NO"] | C | NoteIn the first example one of suitable intervals is from 1 to 5. The interval contains two even stepsΒ β 2 and 4, and three odd: 1, 3 and 5. | In the only line print "YES", if the interval of steps described above exists, and "NO" otherwise. | On her way to programming school tiger Dasha faced her first test β a huge staircase! The steps were numbered from one to infinity. As we know, tigers are very fond of all striped things, it is possible that it has something to do with their color. So on some interval of her way she calculated two values β the number of steps with even and odd numbers. You need to check whether there is an interval of steps from the l-th to the r-th (1ββ€βlββ€βr), for which values that Dasha has found are correct. | [{"input": "2 3\r\n", "output": ["YES"]}, {"input": "3 1\r\n", "output": ["NO"]}, {"input": "5 4\r\n", "output": ["YES"]}, {"input": "9 9\r\n", "output": ["YES"]}, {"input": "85 95\r\n", "output": ["NO"]}, {"input": "0 1\r\n", "output": ["YES"]}, {"input": "89 25\r\n", "output": ["NO"]}, {"input": "74 73\r\n", "output": ["YES"]}, {"input": "62 39\r\n", "output": ["NO"]}, {"input": "57 57\r\n", "output": ["YES"]}, {"input": "100 99\r\n", "output": ["YES"]}, {"input": "0 0\r\n", "output": ["NO"]}, {"input": "98 100\r\n", "output": ["NO"]}, {"input": "99 100\r\n", "output": ["YES"]}, {"input": "1 0\r\n", "output": ["YES"]}, {"input": "100 0\r\n", "output": ["NO"]}, {"input": "0 100\r\n", "output": ["NO"]}, {"input": "100 98\r\n", "output": ["NO"]}, {"input": "100 100\r\n", "output": ["YES"]}, {"input": "0 5\r\n", "output": ["NO"]}, {"input": "2 2\r\n", "output": ["YES"]}] | 100 | 100 | 100 | [{'input': '85 95\r\n', 'output': ['NO']}, {'input': '100 0\r\n', 'output': ['NO']}, {'input': '100 100\r\n', 'output': ['YES']}, {'input': '5 4\r\n', 'output': ['YES']}, {'input': '2 3\r\n', 'output': ['YES']}] | [{'input': '9 9\r\n', 'output': ['YES']}, {'input': '100 0\r\n', 'output': ['NO']}, {'input': '99 100\r\n', 'output': ['YES']}, {'input': '0 1\r\n', 'output': ['YES']}, {'input': '5 4\r\n', 'output': ['YES']}] | [{'input': '100 100\r\n', 'output': ['YES']}, {'input': '62 39\r\n', 'output': ['NO']}, {'input': '2 2\r\n', 'output': ['YES']}, {'input': '100 0\r\n', 'output': ['NO']}, {'input': '99 100\r\n', 'output': ['YES']}] | [{'input': '0 0\r\n', 'output': ['NO']}, {'input': '2 2\r\n', 'output': ['YES']}, {'input': '89 25\r\n', 'output': ['NO']}, {'input': '1 0\r\n', 'output': ['YES']}, {'input': '57 57\r\n', 'output': ['YES']}] | [{'input': '2 3\r\n', 'output': ['YES']}, {'input': '9 9\r\n', 'output': ['YES']}, {'input': '99 100\r\n', 'output': ['YES']}, {'input': '0 0\r\n', 'output': ['NO']}, {'input': '85 95\r\n', 'output': ['NO']}] | 100 | 100 | 100 | 100 | 100 | 87.5 | 87.5 | 87.5 | 100 | 100 | 70 | 90 | 60 | 80 | 80 | 56 | 100 | 92.5 | 76 |
["27", "4545"] | The first line contains a single integer x (1ββ€βxββ€β1018) β the number that Luke Skywalker gave to Chewbacca. | d5de5052b4e9bbdb5359ac6e05a18b61 | #include<stdio.h>
#include<string.h>
int main()
{
int i;
char arr[20];
int c=0,b[20];
scanf("%s",arr);
for(i=0;i<strlen(arr);i++)
{
b[i]=arr[i];
if(b[i]>=53)
{
b[i]=57-b[i];
if(b[0]==0)
b[0]=9;
}
else
{b[i]=b[i]-48;}
printf("%d",b[i]);
}
//printf("1");
return 0;
}
| ["22", "4444"] | C | null | Print the minimum possible positive number that Chewbacca can obtain after inverting some digits. The number shouldn't contain leading zeroes. | Luke Skywalker gave Chewbacca an integer number x. Chewbacca isn't good at numbers but he loves inverting digits in them. Inverting digit t means replacing it with digit 9β-βt. Help Chewbacca to transform the initial number x to the minimum possible positive number by inverting some (possibly, zero) digits. The decimal representation of the final number shouldn't start with a zero. | [{"input": "27\r\n", "output": ["22"]}, {"input": "4545\r\n", "output": ["4444"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "9\r\n", "output": ["9"]}, {"input": "8772\r\n", "output": ["1222"]}, {"input": "81\r\n", "output": ["11"]}, {"input": "71723447\r\n", "output": ["21223442"]}, {"input": "91730629\r\n", "output": ["91230320"]}, {"input": "420062703497\r\n", "output": ["420032203402"]}, {"input": "332711047202\r\n", "output": ["332211042202"]}, {"input": "3395184971407775\r\n", "output": ["3304114021402224"]}, {"input": "8464062628894325\r\n", "output": ["1434032321104324"]}, {"input": "164324828731963982\r\n", "output": ["134324121231033012"]}, {"input": "384979173822804784\r\n", "output": ["314020123122104214"]}, {"input": "41312150450968417\r\n", "output": ["41312140440031412"]}, {"input": "2156\r\n", "output": ["2143"]}, {"input": "1932\r\n", "output": ["1032"]}, {"input": "5902\r\n", "output": ["4002"]}, {"input": "5728\r\n", "output": ["4221"]}, {"input": "8537\r\n", "output": ["1432"]}, {"input": "55403857\r\n", "output": ["44403142"]}, {"input": "270739\r\n", "output": ["220230"]}, {"input": "28746918\r\n", "output": ["21243011"]}, {"input": "10279211\r\n", "output": ["10220211"]}, {"input": "40289679\r\n", "output": ["40210320"]}, {"input": "545203238506\r\n", "output": ["444203231403"]}, {"input": "461117063340\r\n", "output": ["431112033340"]}, {"input": "658492686568\r\n", "output": ["341402313431"]}, {"input": "857373361868\r\n", "output": ["142323331131"]}, {"input": "429325660016\r\n", "output": ["420324330013"]}, {"input": "9894448650287940\r\n", "output": ["9104441340212040"]}, {"input": "6354510839296263\r\n", "output": ["3344410130203233"]}, {"input": "6873575462224593\r\n", "output": ["3123424432224403"]}, {"input": "4237951492601449\r\n", "output": ["4232041402301440"]}, {"input": "2680352384836991\r\n", "output": ["2310342314133001"]}, {"input": "606187734191890310\r\n", "output": ["303112234101100310"]}, {"input": "351499943576823355\r\n", "output": ["341400043423123344"]}, {"input": "180593481782177068\r\n", "output": ["110403411212122031"]}, {"input": "999999999999999999\r\n", "output": ["900000000000000000"]}, {"input": "1000000000000000000\r\n", "output": ["1000000000000000000"]}, {"input": "9999\r\n", "output": ["9000"]}, {"input": "99\r\n", "output": ["90"]}, {"input": "9991\r\n", "output": ["9001"]}] | 100 | 100 | 100 | [{'input': '99\r\n', 'output': ['90']}, {'input': '81\r\n', 'output': ['11']}, {'input': '5902\r\n', 'output': ['4002']}, {'input': '71723447\r\n', 'output': ['21223442']}, {'input': '429325660016\r\n', 'output': ['420324330013']}] | [{'input': '384979173822804784\r\n', 'output': ['314020123122104214']}, {'input': '270739\r\n', 'output': ['220230']}, {'input': '4237951492601449\r\n', 'output': ['4232041402301440']}, {'input': '8464062628894325\r\n', 'output': ['1434032321104324']}, {'input': '10279211\r\n', 'output': ['10220211']}] | [{'input': '5902\r\n', 'output': ['4002']}, {'input': '8537\r\n', 'output': ['1432']}, {'input': '545203238506\r\n', 'output': ['444203231403']}, {'input': '1000000000000000000\r\n', 'output': ['1000000000000000000']}, {'input': '1932\r\n', 'output': ['1032']}] | [{'input': '9\r\n', 'output': ['9']}, {'input': '857373361868\r\n', 'output': ['142323331131']}, {'input': '10279211\r\n', 'output': ['10220211']}, {'input': '420062703497\r\n', 'output': ['420032203402']}, {'input': '9991\r\n', 'output': ['9001']}] | [{'input': '3395184971407775\r\n', 'output': ['3304114021402224']}, {'input': '55403857\r\n', 'output': ['44403142']}, {'input': '429325660016\r\n', 'output': ['420324330013']}, {'input': '164324828731963982\r\n', 'output': ['134324121231033012']}, {'input': '9999\r\n', 'output': ['9000']}] | 100 | 100 | 100 | 100 | 100 | 100 | 91.67 | 91.67 | 100 | 100 | 100 | 83.33 | 83.33 | 100 | 100 | 57 | 100 | 96.668 | 93.332 |
["3 7", "100 99", "100 50"] | The first line contains two integers w,βm (2ββ€βwββ€β109, 1ββ€βmββ€β109) β the number defining the masses of the weights and the mass of the item. | a74adcf0314692f8ac95f54d165d9582 | #include<stdio.h>
typedef unsigned u;
u w,m;
int main()
{
scanf("%u%u",&w,&m);
while(m)
{
if(m%w==1)--m;
if(m%w==w-1)++m;
if(m%w==0)m/=w;
else{printf("NO\n");return 0;}
}
printf("YES\n");
return 0;
}
| ["YES", "YES", "NO"] | C | NoteNote to the first sample test. One pan can have an item of mass 7 and a weight of mass 3, and the second pan can have two weights of masses 9 and 1, correspondingly. Then 7β+β3β=β9β+β1.Note to the second sample test. One pan of the scales can have an item of mass 99 and the weight of mass 1, and the second pan can have the weight of mass 100.Note to the third sample test. It is impossible to measure the weight of the item in the manner described in the input. | Print word 'YES' if the item can be weighted and 'NO' if it cannot. | Vanya has a scales for weighing loads and weights of masses w0,βw1,βw2,β...,βw100 grams where w is some integer not less than 2 (exactly one weight of each nominal value). Vanya wonders whether he can weight an item with mass m using the given weights, if the weights can be put on both pans of the scales. Formally speaking, your task is to determine whether it is possible to place an item of mass m and some weights on the left pan of the scales, and some weights on the right pan of the scales so that the pans of the scales were in balance. | [{"input": "3 7\r\n", "output": ["YES"]}, {"input": "100 99\r\n", "output": ["YES"]}, {"input": "100 50\r\n", "output": ["NO"]}, {"input": "1000000000 1\r\n", "output": ["YES"]}, {"input": "100 10002\r\n", "output": ["NO"]}, {"input": "4 7\r\n", "output": ["NO"]}, {"input": "4 11\r\n", "output": ["YES"]}, {"input": "5 781\r\n", "output": ["YES"]}, {"input": "7 9\r\n", "output": ["NO"]}, {"input": "5077 5988\r\n", "output": ["NO"]}, {"input": "2 9596\r\n", "output": ["YES"]}, {"input": "4 1069\r\n", "output": ["YES"]}, {"input": "4 7134\r\n", "output": ["NO"]}, {"input": "4 9083\r\n", "output": ["NO"]}, {"input": "4 7927\r\n", "output": ["NO"]}, {"input": "4 6772\r\n", "output": ["NO"]}, {"input": "5 782\r\n", "output": ["NO"]}, {"input": "4 1000000000\r\n", "output": ["NO"]}, {"input": "4 357913941\r\n", "output": ["YES"]}, {"input": "4 357918037\r\n", "output": ["NO"]}, {"input": "5 12207031\r\n", "output": ["YES"]}, {"input": "5 41503906\r\n", "output": ["YES"]}, {"input": "5 90332031\r\n", "output": ["NO"]}, {"input": "11 1786324\r\n", "output": ["YES"]}, {"input": "10 999\r\n", "output": ["YES"]}, {"input": "8 28087\r\n", "output": ["YES"]}, {"input": "8 28598\r\n", "output": ["NO"]}, {"input": "32 33586176\r\n", "output": ["YES"]}, {"input": "87 56631258\r\n", "output": ["YES"]}, {"input": "19 20\r\n", "output": ["YES"]}, {"input": "58 11316496\r\n", "output": ["YES"]}, {"input": "89 89\r\n", "output": ["YES"]}, {"input": "21 85756882\r\n", "output": ["YES"]}, {"input": "56 540897225\r\n", "output": ["YES"]}, {"input": "91 8189\r\n", "output": ["YES"]}, {"input": "27 14329927\r\n", "output": ["YES"]}, {"input": "58 198535\r\n", "output": ["YES"]}, {"input": "939 938\r\n", "output": ["YES"]}, {"input": "27463 754243832\r\n", "output": ["YES"]}, {"input": "21427 459137757\r\n", "output": ["YES"]}, {"input": "26045 26045\r\n", "output": ["YES"]}, {"input": "25336 25336\r\n", "output": ["YES"]}, {"input": "24627 24626\r\n", "output": ["YES"]}, {"input": "29245 855299270\r\n", "output": ["YES"]}, {"input": "28536 814274759\r\n", "output": ["YES"]}, {"input": "33154 33155\r\n", "output": ["YES"]}, {"input": "27118 27119\r\n", "output": ["YES"]}, {"input": "70 338171\r\n", "output": ["YES"]}, {"input": "24 346226\r\n", "output": ["NO"]}, {"input": "41 2966964\r\n", "output": ["NO"]}, {"input": "31 29792\r\n", "output": ["YES"]}, {"input": "48 2402\r\n", "output": ["NO"]}, {"input": "65 4159\r\n", "output": ["YES"]}, {"input": "20 67376840\r\n", "output": ["NO"]}, {"input": "72 5111\r\n", "output": ["YES"]}, {"input": "27 14349609\r\n", "output": ["YES"]}, {"input": "44 89146\r\n", "output": ["NO"]}, {"input": "22787 519292944\r\n", "output": ["NO"]}, {"input": "24525 601475624\r\n", "output": ["YES"]}, {"input": "3716 13816089\r\n", "output": ["NO"]}, {"input": "4020 4020\r\n", "output": ["YES"]}, {"input": "13766 13767\r\n", "output": ["YES"]}, {"input": "23512 23511\r\n", "output": ["YES"]}, {"input": "23816 567225671\r\n", "output": ["YES"]}, {"input": "33562 33564\r\n", "output": ["NO"]}, {"input": "33866 33866\r\n", "output": ["YES"]}, {"input": "13057 13059\r\n", "output": ["NO"]}, {"input": "441890232 441890232\r\n", "output": ["YES"]}, {"input": "401739553 401739553\r\n", "output": ["YES"]}, {"input": "285681920 285681919\r\n", "output": ["YES"]}, {"input": "464591587 464591588\r\n", "output": ["YES"]}, {"input": "703722884 703722884\r\n", "output": ["YES"]}, {"input": "982276216 982276216\r\n", "output": ["YES"]}, {"input": "867871061 867871062\r\n", "output": ["YES"]}, {"input": "48433217 48433216\r\n", "output": ["YES"]}, {"input": "8 324818663\r\n", "output": ["NO"]}, {"input": "7 898367507\r\n", "output": ["NO"]}, {"input": "6 471916351\r\n", "output": ["NO"]}, {"input": "5 45465196\r\n", "output": ["NO"]}, {"input": "9 768757144\r\n", "output": ["NO"]}, {"input": "8 342305988\r\n", "output": ["NO"]}, {"input": "6 114457122\r\n", "output": ["NO"]}, {"input": "6 688005966\r\n", "output": ["NO"]}, {"input": "4 556522107\r\n", "output": ["NO"]}, {"input": "3 130070951\r\n", "output": ["YES"]}, {"input": "6 558395604\r\n", "output": ["NO"]}, {"input": "5 131944448\r\n", "output": ["NO"]}, {"input": "2 1000000\r\n", "output": ["YES"]}, {"input": "2 22222222\r\n", "output": ["YES"]}, {"input": "3 100000000\r\n", "output": ["YES"]}, {"input": "3 100000001\r\n", "output": ["YES"]}, {"input": "3 100000002\r\n", "output": ["YES"]}, {"input": "3 100000003\r\n", "output": ["YES"]}, {"input": "3 100000004\r\n", "output": ["YES"]}, {"input": "2 1\r\n", "output": ["YES"]}, {"input": "2 1000000000\r\n", "output": ["YES"]}, {"input": "3 1000000000\r\n", "output": ["YES"]}, {"input": "99999 1000000000\r\n", "output": ["NO"]}, {"input": "10 1000000000\r\n", "output": ["YES"]}, {"input": "1000 1000000000\r\n", "output": ["YES"]}, {"input": "10 999999999\r\n", "output": ["YES"]}, {"input": "100 99999999\r\n", "output": ["YES"]}, {"input": "1000 999999999\r\n", "output": ["YES"]}, {"input": "1000 999999998\r\n", "output": ["NO"]}, {"input": "2 536870912\r\n", "output": ["YES"]}, {"input": "10 99\r\n", "output": ["YES"]}, {"input": "10 8\r\n", "output": ["NO"]}, {"input": "3 5\r\n", "output": ["YES"]}, {"input": "3 26\r\n", "output": ["YES"]}, {"input": "10 8888\r\n", "output": ["NO"]}, {"input": "3 8\r\n", "output": ["YES"]}, {"input": "3 984742145\r\n", "output": ["YES"]}, {"input": "4 43\r\n", "output": ["YES"]}, {"input": "1000000000 1000000000\r\n", "output": ["YES"]}, {"input": "4194304 4194305\r\n", "output": ["YES"]}, {"input": "10 899\r\n", "output": ["YES"]}, {"input": "4 47\r\n", "output": ["YES"]}, {"input": "4 822083581\r\n", "output": ["YES"]}, {"input": "3 999987989\r\n", "output": ["YES"]}, {"input": "4 31\r\n", "output": ["NO"]}, {"input": "4 15\r\n", "output": ["YES"]}, {"input": "100000000 100000001\r\n", "output": ["YES"]}] | 100 | 100 | 100 | [{'input': '22787 519292944\r\n', 'output': ['NO']}, {'input': '100 99\r\n', 'output': ['YES']}, {'input': '3716 13816089\r\n', 'output': ['NO']}, {'input': '3 8\r\n', 'output': ['YES']}, {'input': '4 7134\r\n', 'output': ['NO']}] | [{'input': '58 11316496\r\n', 'output': ['YES']}, {'input': '7 898367507\r\n', 'output': ['NO']}, {'input': '3 100000000\r\n', 'output': ['YES']}, {'input': '29245 855299270\r\n', 'output': ['YES']}, {'input': '1000 999999998\r\n', 'output': ['NO']}] | [{'input': '5 782\r\n', 'output': ['NO']}, {'input': '4 31\r\n', 'output': ['NO']}, {'input': '44 89146\r\n', 'output': ['NO']}, {'input': '2 9596\r\n', 'output': ['YES']}, {'input': '6 114457122\r\n', 'output': ['NO']}] | [{'input': '27 14329927\r\n', 'output': ['YES']}, {'input': '401739553 401739553\r\n', 'output': ['YES']}, {'input': '32 33586176\r\n', 'output': ['YES']}, {'input': '4 31\r\n', 'output': ['NO']}, {'input': '939 938\r\n', 'output': ['YES']}] | [{'input': '100000000 100000001\r\n', 'output': ['YES']}, {'input': '33562 33564\r\n', 'output': ['NO']}, {'input': '6 688005966\r\n', 'output': ['NO']}, {'input': '5 90332031\r\n', 'output': ['NO']}, {'input': '3 100000003\r\n', 'output': ['YES']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 58 | 100 | 100 | 100 |
["3"] | The first line contains a single integer n (0ββ€βnββ€β1000). | 1a335a9638523ca0315282a67e18eec7 | #include<stdio.h>
#define MOD 1000003
int power(int x,int y)
{
if(y==0)
return 1;
int temp=x;
while(--y)
{
x*=temp;
x%=MOD;
}
return x;
}
int main()
{
int y;
scanf("%d",&y);
if(y==0)
{
printf("%d",1);
return 0;
}
int res=power(3,y-1);
printf("%d\n",res);
return 0;
} | ["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': '1000\r\n', 'output': ['691074']}, {'input': '0\r\n', 'output': ['1']}, {'input': '11\r\n', 'output': ['59049']}, {'input': '226\r\n', 'output': ['376094']}, {'input': '617\r\n', 'output': ['247876']}] | [{'input': '226\r\n', 'output': ['376094']}, {'input': '617\r\n', 'output': ['247876']}, {'input': '857\r\n', 'output': ['562128']}, {'input': '15\r\n', 'output': ['782957']}, {'input': '1000\r\n', 'output': ['691074']}] | [{'input': '6\r\n', 'output': ['243']}, {'input': '1\r\n', 'output': ['1']}, {'input': '823\r\n', 'output': ['858672']}, {'input': '928\r\n', 'output': ['794863']}, {'input': '589\r\n', 'output': ['889192']}] | [{'input': '589\r\n', 'output': ['889192']}, {'input': '14\r\n', 'output': ['594320']}, {'input': '910\r\n', 'output': ['678945']}, {'input': '823\r\n', 'output': ['858672']}, {'input': '4\r\n', 'output': ['27']}] | [{'input': '15\r\n', 'output': ['782957']}, {'input': '823\r\n', 'output': ['858672']}, {'input': '857\r\n', 'output': ['562128']}, {'input': '696\r\n', 'output': ['695035']}, {'input': '226\r\n', 'output': ['376094']}] | 100 | 100 | 100 | 100 | 100 | 93.75 | 81.25 | 87.5 | 81.25 | 81.25 | 83.33 | 66.67 | 83.33 | 66.67 | 66.67 | 59 | 100 | 85 | 73.334 |
["2 3\n1 3", "2 4\n2 2", "3 5\n1 3 2"] | The first line of input contains two space-separated integers n and s (1ββ€βnββ€β20, 0ββ€βsββ€β1014). The second line contains n space-separated integers f1,βf2,β... fn (0ββ€βfiββ€β1012). | 8b883011eba9d15d284e54c7a85fcf74 | #include<stdio.h>
long long f[23],n,s,sum,inv[25];
int c[23];
int function(){
int i,t1,j=0;
i=1;
while(1){
if(c[i]==0){
c[i]=1;
break;
}else{
c[i]=0;
i++;
}
}
}
long long power(long long a, long long b, long long MOD) {
long long x = 1, y = a;
while(b > 0) {
if(b%2 == 1) {
x=(x*y);
if(x>MOD) x%=MOD;
}
y = (y*y);
if(y>MOD) y%=MOD;
b /= 2;
}
return x;
}
long long modInverse(long long a,long long m) {
if(inv[a]==0)
inv[a]=power(a,m-2,m);
return inv[a];
}
long long binomialCoeff(long long n, long long k)
{
long long i,res = 1;
if (k >( n - k))
k = n - k;
for ( i = 0; i < k; ++i)
{
res =(res* ((n - i)%1000000007))%1000000007;
res =(res* modInverse((i + 1),1000000007))%1000000007;
}
return res;
}
void recursion(int i,long long pow,int fac){
int j;
i=0;
while(1){
fac=1;
j=0;
pow=0;
for(i=1;i<=n;i++){
pow=pow+c[i]*(f[i]+1);
if(c[i]==1){ fac=fac*-1;
j++;
}
}
if(pow<=s){
sum=(sum+fac*binomialCoeff(n+s-pow-1,s-pow))%1000000007;
}
if(j==n) break;
function();
}
}
int main(){
long long i,j,k,l;
scanf("%lld %lld",&n,&s);
for(i=1;i<=n;i++) scanf("%lld",&f[i]);
recursion(1,0,1);
sum=(sum+1000000007)%1000000007;
printf("%lld\n",sum);
return 0;
}
| ["2", "1", "3"] | C | NoteSample 1. There are two ways of selecting 3 flowers: {1,β2} and {0,β3}.Sample 2. There is only one way of selecting 4 flowers: {2,β2}.Sample 3. There are three ways of selecting 5 flowers: {1,β2,β2}, {0,β3,β2}, and {1,β3,β1}. | Output a single integer β the number of ways in which Devu can select the flowers modulo (109β+β7). | Devu wants to decorate his garden with flowers. He has purchased n boxes, where the i-th box contains fi flowers. All flowers in a single box are of the same color (hence they are indistinguishable). Also, no two boxes have flowers of the same color.Now Devu wants to select exactly s flowers from the boxes to decorate his garden. Devu would like to know, in how many different ways can he select the flowers from each box? Since this number may be very large, he asks you to find the number modulo (109β+β7). Devu considers two ways different if there is at least one box from which different number of flowers are selected in these two ways. | [{"input": "2 3\r\n1 3\r\n", "output": ["2"]}, {"input": "2 4\r\n2 2\r\n", "output": ["1"]}, {"input": "3 5\r\n1 3 2\r\n", "output": ["3"]}, {"input": "2 270030023747\r\n891135146290 437305641972\r\n", "output": ["30021858"]}, {"input": "20 4385085334307\r\n273634411136 208521328637 450482376435 844118010709 197241285878 472126475472 2414038897 672334205413 809269727018 409013884362 739986692075 953956651947 462216461906 388007176838 245504550965 527140291750 632844435887 550532123833 757200390348 944901802640\r\n", "output": ["316418090"]}, {"input": "20 3752307092657\r\n283053521097 653583221811 681984546714 933027822250 487241474739 534269715560 834243597472 848019110117 485265346854 396702345118 408945102153 816559907551 401511139988 367150665755 712567362471 717769226958 548952754032 434801840119 879399744983 324531633609\r\n", "output": ["381258106"]}, {"input": "20 16619020188439\r\n1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000\r\n", "output": ["801984344"]}, {"input": "20 262144\r\n0 1 3 7 15 31 63 127 255 511 1023 2047 4095 8191 16383 32767 65535 131071 262143 524287\r\n", "output": ["725216474"]}, {"input": "20 5230175580\r\n2 8 26 80 242 728 2186 6560 19682 59048 177146 531440 1594322 4782968 14348906 43046720 129140162 387420488 1162261466 3486784400\r\n", "output": ["538211934"]}, {"input": "20 5230176570\r\n2 8 26 80 242 728 2186 6560 19682 59048 177146 531440 1594322 4782968 14348906 43046720 129140162 387420488 1162261466 3486784400\r\n", "output": ["19372190"]}, {"input": "20 818000201\r\n0 2 8 26 80 242 728 2186 6560 19682 59048 177146 531440 1594322 4782968 14348906 43046720 129140162 387420488 1162261466\r\n", "output": ["505949526"]}, {"input": "1 1\r\n1\r\n", "output": ["1"]}, {"input": "5 4\r\n3 3 4 4 4\r\n", "output": ["68"]}, {"input": "3 850878851187\r\n599705086316 802990808570 221067397125\r\n", "output": ["334902111"]}, {"input": "4 731767033652\r\n306127542694 172970942464 358017806176 394151815116\r\n", "output": ["418840506"]}, {"input": "5 1199105497223\r\n12549999072 542951076358 494968215227 507969287352 287108873850\r\n", "output": ["997302283"]}, {"input": "6 2407012786524\r\n721119939098 908636242955 629771140630 619639275940 522572133850 990422786968\r\n", "output": ["338886284"]}, {"input": "7 1658412315976\r\n390687619668 278616376849 766721549681 733456748176 716885650745 179493438565 887893058525\r\n", "output": ["227709251"]}, {"input": "8 3813157100184\r\n94962592398 646449027095 903671958732 847274220411 915494134937 336004281651 958773586686 419294404968\r\n", "output": ["789858236"]}, {"input": "9 3583740972033\r\n805680016072 12134193693 38474884135 958944208999 114102619129 486072673792 990651855390 976802100017 464520935171\r\n", "output": ["411195526"]}, {"input": "10 1303630103199\r\n335013516244 958354148440 976543431084 565663694920 818191244892 247036352979 903603155051 844331675449 5958875397 633112048156\r\n", "output": ["130003736"]}, {"input": "11 3413722756227\r\n41435972622 328334282334 113493840135 681628650803 53654504892 397104745120 937628907403 397544403202 978080140924 138793325393 275583919363\r\n", "output": ["481042457"]}, {"input": "12 3950166899748\r\n752153396296 698314416228 246149281890 795446123039 250115505435 549320620909 4214468268 918197322444 952348890098 685624345734 963610131910 998304966486\r\n", "output": ["704755232"]}, {"input": "13 3231756157805\r\n456428369026 63999582826 385247174589 909263595275 444429022331 701536496698 38240220621 473557533845 887615379817 195600590268 694933571209 105486312375 699514624098\r\n", "output": ["21927593"]}, {"input": "14 5118792034176\r\n162850825404 433979716719 522197583640 20933583863 643037506523 851604888839 104825781485 989915485791 859736645343 740284126961 419814559564 214815141912 468744648539 228783909097\r\n", "output": ["80223119"]}, {"input": "15 1558494741523\r\n871420765430 803959850613 654853025395 134751056099 837351023419 8115731924 136704050190 545275697192 831857910870 250260371494 109988255759 324143971449 270534481491 203417577675 71520651905\r\n", "output": ["674766437"]}, {"input": "16 788453604753\r\n577843221808 167497533563 791803434447 283275820494 72814283419 158184124065 203289611054 98488424946 799684209100 792796424539 834869244114 427030350042 39764505931 217053505710 484435378338 862395026264\r\n", "output": ["652797798"]}, {"input": "17 9007952448244\r\n282118194538 537477667457 930901327146 397093292730 264980316667 347254775663 237315363407 616993860539 771805474627 339627444880 525042940309 536359179580 804699563076 230689433744 897350104771 814486287026 524910356697\r\n", "output": ["31329302"]}, {"input": "18 7999930929823\r\n992835618212 907457801350 63556768901 515205732262 463588800858 499470651452 303900924272 170206588293 707071964345 849603689414 249923928664 643540525469 608636879676 207470585970 342824639716 768725031437 470251089472 346311861570\r\n", "output": ["648904203"]}, {"input": "19 9705775952949\r\n662403298782 277437935244 200507177952 626875720850 657902317754 649539043593 337926676624 688712023886 679193229872 394287226107 940097624859 752869355006 377866904116 218959030357 755739366148 759818551656 454594081704 739525703426 242214895448\r\n", "output": ["810780885"]}, {"input": "2 412849959951\r\n186777869134 354554126688\r\n", "output": ["482034976"]}, {"input": "3 994437863260\r\n596847635049 634289413919 671297779787\r\n", "output": ["912049453"]}, {"input": "4 484402508263\r\n19064884611 335165127717 322359010582 281374567239\r\n", "output": ["289015253"]}, {"input": "5 791953923546\r\n435577101470 614900414949 563017233052 356648566543 441001524035\r\n", "output": ["173305014"]}, {"input": "6 2640586287988\r\n845646867385 315776128746 214078463847 838768025119 708835459344 934321520813\r\n", "output": ["795903668"]}, {"input": "7 2053179920110\r\n674709576219 593363932330 454736686317 330887483693 391367370275 279198145307 147889917494\r\n", "output": ["893383692"]}, {"input": "8 439869733705\r\n96926825781 294239646128 105797917112 808711974973 661348789232 209376794178 892923476071 68560519128\r\n", "output": ["158940804"]}, {"input": "9 1291213158274\r\n506996591696 573974933359 753301598853 302978917195 348175667460 544253418672 652252001943 837793929669 992753968527\r\n", "output": ["115213603"]}, {"input": "10 957014537036\r\n817957214028 21216064562 782979338116 99716780532 466634308294 252843354854 653225805495 197215781879 450502843918 936581467941\r\n", "output": ["339756041"]}, {"input": "11 2523835918230\r\n238026979942 300951351794 27195109640 583983722756 153461186521 589867462996 410406847719 383294651690 434136016355 239499156985 605005205631\r\n", "output": ["410668022"]}, {"input": "12 237485322803\r\n654539196801 989679581945 674698791381 76103181330 828140581102 517898628219 165440406295 160380578581 10923729522 532416846030 869246361010 697649464752\r\n", "output": ["882287279"]}, {"input": "13 3269153679576\r\n76756446363 279414869175 913209530202 553927672610 103827032762 854922736361 505775989249 925319021826 982409418312 237885027049 548185492012 981990500354 816927519686\r\n", "output": ["771986243"]}, {"input": "14 3533400720920\r\n486826212278 970290582974 566418244646 46047131184 780653910990 782953901584 265104515121 121397891635 966042590749 530802716094 816721614687 274184052307 410140678523 769875336369\r\n", "output": ["641684934"]}, {"input": "15 2774417264718\r\n899043461842 260025870205 221774442737 121321130489 60635329946 132125493373 24433040993 886336334879 945380795890 823720405139 90962770066 149532144989 995501321008 824453862177 210161921008\r\n", "output": ["36123304"]}, {"input": "16 6819891369867\r\n321260711404 950901584003 458137697911 603440589064 737462208174 469149601515 771614083218 82415204689 522168509057 535631037101 355203925446 429578213295 590861963493 295877847255 313625384311 583033522628\r\n", "output": ["348393153"]}, {"input": "17 2309534620849\r\n148175936589 240636871234 113493896003 95560047639 15296143483 397180766738 530942609090 847353647933 503654197846 828548726146 36290540095 711771765248 184075122329 350456373063 419236331263 152256813920 755146994664\r\n", "output": ["379054730"]}, {"input": "18 1950920788528\r\n560393186152 931512585032 349857151176 577679506214 687828054415 734204874881 285976167666 626587058472 487287370283 127171447894 300531695475 996112800850 765140797519 400739931575 522699794566 124030597188 562898195459 475763385703\r\n", "output": ["698191096"]}, {"input": "19 4682267377407\r\n970462952067 221247872263 995213349269 65503997493 957809473372 662236040104 43157209890 812665928283 64075083449 420089136939 564772850855 288306352803 360501440003 860016433006 626163257870 93656896807 955951420632 637845969941 165819589855\r\n", "output": ["523191343"]}, {"input": "20 14017821532816\r\n1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000\r\n", "output": ["347848142"]}, {"input": "20 16335271760241\r\n1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000\r\n", "output": ["395113180"]}, {"input": "20 18060579396941\r\n1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000\r\n", "output": ["668178260"]}, {"input": "20 10137806992108\r\n1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000\r\n", "output": ["357383650"]}, {"input": "20 17054536210144\r\n1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000\r\n", "output": ["517516660"]}, {"input": "20 14387278835382\r\n1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000\r\n", "output": ["467238355"]}, {"input": "20 10472667171608\r\n1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000\r\n", "output": ["868395358"]}, {"input": "20 9876740295167\r\n1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000\r\n", "output": ["125737184"]}, {"input": "20 9502335428550\r\n1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000\r\n", "output": ["209415674"]}, {"input": "20 16899776686559\r\n1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000\r\n", "output": ["212580649"]}, {"input": "1 1\r\n0\r\n", "output": ["0"]}, {"input": "20 10043\r\n2 8 26 80 242 728 2186 6560 19682 59048 177146 531440 1594322 4782968 14348906 43046720 129140162 387420488 1162261466 3486784400\r\n", "output": ["52142433"]}, {"input": "1 0\r\n1\r\n", "output": ["1"]}, {"input": "17 953674316167\r\n4 24 124 624 3124 15624 78124 390624 1953124 9765624 48828124 244140624 1220703124 6103515624 30517578124 152587890624 762939453124\r\n", "output": ["197405646"]}, {"input": "17 953674314899\r\n4 24 124 624 3124 15624 78124 390624 1953124 9765624 48828124 244140624 1220703124 6103515624 30517578124 152587890624 762939453124\r\n", "output": ["307042369"]}, {"input": "17 953674312906\r\n4 24 124 624 3124 15624 78124 390624 1953124 9765624 48828124 244140624 1220703124 6103515624 30517578124 152587890624 762939453124\r\n", "output": ["81725967"]}, {"input": "20 33554432\r\n0 1 3 7 15 31 63 127 255 511 1023 2047 4095 8191 16383 32767 65535 131071 262143 524287\r\n", "output": ["0"]}, {"input": "20 1048554\r\n0 1 3 7 15 31 63 127 255 511 1023 2047 4095 8191 16383 32767 65535 131071 262143 524287\r\n", "output": ["19"]}, {"input": "20 1048455\r\n0 1 3 7 15 31 63 127 255 511 1023 2047 4095 8191 16383 32767 65535 131071 262143 524287\r\n", "output": ["461657829"]}, {"input": "20 1038555\r\n0 1 3 7 15 31 63 127 255 511 1023 2047 4095 8191 16383 32767 65535 131071 262143 524287\r\n", "output": ["216743080"]}, {"input": "20 64741\r\n0 1 3 7 15 31 63 127 255 511 1023 2047 4095 8191 16383 32767 65535 131071 262143 524287\r\n", "output": ["181890008"]}, {"input": "20 125618\r\n1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288\r\n", "output": ["435524008"]}] | 100 | 100 | 100 | [{'input': '20 17054536210144\r\n1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000\r\n', 'output': ['517516660']}, {'input': '20 1048455\r\n0 1 3 7 15 31 63 127 255 511 1023 2047 4095 8191 16383 32767 65535 131071 262143 524287\r\n', 'output': ['461657829']}, {'input': '16 788453604753\r\n577843221808 167497533563 791803434447 283275820494 72814283419 158184124065 203289611054 98488424946 799684209100 792796424539 834869244114 427030350042 39764505931 217053505710 484435378338 862395026264\r\n', 'output': ['652797798']}, {'input': '17 9007952448244\r\n282118194538 537477667457 930901327146 397093292730 264980316667 347254775663 237315363407 616993860539 771805474627 339627444880 525042940309 536359179580 804699563076 230689433744 897350104771 814486287026 524910356697\r\n', 'output': ['31329302']}, {'input': '9 3583740972033\r\n805680016072 12134193693 38474884135 958944208999 114102619129 486072673792 990651855390 976802100017 464520935171\r\n', 'output': ['411195526']}] | [{'input': '17 2309534620849\r\n148175936589 240636871234 113493896003 95560047639 15296143483 397180766738 530942609090 847353647933 503654197846 828548726146 36290540095 711771765248 184075122329 350456373063 419236331263 152256813920 755146994664\r\n', 'output': ['379054730']}, {'input': '17 9007952448244\r\n282118194538 537477667457 930901327146 397093292730 264980316667 347254775663 237315363407 616993860539 771805474627 339627444880 525042940309 536359179580 804699563076 230689433744 897350104771 814486287026 524910356697\r\n', 'output': ['31329302']}, {'input': '13 3269153679576\r\n76756446363 279414869175 913209530202 553927672610 103827032762 854922736361 505775989249 925319021826 982409418312 237885027049 548185492012 981990500354 816927519686\r\n', 'output': ['771986243']}, {'input': '5 1199105497223\r\n12549999072 542951076358 494968215227 507969287352 287108873850\r\n', 'output': ['997302283']}, {'input': '8 3813157100184\r\n94962592398 646449027095 903671958732 847274220411 915494134937 336004281651 958773586686 419294404968\r\n', 'output': ['789858236']}] | [{'input': '20 1048455\r\n0 1 3 7 15 31 63 127 255 511 1023 2047 4095 8191 16383 32767 65535 131071 262143 524287\r\n', 'output': ['461657829']}, {'input': '2 270030023747\r\n891135146290 437305641972\r\n', 'output': ['30021858']}, {'input': '7 2053179920110\r\n674709576219 593363932330 454736686317 330887483693 391367370275 279198145307 147889917494\r\n', 'output': ['893383692']}, {'input': '9 1291213158274\r\n506996591696 573974933359 753301598853 302978917195 348175667460 544253418672 652252001943 837793929669 992753968527\r\n', 'output': ['115213603']}, {'input': '18 7999930929823\r\n992835618212 907457801350 63556768901 515205732262 463588800858 499470651452 303900924272 170206588293 707071964345 849603689414 249923928664 643540525469 608636879676 207470585970 342824639716 768725031437 470251089472 346311861570\r\n', 'output': ['648904203']}] | [{'input': '3 5\r\n1 3 2\r\n', 'output': ['3']}, {'input': '3 850878851187\r\n599705086316 802990808570 221067397125\r\n', 'output': ['334902111']}, {'input': '6 2640586287988\r\n845646867385 315776128746 214078463847 838768025119 708835459344 934321520813\r\n', 'output': ['795903668']}, {'input': '20 14017821532816\r\n1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000\r\n', 'output': ['347848142']}, {'input': '20 1048455\r\n0 1 3 7 15 31 63 127 255 511 1023 2047 4095 8191 16383 32767 65535 131071 262143 524287\r\n', 'output': ['461657829']}] | [{'input': '17 2309534620849\r\n148175936589 240636871234 113493896003 95560047639 15296143483 397180766738 530942609090 847353647933 503654197846 828548726146 36290540095 711771765248 184075122329 350456373063 419236331263 152256813920 755146994664\r\n', 'output': ['379054730']}, {'input': '5 1199105497223\r\n12549999072 542951076358 494968215227 507969287352 287108873850\r\n', 'output': ['997302283']}, {'input': '17 953674312906\r\n4 24 124 624 3124 15624 78124 390624 1953124 9765624 48828124 244140624 1220703124 6103515624 30517578124 152587890624 762939453124\r\n', 'output': ['81725967']}, {'input': '17 953674314899\r\n4 24 124 624 3124 15624 78124 390624 1953124 9765624 48828124 244140624 1220703124 6103515624 30517578124 152587890624 762939453124\r\n', 'output': ['307042369']}, {'input': '10 1303630103199\r\n335013516244 958354148440 976543431084 565663694920 818191244892 247036352979 903603155051 844331675449 5958875397 633112048156\r\n', 'output': ['130003736']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 96.15 | 100 | 100 | 96.15 | 60 | 100 | 100 | 98.46 |
["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 <stdio.h>
#include <limits.h>
int main(void){
long long int m, b;
scanf("%lld%lld", &m, &b);
long long int i;
long long int max = INT_MIN;
for(i=b; i>=0; i--){
long long int x = (b-i)*m;
long long int w = x*(x+1)/2;
long long int p = i*(i+1)/2;
long long int val = w*(i+1)+p*(x+1);
if(val > max){
max = val;
}
}
printf("%lld\n", max);
return 0;
} | ["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': '515 1563\r\n', 'output': ['75233740231341']}, {'input': '918 7704\r\n', 'output': ['28569727339126165']}, {'input': '446 5030\r\n', 'output': ['1878390629993745']}, {'input': '945 2563\r\n', 'output': ['1115613396515835']}, {'input': '494 6155\r\n', 'output': ['4221391613846823']}] | [{'input': '515 1563\r\n', 'output': ['75233740231341']}, {'input': '4 6\r\n', 'output': ['459']}, {'input': '259 770\r\n', 'output': ['2281741798549']}, {'input': '555 3594\r\n', 'output': ['1061060598862891']}, {'input': '387 5422\r\n', 'output': ['1771610559998400']}] | [{'input': '393 4874\r\n', 'output': ['1327174123029975']}, {'input': '1 1\r\n', 'output': ['1']}, {'input': '417 1045\r\n', 'output': ['14758909519725']}, {'input': '539 9221\r\n', 'output': ['16893595018603386']}, {'input': '70 7311\r\n', 'output': ['142915220249910']}] | [{'input': '1000 10000\r\n', 'output': ['74133360011484445']}, {'input': '10 1\r\n', 'output': ['55']}, {'input': '2 3\r\n', 'output': ['25']}, {'input': '894 4637\r\n', 'output': ['5909849585253250']}, {'input': '539 9221\r\n', 'output': ['16893595018603386']}] | [{'input': '22 3481\r\n', 'output': ['1548544125646']}, {'input': '20 10\r\n', 'output': ['40326']}, {'input': '446 5030\r\n', 'output': ['1878390629993745']}, {'input': '841 7185\r\n', 'output': ['19452619774222875']}, {'input': '945 2563\r\n', 'output': ['1115613396515835']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 61 | 100 | 100 | 100 |
["1 1 2", "3 4 5", "4 1 1"] | The single line of the input contains three space-separated integers a, b and c (1ββ€βa,βb,βcββ€β106) β the valence numbers of the given atoms. | b3b986fddc3770fed64b878fa42ab1bc | #include<stdio.h>
#include<stdlib.h>
int main()
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
int K = (a+b-c)/2;
int K2 = (b+c-a)/2;
if(K >= 0 && K2>= 0 && a- K >=0 && 2*(K + K2 + (a - K)) == (a + b + c))
{
printf("%d %d %d\n",K,K2,a-K);
}
else
{
printf("Impossible\n");
}
return 0;
}
| ["0 1 1", "1 3 2", "Impossible"] | C | NoteThe first sample corresponds to the first figure. There are no bonds between atoms 1 and 2 in this case.The second sample corresponds to the second figure. There is one or more bonds between each pair of atoms.The third sample corresponds to the third figure. There is no solution, because an atom cannot form bonds with itself.The configuration in the fourth figure is impossible as each atom must have at least one atomic bond. | If such a molecule can be built, print three space-separated integers β the number of bonds between the 1-st and the 2-nd, the 2-nd and the 3-rd, the 3-rd and the 1-st atoms, correspondingly. If there are multiple solutions, output any of them. If there is no solution, print "Impossible" (without the quotes). | Mad scientist Mike is busy carrying out experiments in chemistry. Today he will attempt to join three atoms into one molecule.A molecule consists of atoms, with some pairs of atoms connected by atomic bonds. Each atom has a valence number β the number of bonds the atom must form with other atoms. An atom can form one or multiple bonds with any other atom, but it cannot form a bond with itself. The number of bonds of an atom in the molecule must be equal to its valence number. Mike knows valence numbers of the three atoms. Find a molecule that can be built from these atoms according to the stated rules, or determine that it is impossible. | [{"input": "1 1 2\r\n", "output": ["0 1 1"]}, {"input": "3 4 5\r\n", "output": ["1 3 2"]}, {"input": "4 1 1\r\n", "output": ["Impossible"]}, {"input": "1 1 1\r\n", "output": ["Impossible"]}, {"input": "1000000 1000000 1000000\r\n", "output": ["500000 500000 500000"]}, {"input": "3 11 8\r\n", "output": ["3 8 0"]}, {"input": "8 5 12\r\n", "output": ["Impossible"]}, {"input": "1000000 500000 1\r\n", "output": ["Impossible"]}, {"input": "1000000 500000 2\r\n", "output": ["Impossible"]}, {"input": "2 2 2\r\n", "output": ["1 1 1"]}, {"input": "3 3 3\r\n", "output": ["Impossible"]}, {"input": "4 4 4\r\n", "output": ["2 2 2"]}, {"input": "2 4 2\r\n", "output": ["2 2 0"]}, {"input": "10 5 14\r\n", "output": ["Impossible"]}, {"input": "10 5 15\r\n", "output": ["0 5 10"]}, {"input": "10 4 16\r\n", "output": ["Impossible"]}, {"input": "3 3 6\r\n", "output": ["0 3 3"]}, {"input": "9 95 90\r\n", "output": ["7 88 2"]}, {"input": "3 5 8\r\n", "output": ["0 5 3"]}, {"input": "5 8 13\r\n", "output": ["0 8 5"]}, {"input": "6 1 5\r\n", "output": ["1 0 5"]}, {"input": "59 54 56\r\n", "output": ["Impossible"]}, {"input": "246 137 940\r\n", "output": ["Impossible"]}, {"input": "7357 3578 9123\r\n", "output": ["906 2672 6451"]}, {"input": "93952 49553 83405\r\n", "output": ["30050 19503 63902"]}, {"input": "688348 726472 442198\r\n", "output": ["486311 240161 202037"]}, {"input": "602752 645534 784262\r\n", "output": ["232012 413522 370740"]}, {"input": "741349 48244 642678\r\n", "output": ["Impossible"]}, {"input": "655754 418251 468390\r\n", "output": ["Impossible"]}, {"input": "310703 820961 326806\r\n", "output": ["Impossible"]}, {"input": "1 1 3\r\n", "output": ["Impossible"]}, {"input": "5 1 4\r\n", "output": ["1 0 4"]}] | 100 | 100 | 100 | [{'input': '1000000 1000000 1000000\r\n', 'output': ['500000 500000 500000']}, {'input': '3 3 3\r\n', 'output': ['Impossible']}, {'input': '1 1 3\r\n', 'output': ['Impossible']}, {'input': '246 137 940\r\n', 'output': ['Impossible']}, {'input': '6 1 5\r\n', 'output': ['1 0 5']}] | [{'input': '5 1 4\r\n', 'output': ['1 0 4']}, {'input': '4 1 1\r\n', 'output': ['Impossible']}, {'input': '3 3 3\r\n', 'output': ['Impossible']}, {'input': '1 1 2\r\n', 'output': ['0 1 1']}, {'input': '602752 645534 784262\r\n', 'output': ['232012 413522 370740']}] | [{'input': '1000000 1000000 1000000\r\n', 'output': ['500000 500000 500000']}, {'input': '3 5 8\r\n', 'output': ['0 5 3']}, {'input': '8 5 12\r\n', 'output': ['Impossible']}, {'input': '4 4 4\r\n', 'output': ['2 2 2']}, {'input': '2 4 2\r\n', 'output': ['2 2 0']}] | [{'input': '5 1 4\r\n', 'output': ['1 0 4']}, {'input': '2 2 2\r\n', 'output': ['1 1 1']}, {'input': '4 1 1\r\n', 'output': ['Impossible']}, {'input': '8 5 12\r\n', 'output': ['Impossible']}, {'input': '3 3 3\r\n', 'output': ['Impossible']}] | [{'input': '10 5 14\r\n', 'output': ['Impossible']}, {'input': '5 8 13\r\n', 'output': ['0 8 5']}, {'input': '8 5 12\r\n', 'output': ['Impossible']}, {'input': '5 1 4\r\n', 'output': ['1 0 4']}, {'input': '310703 820961 326806\r\n', 'output': ['Impossible']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 75 | 75 | 62.5 | 75 | 75 | 62 | 100 | 100 | 72.5 |
["12\ntoosmallword", "35\nTheQuickBrownFoxJumpsOverTheLazyDog"] | The first line contains a single integer n (1ββ€βnββ€β100)Β β the number of characters in the string. The second line contains the string. The string consists only of uppercase and lowercase Latin letters. | f13eba0a0fb86e20495d218fc4ad532d | #include<stdio.h>
int main(void)
{
int i,j,n,m=0,k=0;
char a[101];
while((scanf("%d",&n))!=EOF)
{
m=0;
for(i=0;i<n;i++)
{
scanf(" %c",&a[i]);
}
for(i='a';i<='z';i++)
{
for(j=0;j<n;j++)
{
if(i==a[j]||(i-32)==a[j])
{
m=1;
}
}
if(m==1)
{
k++;
m=0;
}
}
if(k==26)
{
printf("YES\n");
}
else
{
printf("NO\n");
}
k=0;
}
return 0;
}
| ["NO", "YES"] | C | null | Output "YES", if the string is a pangram and "NO" otherwise. | A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.You are given a string consisting of lowercase and uppercase Latin letters. Check whether this string is a pangram. We say that the string contains a letter of the Latin alphabet if this letter occurs in the string in uppercase or lowercase. | [{"input": "12\r\ntoosmallword\r\n", "output": ["No", "NO", "no"]}, {"input": "35\r\nTheQuickBrownFoxJumpsOverTheLazyDog\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "1\r\na\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nqwertyuiopasdfghjklzxcvbnm\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "26\r\nABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "48\r\nthereisasyetinsufficientdataforameaningfulanswer\r\n", "output": ["No", "NO", "no"]}, {"input": "30\r\nToBeOrNotToBeThatIsTheQuestion\r\n", "output": ["No", "NO", "no"]}, {"input": "30\r\njackdawslovemybigsphinxofquarz\r\n", "output": ["No", "NO", "no"]}, {"input": "31\r\nTHEFIVEBOXINGWIZARDSJUMPQUICKLY\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "26\r\naaaaaaaaaaaaaaaaaaaaaaaaaa\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nMGJYIZDKsbhpVeNFlquRTcWoAx\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "26\r\nfWMOhAPsbIVtyUEZrGNQXDklCJ\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "26\r\nngPMVFSThiRCwLEuyOAbKxQzDJ\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "25\r\nnxYTzLFwzNolAumjgcAboyxAj\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\npRWdodGdxUESvcScPGbUoooZsC\r\n", "output": ["No", "NO", "no"]}, {"input": "66\r\nBovdMlDzTaqKllZILFVfxbLGsRnzmtVVTmqiIDTYrossLEPlmsPrkUYtWEsGHVOnFj\r\n", "output": ["No", "NO", "no"]}, {"input": "100\r\nmKtsiDRJypUieHIkvJaMFkwaKxcCIbBszZQLIyPpCDCjhNpAnYFngLjRpnKWpKWtGnwoSteeZXuFHWQxxxOpFlNeYTwKocsXuCoa\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "26\r\nEoqxUbsLjPytUHMiFnvcGWZdRK\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nvCUFRKElZOnjmXGylWQaHDiPst\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nWtrPuaHdXLKJMsnvQfgOiJZBEY\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\npGiFluRteQwkaVoPszJyNBChxM\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\ncTUpqjPmANrdbzSFhlWIoKxgVY\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nLndjgvAEuICHKxPwqYztosrmBN\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nMdaXJrCipnOZLykfqHWEStevbU\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nEjDWsVxfKTqGXRnUMOLYcIzPba\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nxKwzRMpunYaqsdfaBgJcVElTHo\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nnRYUQsTwCPLZkgshfEXvBdoiMa\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nHNCQPfJutyAlDGsvRxZWMEbIdO\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nDaHJIpvKznQcmUyWsTGObXRFDe\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nkqvAnFAiRhzlJbtyuWedXSPcOG\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nhlrvgdwsIOyjcmUZXtAKEqoBpF\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\njLfXXiMhBTcAwQVReGnpKzdsYu\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nlNMcVuwItjxRBGAekjhyDsQOzf\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nRkSwbNoYldUGtAZvpFMcxhIJFE\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nDqspXZJTuONYieKgaHLMBwfVSC\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\necOyUkqNljFHRVXtIpWabGMLDz\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nEKAvqZhBnPmVCDRlgWJfOusxYI\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\naLbgqeYchKdMrsZxIPFvTOWNjA\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nxfpBLsndiqtacOCHGmeWUjRkYz\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nXsbRKtqleZPNIVCdfUhyagAomJ\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nAmVtbrwquEthZcjKPLiyDgSoNF\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nOhvXDcwqAUmSEPRZGnjFLiKtNB\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nEKWJqCFLRmstxVBdYuinpbhaOg\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nmnbvcxxlkjhgfdsapoiuytrewq\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\naAbcdefghijklmnopqrstuvwxy\r\n", "output": ["No", "NO", "no"]}, {"input": "30\r\nABCDEFGHTYRIOPLabcdefghtyriopl\r\n", "output": ["No", "NO", "no"]}, {"input": "25\r\nabcdefghijklmnopqrstuvwxy\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nabcdefhijklmnopqrstVxyzABC\r\n", "output": ["No", "NO", "no"]}, {"input": "25\r\nqwertyuiopasdfghjklxcvbnm\r\n", "output": ["No", "NO", "no"]}, {"input": "34\r\nTheQuickBrownFoxJumpsOverTheLayDog\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nabcdefghigklmnopqrstuvwxyz\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nabcdefghijklmnopqrstuvwxyA\r\n", "output": ["No", "NO", "no"]}, {"input": "50\r\nqazwsxedcrfvtgbyhnujmikolQWERTYUIOASDFGHJKLZXCVBNM\r\n", "output": ["No", "NO", "no"]}, {"input": "35\r\nTheQuickBrownFoxJumpsOverTheLasyDog\r\n", "output": ["No", "NO", "no"]}, {"input": "25\r\nbcdefghijklmnopqrstuvwxyz\r\n", "output": ["No", "NO", "no"]}, {"input": "38\r\nAbCdEfGhIjKlMnOpQrStVwXyZzzzzzzaaaaaaa\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nabcdefghiklmnopqrstvxyzABC\r\n", "output": ["No", "NO", "no"]}, {"input": "26\r\nabcdefghijklmnopqrstuvwxzZ\r\n", "output": ["No", "NO", "no"]}, {"input": "50\r\nabcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXY\r\n", "output": ["No", "NO", "no"]}] | 100 | 100 | 100 | [{'input': '26\r\ncTUpqjPmANrdbzSFhlWIoKxgVY\r\n', 'output': ['No', 'NO', 'no']}, {'input': '30\r\nABCDEFGHTYRIOPLabcdefghtyriopl\r\n', 'output': ['No', 'NO', 'no']}, {'input': '26\r\nqwertyuiopasdfghjklzxcvbnm\r\n', 'output': ['YES', 'Yes', 'yes']}, {'input': '50\r\nabcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXY\r\n', 'output': ['No', 'NO', 'no']}, {'input': '38\r\nAbCdEfGhIjKlMnOpQrStVwXyZzzzzzzaaaaaaa\r\n', 'output': ['No', 'NO', 'no']}] | [{'input': '26\r\nEoqxUbsLjPytUHMiFnvcGWZdRK\r\n', 'output': ['No', 'NO', 'no']}, {'input': '26\r\nEKWJqCFLRmstxVBdYuinpbhaOg\r\n', 'output': ['No', 'NO', 'no']}, {'input': '26\r\nEjDWsVxfKTqGXRnUMOLYcIzPba\r\n', 'output': ['No', 'NO', 'no']}, {'input': '25\r\nqwertyuiopasdfghjklxcvbnm\r\n', 'output': ['No', 'NO', 'no']}, {'input': '38\r\nAbCdEfGhIjKlMnOpQrStVwXyZzzzzzzaaaaaaa\r\n', 'output': ['No', 'NO', 'no']}] | [{'input': '1\r\na\r\n', 'output': ['No', 'NO', 'no']}, {'input': '26\r\nnRYUQsTwCPLZkgshfEXvBdoiMa\r\n', 'output': ['No', 'NO', 'no']}, {'input': '26\r\nHNCQPfJutyAlDGsvRxZWMEbIdO\r\n', 'output': ['No', 'NO', 'no']}, {'input': '26\r\nxKwzRMpunYaqsdfaBgJcVElTHo\r\n', 'output': ['No', 'NO', 'no']}, {'input': '26\r\nhlrvgdwsIOyjcmUZXtAKEqoBpF\r\n', 'output': ['No', 'NO', 'no']}] | [{'input': '66\r\nBovdMlDzTaqKllZILFVfxbLGsRnzmtVVTmqiIDTYrossLEPlmsPrkUYtWEsGHVOnFj\r\n', 'output': ['No', 'NO', 'no']}, {'input': '26\r\nDqspXZJTuONYieKgaHLMBwfVSC\r\n', 'output': ['No', 'NO', 'no']}, {'input': '31\r\nTHEFIVEBOXINGWIZARDSJUMPQUICKLY\r\n', 'output': ['YES', 'Yes', 'yes']}, {'input': '26\r\nWtrPuaHdXLKJMsnvQfgOiJZBEY\r\n', 'output': ['No', 'NO', 'no']}, {'input': '26\r\necOyUkqNljFHRVXtIpWabGMLDz\r\n', 'output': ['No', 'NO', 'no']}] | [{'input': '25\r\nbcdefghijklmnopqrstuvwxyz\r\n', 'output': ['No', 'NO', 'no']}, {'input': '26\r\nvCUFRKElZOnjmXGylWQaHDiPst\r\n', 'output': ['No', 'NO', 'no']}, {'input': '26\r\nEoqxUbsLjPytUHMiFnvcGWZdRK\r\n', 'output': ['No', 'NO', 'no']}, {'input': '26\r\nhlrvgdwsIOyjcmUZXtAKEqoBpF\r\n', 'output': ['No', 'NO', 'no']}, {'input': '26\r\nABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n', 'output': ['YES', 'Yes', 'yes']}] | 100 | 100 | 100 | 100 | 100 | 100 | 94.44 | 94.44 | 100 | 100 | 100 | 93.75 | 93.75 | 100 | 100 | 63 | 100 | 97.776 | 97.5 |
["5 2 3", "8 2 4"] | The only line contains three integers n,βb,βp (1ββ€βn,βb,βpββ€β500) β the number of participants and the parameters described in the problem statement. | eb815f35e9f29793a120d120968cfe34 | #include<stdio.h>
int main()
{
int n,b,p,nb,np,temp,count=0,r;
scanf("%d %d %d",&n,&b,&p);
printf("%d %d",(n-1)*(2*b+1),n*p);
return 0;
}
| ["20 15", "35 32"] | C | NoteIn the first example will be three rounds: in the first round will be two matches and for each match 5 bottles of water are needed (two for each of the participants and one for the judge), in the second round will be only one match, so we need another 5 bottles of water, in the third round will also be only one match, so we need another 5 bottles of water. So in total we need 20 bottles of water.In the second example no participant will move on to some round directly. | Print two integers x and y β the number of bottles and towels need for the tournament. | A tennis tournament with n participants is running. The participants are playing by an olympic system, so the winners move on and the losers drop out.The tournament takes place in the following way (below, m is the number of the participants of the current round): let k be the maximal power of the number 2 such that kββ€βm, k participants compete in the current round and a half of them passes to the next round, the other mβ-βk participants pass to the next round directly, when only one participant remains, the tournament finishes. Each match requires b bottles of water for each participant and one bottle for the judge. Besides p towels are given to each participant for the whole tournament.Find the number of bottles and towels needed for the tournament.Note that it's a tennis tournament so in each match two participants compete (one of them will win and the other will lose). | [{"input": "5 2 3\r\n", "output": ["20\r\n15", "20 15"]}, {"input": "8 2 4\r\n", "output": ["35\r\n32", "35 32"]}, {"input": "10 1 500\r\n", "output": ["27 5000", "27\r\n5000"]}, {"input": "20 500 1\r\n", "output": ["19019\r\n20", "19019 20"]}, {"input": "100 123 99\r\n", "output": ["24453\r\n9900", "24453 9900"]}, {"input": "500 1 1\r\n", "output": ["1497 500", "1497\r\n500"]}, {"input": "500 500 500\r\n", "output": ["499499\r\n250000", "499499 250000"]}, {"input": "500 237 474\r\n", "output": ["237025 237000", "237025\r\n237000"]}, {"input": "1 2 3\r\n", "output": ["0\r\n3", "0 3"]}, {"input": "1 2 133\r\n", "output": ["0 133", "0\r\n133"]}, {"input": "1 2 100\r\n", "output": ["0 100", "0\r\n100"]}, {"input": "1 3 4\r\n", "output": ["0\r\n4", "0 4"]}, {"input": "1 10 15\r\n", "output": ["0 15", "0\r\n15"]}, {"input": "1 1 1\r\n", "output": ["0 1", "0\r\n1"]}, {"input": "1 2 5\r\n", "output": ["0 5", "0\r\n5"]}, {"input": "1 500 500\r\n", "output": ["0\r\n500", "0 500"]}, {"input": "1 3 8\r\n", "output": ["0 8", "0\r\n8"]}, {"input": "10 10 10\r\n", "output": ["189\r\n100", "189 100"]}, {"input": "1 3 5\r\n", "output": ["0 5", "0\r\n5"]}, {"input": "1 2 1\r\n", "output": ["0 1", "0\r\n1"]}, {"input": "1 2 4\r\n", "output": ["0\r\n4", "0 4"]}, {"input": "1 10 10\r\n", "output": ["0\r\n10", "0 10"]}, {"input": "1 345 345\r\n", "output": ["0 345", "0\r\n345"]}, {"input": "7 12 13\r\n", "output": ["150\r\n91", "150 91"]}, {"input": "1 500 1\r\n", "output": ["0 1", "0\r\n1"]}, {"input": "1 12 13\r\n", "output": ["0 13", "0\r\n13"]}, {"input": "1 500 499\r\n", "output": ["0\r\n499", "0 499"]}, {"input": "1 100 90\r\n", "output": ["0 90", "0\r\n90"]}, {"input": "2 100 90\r\n", "output": ["201 180", "201\r\n180"]}, {"input": "53 1 1\r\n", "output": ["156\r\n53", "156 53"]}, {"input": "73 73 73\r\n", "output": ["10584 5329", "10584\r\n5329"]}, {"input": "67 1 1\r\n", "output": ["198 67", "198\r\n67"]}, {"input": "63 1 1\r\n", "output": ["186\r\n63", "186 63"]}, {"input": "59 1 1\r\n", "output": ["174\r\n59", "174 59"]}, {"input": "57 1 1\r\n", "output": ["168 57", "168\r\n57"]}, {"input": "13 1 1\r\n", "output": ["36 13", "36\r\n13"]}, {"input": "349 2 5\r\n", "output": ["1740\r\n1745", "1740 1745"]}, {"input": "456 456 456\r\n", "output": ["415415\r\n207936", "415415 207936"]}] | 100 | 100 | 100 | [{'input': '1 100 90\r\n', 'output': ['0 90', '0\r\n90']}, {'input': '1 2 100\r\n', 'output': ['0 100', '0\r\n100']}, {'input': '1 2 3\r\n', 'output': ['0\r\n3', '0 3']}, {'input': '10 10 10\r\n', 'output': ['189\r\n100', '189 100']}, {'input': '1 345 345\r\n', 'output': ['0 345', '0\r\n345']}] | [{'input': '7 12 13\r\n', 'output': ['150\r\n91', '150 91']}, {'input': '1 500 500\r\n', 'output': ['0\r\n500', '0 500']}, {'input': '10 1 500\r\n', 'output': ['27 5000', '27\r\n5000']}, {'input': '1 2 5\r\n', 'output': ['0 5', '0\r\n5']}, {'input': '1 100 90\r\n', 'output': ['0 90', '0\r\n90']}] | [{'input': '1 345 345\r\n', 'output': ['0 345', '0\r\n345']}, {'input': '20 500 1\r\n', 'output': ['19019\r\n20', '19019 20']}, {'input': '7 12 13\r\n', 'output': ['150\r\n91', '150 91']}, {'input': '1 2 100\r\n', 'output': ['0 100', '0\r\n100']}, {'input': '1 3 4\r\n', 'output': ['0\r\n4', '0 4']}] | [{'input': '500 500 500\r\n', 'output': ['499499\r\n250000', '499499 250000']}, {'input': '5 2 3\r\n', 'output': ['20\r\n15', '20 15']}, {'input': '1 2 5\r\n', 'output': ['0 5', '0\r\n5']}, {'input': '13 1 1\r\n', 'output': ['36 13', '36\r\n13']}, {'input': '73 73 73\r\n', 'output': ['10584 5329', '10584\r\n5329']}] | [{'input': '1 2 1\r\n', 'output': ['0 1', '0\r\n1']}, {'input': '1 100 90\r\n', 'output': ['0 90', '0\r\n90']}, {'input': '59 1 1\r\n', 'output': ['174\r\n59', '174 59']}, {'input': '349 2 5\r\n', 'output': ['1740\r\n1745', '1740 1745']}, {'input': '1 500 500\r\n', 'output': ['0\r\n500', '0 500']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 64 | 100 | 100 | 100 |
["1 1 1 2", "1 2 3 1", "10 2 1 7"] | The single line contains 4 integers a,βb,βc,βl (1ββ€βa,βb,βcββ€β3Β·105, 0ββ€βlββ€β3Β·105). | 185ff90a8b0ae0e2b75605f772589410 | #include<stdio.h>
#define min(a,b) ((a<b)?a:b)
long long cal(long long a,long long b,long long c,long long la,long long l)
{
long long x,val=a-b-c+la;
if(val<=-1)
return 0;
x=min(val,l-la);
return (x+1)*(x+2)/2;
}
int main()
{
long long int i,a,b,c,l;
scanf("%lld %lld %lld %lld",&a,&b,&c,&l);
unsigned long long ans=(l+3)*(l+2)*(l+1)/6;
for(i=0;i<=l;i++)
ans-=cal(a,b,c,i,l);
for(i=0;i<=l;i++)
ans-=cal(b,a,c,i,l);
for(i=0;i<=l;i++)
ans-=cal(c,a,b,i,l);
printf("%llu\n",ans);
return 0;
}
| ["4", "2", "0"] | C | NoteIn the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter.In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions. | Print a single integer β the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it. | You are given three sticks with positive integer lengths of a,βb, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick.Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them. | [{"input": "1 1 1 2\r\n", "output": ["4"]}, {"input": "1 2 3 1\r\n", "output": ["2"]}, {"input": "10 2 1 7\r\n", "output": ["0"]}, {"input": "1 2 1 5\r\n", "output": ["20"]}, {"input": "10 15 17 10\r\n", "output": ["281"]}, {"input": "5 5 5 10000\r\n", "output": ["41841675001"]}, {"input": "5 7 30 100\r\n", "output": ["71696"]}, {"input": "5 5 5 300000\r\n", "output": ["1125157500250001"]}, {"input": "4 2 5 28\r\n", "output": ["1893"]}, {"input": "2 7 8 4\r\n", "output": ["25"]}, {"input": "85 50 17 89\r\n", "output": ["68620"]}, {"input": "17 28 19 5558\r\n", "output": ["7396315389"]}, {"input": "5276 8562 1074 8453\r\n", "output": ["49093268246"]}, {"input": "9133 7818 3682 82004\r\n", "output": ["38306048676255"]}, {"input": "81780 54799 231699 808\r\n", "output": ["0"]}, {"input": "53553 262850 271957 182759\r\n", "output": ["834977070873802"]}, {"input": "300000 300000 300000 300000\r\n", "output": ["4500090000549998"]}, {"input": "1 1 300000 300000\r\n", "output": ["599999"]}, {"input": "300000 300000 1 300000\r\n", "output": ["2250045000350001"]}, {"input": "300000 300000 1 24234\r\n", "output": ["1186319275394"]}, {"input": "1 1 1 300000\r\n", "output": ["1125022500250001"]}, {"input": "3 5 7 300000\r\n", "output": ["1125157499050009"]}, {"input": "63 5 52 78\r\n", "output": ["46502"]}, {"input": "2 42 49 93\r\n", "output": ["72542"]}, {"input": "61 100 3 8502\r\n", "output": ["27050809786"]}, {"input": "30 918 702 591\r\n", "output": ["14315560"]}, {"input": "98406 37723 3 257918\r\n", "output": ["1154347569149860"]}, {"input": "552 250082 77579 278985\r\n", "output": ["596240712378446"]}, {"input": "183808 8 8 294771\r\n", "output": ["622921327009564"]}, {"input": "2958 4133 233463 259655\r\n", "output": ["65797591388150"]}, {"input": "300000 200000 100000 1\r\n", "output": ["2"]}, {"input": "300000 200000 100000 0\r\n", "output": ["0"]}, {"input": "100000 300000 100000 100000\r\n", "output": ["0"]}, {"input": "100000 300000 100000 100001\r\n", "output": ["100002"]}, {"input": "100000 300000 100000 100002\r\n", "output": ["200005"]}, {"input": "100000 300000 100000 100003\r\n", "output": ["400012"]}, {"input": "100000 300000 100000 100010\r\n", "output": ["3000195"]}, {"input": "100000 300000 100000 100100\r\n", "output": ["255131325"]}, {"input": "100000 300000 199999 0\r\n", "output": ["0"]}, {"input": "100000 300000 200001 0\r\n", "output": ["1"]}, {"input": "3 1 29 1\r\n", "output": ["0"]}] | 100 | 100 | 100 | [{'input': '300000 300000 300000 300000\r\n', 'output': ['4500090000549998']}, {'input': '1 1 1 2\r\n', 'output': ['4']}, {'input': '552 250082 77579 278985\r\n', 'output': ['596240712378446']}, {'input': '300000 200000 100000 1\r\n', 'output': ['2']}, {'input': '5 7 30 100\r\n', 'output': ['71696']}] | [{'input': '100000 300000 199999 0\r\n', 'output': ['0']}, {'input': '98406 37723 3 257918\r\n', 'output': ['1154347569149860']}, {'input': '63 5 52 78\r\n', 'output': ['46502']}, {'input': '1 1 300000 300000\r\n', 'output': ['599999']}, {'input': '30 918 702 591\r\n', 'output': ['14315560']}] | [{'input': '1 2 1 5\r\n', 'output': ['20']}, {'input': '63 5 52 78\r\n', 'output': ['46502']}, {'input': '1 1 300000 300000\r\n', 'output': ['599999']}, {'input': '30 918 702 591\r\n', 'output': ['14315560']}, {'input': '1 2 3 1\r\n', 'output': ['2']}] | [{'input': '2 42 49 93\r\n', 'output': ['72542']}, {'input': '2 7 8 4\r\n', 'output': ['25']}, {'input': '81780 54799 231699 808\r\n', 'output': ['0']}, {'input': '61 100 3 8502\r\n', 'output': ['27050809786']}, {'input': '300000 300000 1 24234\r\n', 'output': ['1186319275394']}] | [{'input': '61 100 3 8502\r\n', 'output': ['27050809786']}, {'input': '300000 200000 100000 1\r\n', 'output': ['2']}, {'input': '5 7 30 100\r\n', 'output': ['71696']}, {'input': '1 2 3 1\r\n', 'output': ['2']}, {'input': '30 918 702 591\r\n', 'output': ['14315560']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 65 | 100 | 100 | 100 |
["4 1", "4 2", "4 3", "4 0"] | The only line contains two integers n,βk (1ββ€βnββ€β109,β0ββ€βkββ€β106). | 6f6fc42a367cdce60d76fd1914e73f0c | #include <stdio.h>
#define M 1000000007
int n,k,i,c,d;
long long y,z,u,v,r;
int F(int a,int b){
int r=1;
for (;b;b>>=1,a=(long long)a*a%M){
if (b&1)r=(long long)r*a%M;
}
return r;
}
int main(){
scanf("%d%d",&n,&k);
if (!k)r=n;
else{
if (n<=++k){for(i=1;i<=n;i++)r+=F(i,k-1);}
else{
for (u=v=1;i<=k;i++){u=(u*(n-i))%M;if (i)v=((v*-i)%M+M)%M;}
for (i=0,c=1,d=k;i<=k;i++,c++,d--){
z=(z+F(i,k-1))%M;
y=u*z%M*F(n-i,M-2)%M*F(v,M-2)%M;
v=v*c%M*F(d,M-2)%M;
if(i&1)y=M-y;
r+=y;
}
}
}
printf("%lld\n",r%M);
}
| ["10", "30", "100", "4"] | C | null | Print the only integer a β the remainder after dividing the value of the sum by the value 109β+β7. | There are well-known formulas: , , . Also mathematicians found similar formulas for higher degrees.Find the value of the sum modulo 109β+β7 (so you should find the remainder after dividing the answer by the value 109β+β7). | [{"input": "4 1\r\n", "output": ["10"]}, {"input": "4 2\r\n", "output": ["30"]}, {"input": "4 3\r\n", "output": ["100"]}, {"input": "4 0\r\n", "output": ["4"]}, {"input": "10 0\r\n", "output": ["10"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "1 0\r\n", "output": ["1"]}, {"input": "1 1000000\r\n", "output": ["1"]}, {"input": "1000000000 0\r\n", "output": ["1000000000"]}, {"input": "100 100\r\n", "output": ["568830579"]}, {"input": "10000 100\r\n", "output": ["352711099"]}, {"input": "100 10000\r\n", "output": ["859998022"]}, {"input": "1000000000 1000000\r\n", "output": ["617381606"]}, {"input": "1000000 1000000\r\n", "output": ["997878755"]}, {"input": "999999 1000000\r\n", "output": ["504760730"]}, {"input": "77674473 447444\r\n", "output": ["838207299"]}, {"input": "333312494 795258\r\n", "output": ["393290476"]}, {"input": "761637147 673329\r\n", "output": ["223778667"]}, {"input": "335185991 514401\r\n", "output": ["412595240"]}, {"input": "203702132 355473\r\n", "output": ["229710810"]}, {"input": "1000000000 999935\r\n", "output": ["729344740"]}] | 100 | 100 | 100 | [{'input': '1 1000000\r\n', 'output': ['1']}, {'input': '100 10000\r\n', 'output': ['859998022']}, {'input': '10 0\r\n', 'output': ['10']}, {'input': '4 0\r\n', 'output': ['4']}, {'input': '203702132 355473\r\n', 'output': ['229710810']}] | [{'input': '1000000000 999935\r\n', 'output': ['729344740']}, {'input': '4 3\r\n', 'output': ['100']}, {'input': '333312494 795258\r\n', 'output': ['393290476']}, {'input': '1 1000000\r\n', 'output': ['1']}, {'input': '4 1\r\n', 'output': ['10']}] | [{'input': '4 2\r\n', 'output': ['30']}, {'input': '761637147 673329\r\n', 'output': ['223778667']}, {'input': '1000000000 999935\r\n', 'output': ['729344740']}, {'input': '4 3\r\n', 'output': ['100']}, {'input': '10 0\r\n', 'output': ['10']}] | [{'input': '761637147 673329\r\n', 'output': ['223778667']}, {'input': '1 0\r\n', 'output': ['1']}, {'input': '1000000000 999935\r\n', 'output': ['729344740']}, {'input': '77674473 447444\r\n', 'output': ['838207299']}, {'input': '4 1\r\n', 'output': ['10']}] | [{'input': '100 100\r\n', 'output': ['568830579']}, {'input': '1000000000 1000000\r\n', 'output': ['617381606']}, {'input': '4 2\r\n', 'output': ['30']}, {'input': '203702132 355473\r\n', 'output': ['229710810']}, {'input': '100 10000\r\n', 'output': ['859998022']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 94.44 | 100 | 83.33 | 94.44 | 66 | 100 | 100 | 94.442 |
["4 5\n2 3 1 4 4", "3 3\n3 1 2"] | The first line contains two integer numbers n, m (1ββ€βn,βmββ€β100). The second line contains m integer numbers l1,βl2,β...,βlm (1ββ€βliββ€βn) β indices of leaders in the beginning of each step. | 4a7c959ca279d0a9bd9bbf0ce88cf72b | #include<stdio.h>
int arr[101],no[101],l[100];
int main()
{
int n,m,source,desti,temp,flag,k,i;
scanf("%d %d",&n,&m);
for(i=0;i<m;i++)
scanf("%d",&l[i]);
for(i=0;i<=n;i++)
{
arr[i]=0;
no[i]=0;
}
flag=0;
for(i=0;i<(m-1);i++)
{
source=l[i];
desti=l[i+1];
if(desti<=source)
desti=desti+n;
temp=desti-source;
if(arr[l[i]]==0)
{
if(no[temp]==1)
{
flag=1;
break;
}
else
{
arr[l[i]]=temp;
no[temp]=1;
}
}
else if(arr[l[i]]==temp);
else
{
flag=1;
break;
}
}
k=1;
if(flag==1)
printf("-1");
else
{
for(i=1;i<=n;i++)
{
if(arr[i]==0)
{
while(no[k]==1)
k++;
arr[i]=k;
no[k]=1;
k++;
}
}
for(i=1;i<=n;i++)
printf("%d ",arr[i]);
}
return 0;
}
| ["3 1 2 4", "-1"] | C | NoteLet's follow leadership in the first example: Child 2 starts. Leadership goes from 2 to 2β+βa2β=β3. Leadership goes from 3 to 3β+βa3β=β5. As it's greater than 4, it's going in a circle to 1. Leadership goes from 1 to 1β+βa1β=β4. Leadership goes from 4 to 4β+βa4β=β8. Thus in circle it still remains at 4. | Print such permutation of n numbers a1,βa2,β...,βan that leaders in the game will be exactly l1,βl2,β...,βlm if all the rules are followed. If there are multiple solutions print any of them. If there is no permutation which satisfies all described conditions print -1. | n children are standing in a circle and playing a game. Children's numbers in clockwise order form a permutation a1,βa2,β...,βan of length n. It is an integer sequence such that each integer from 1 to n appears exactly once in it.The game consists of m steps. On each step the current leader with index i counts out ai people in clockwise order, starting from the next person. The last one to be pointed at by the leader becomes the new leader.You are given numbers l1,βl2,β...,βlm β indices of leaders in the beginning of each step. Child with number l1 is the first leader in the game. Write a program which will restore a possible permutation a1,βa2,β...,βan. If there are multiple solutions then print any of them. If there is no solution then print -1. | [{"input": "4 5\r\n2 3 1 4 4\r\n", "output": ["3 1 2 4"]}, {"input": "3 3\r\n3 1 2\r\n", "output": ["-1"]}, {"input": "1 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": ["1"]}, {"input": "6 8\r\n2 5 4 2 5 4 2 5\r\n", "output": ["1 3 2 4 5 6"]}, {"input": "100 1\r\n6\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 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"]}, {"input": "10 5\r\n7 7 9 9 3\r\n", "output": ["-1"]}, {"input": "10 20\r\n10 1 5 7 1 2 5 3 6 3 9 4 3 4 9 6 8 4 9 6\r\n", "output": ["-1"]}, {"input": "20 15\r\n11 19 1 8 17 12 3 1 8 17 12 3 1 8 17\r\n", "output": ["7 1 18 3 4 5 6 9 10 12 8 11 13 14 16 17 15 19 2 20"]}, {"input": "100 100\r\n96 73 23 74 35 44 75 13 62 50 76 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63\r\n", "output": ["1 2 3 4 5 6 7 8 10 11 12 13 49 14 15 17 18 19 20 21 22 23 51 39 24 25 27 28 16 29 30 32 33 34 9 35 36 37 40 41 42 43 44 31 79 45 46 47 48 26 52 53 54 55 56 57 58 59 60 62 63 88 66 64 65 67 68 69 70 71 72 73 50 61 38 87 74 75 76 78 80 81 82 83 84 85 86 89 90 91 92 93 94 95 96 77 97 98 99 100"]}, {"input": "100 100\r\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 71 45 97 71 14 76 54 81 4 59 46 39 29 92 3 49 22 53 99 59 52 74 31 92 43 42 23 44 9 82 47 7 40 12 9 3 55 37 85 46 22 84 52 98 41 21 77 63 17 62 91\r\n", "output": ["-1"]}, {"input": "20 20\r\n1 20 2 19 3 18 4 17 5 16 6 15 7 14 8 13 9 12 10 11\r\n", "output": ["19 17 15 13 11 9 7 5 3 1 20 18 16 14 12 10 8 6 4 2"]}, {"input": "20 5\r\n1 20 2 19 3\r\n", "output": ["19 17 1 3 5 6 7 8 9 10 11 12 13 14 15 16 18 20 4 2"]}, {"input": "19 19\r\n1 19 2 18 3 17 4 16 5 15 6 14 7 13 8 12 9 11 10\r\n", "output": ["-1"]}, {"input": "100 100\r\n1 99 2 98 3 97 4 96 5 95 6 94 7 93 8 92 9 91 10 90 11 89 12 88 13 87 14 86 15 85 16 84 17 83 18 82 19 81 20 80 21 79 22 78 23 77 24 76 25 75 26 74 27 73 28 72 29 71 30 70 31 69 32 68 33 67 34 66 35 65 36 64 37 63 38 62 39 61 40 60 41 59 42 58 43 57 44 56 45 55 46 54 47 53 48 52 49 51 50 50\r\n", "output": ["98 96 94 92 90 88 86 84 82 80 78 76 74 72 70 68 66 64 62 60 58 56 54 52 50 48 46 44 42 40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2 100 99 97 95 93 91 89 87 85 83 81 79 77 75 73 71 69 67 65 63 61 59 57 55 53 51 49 47 45 43 41 39 37 35 33 31 29 27 25 23 21 19 17 15 13 11 9 7 5 3 1"]}, {"input": "51 18\r\n8 32 24 19 1 29 49 24 39 33 5 37 37 26 17 28 2 19\r\n", "output": ["-1"]}, {"input": "5 5\r\n1 2 5 2 4\r\n", "output": ["-1"]}, {"input": "6 6\r\n1 2 1 1 3 6\r\n", "output": ["-1"]}, {"input": "4 4\r\n4 3 4 2\r\n", "output": ["-1"]}, {"input": "3 3\r\n2 2 3\r\n", "output": ["-1"]}, {"input": "4 6\r\n1 1 2 4 4 4\r\n", "output": ["-1"]}, {"input": "9 4\r\n8 2 8 3\r\n", "output": ["-1"]}, {"input": "4 6\r\n2 3 1 4 4 1\r\n", "output": ["-1"]}, {"input": "2 3\r\n1 1 2\r\n", "output": ["-1"]}, {"input": "5 7\r\n4 3 4 3 3 4 5\r\n", "output": ["-1"]}, {"input": "2 9\r\n1 1 1 1 2 1 1 1 1\r\n", "output": ["-1"]}, {"input": "4 4\r\n2 4 4 4\r\n", "output": ["1 2 3 4"]}, {"input": "3 3\r\n1 1 3\r\n", "output": ["-1"]}, {"input": "2 5\r\n1 2 2 1 1\r\n", "output": ["-1"]}, {"input": "4 4\r\n1 4 1 3\r\n", "output": ["-1"]}, {"input": "3 4\r\n1 3 1 1\r\n", "output": ["-1"]}, {"input": "4 4\r\n1 4 1 1\r\n", "output": ["-1"]}, {"input": "66 67\r\n19 9 60 40 19 48 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5\r\n", "output": ["-1"]}, {"input": "3 3\r\n3 3 2\r\n", "output": ["-1"]}, {"input": "27 28\r\n8 18 27 24 20 8 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23\r\n", "output": ["-1"]}, {"input": "4 3\r\n1 1 2\r\n", "output": ["-1"]}, {"input": "4 4\r\n2 4 2 3\r\n", "output": ["-1"]}, {"input": "2 3\r\n2 2 1\r\n", "output": ["-1"]}, {"input": "2 2\r\n2 2\r\n", "output": ["1 2"]}, {"input": "3 4\r\n2 3 3 1\r\n", "output": ["-1"]}, {"input": "5 6\r\n1 4 4 2 1 4\r\n", "output": ["-1"]}, {"input": "4 3\r\n2 3 4\r\n", "output": ["-1"]}, {"input": "2 3\r\n1 2 1\r\n", "output": ["-1"]}, {"input": "10 4\r\n5 6 5 7\r\n", "output": ["-1"]}, {"input": "3 3\r\n1 1 2\r\n", "output": ["-1"]}, {"input": "4 5\r\n1 4 1 3 2\r\n", "output": ["-1"]}, {"input": "6 5\r\n1 2 4 1 3\r\n", "output": ["-1"]}] | 100 | 100 | 100 | [{'input': '3 3\r\n1 1 3\r\n', 'output': ['-1']}, {'input': '9 4\r\n8 2 8 3\r\n', 'output': ['-1']}, {'input': '100 100\r\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 71 45 97 71 14 76 54 81 4 59 46 39 29 92 3 49 22 53 99 59 52 74 31 92 43 42 23 44 9 82 47 7 40 12 9 3 55 37 85 46 22 84 52 98 41 21 77 63 17 62 91\r\n', 'output': ['-1']}, {'input': '1 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': ['1']}, {'input': '3 3\r\n1 1 2\r\n', 'output': ['-1']}] | [{'input': '6 6\r\n1 2 1 1 3 6\r\n', 'output': ['-1']}, {'input': '4 4\r\n1 4 1 1\r\n', 'output': ['-1']}, {'input': '6 8\r\n2 5 4 2 5 4 2 5\r\n', 'output': ['1 3 2 4 5 6']}, {'input': '5 7\r\n4 3 4 3 3 4 5\r\n', 'output': ['-1']}, {'input': '10 4\r\n5 6 5 7\r\n', 'output': ['-1']}] | [{'input': '4 4\r\n2 4 2 3\r\n', 'output': ['-1']}, {'input': '66 67\r\n19 9 60 40 19 48 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5\r\n', 'output': ['-1']}, {'input': '100 100\r\n1 99 2 98 3 97 4 96 5 95 6 94 7 93 8 92 9 91 10 90 11 89 12 88 13 87 14 86 15 85 16 84 17 83 18 82 19 81 20 80 21 79 22 78 23 77 24 76 25 75 26 74 27 73 28 72 29 71 30 70 31 69 32 68 33 67 34 66 35 65 36 64 37 63 38 62 39 61 40 60 41 59 42 58 43 57 44 56 45 55 46 54 47 53 48 52 49 51 50 50\r\n', 'output': ['98 96 94 92 90 88 86 84 82 80 78 76 74 72 70 68 66 64 62 60 58 56 54 52 50 48 46 44 42 40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2 100 99 97 95 93 91 89 87 85 83 81 79 77 75 73 71 69 67 65 63 61 59 57 55 53 51 49 47 45 43 41 39 37 35 33 31 29 27 25 23 21 19 17 15 13 11 9 7 5 3 1']}, {'input': '100 1\r\n6\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 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']}, {'input': '9 4\r\n8 2 8 3\r\n', 'output': ['-1']}] | [{'input': '2 5\r\n1 2 2 1 1\r\n', 'output': ['-1']}, {'input': '4 3\r\n1 1 2\r\n', 'output': ['-1']}, {'input': '2 2\r\n2 2\r\n', 'output': ['1 2']}, {'input': '66 67\r\n19 9 60 40 19 48 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5\r\n', 'output': ['-1']}, {'input': '4 6\r\n1 1 2 4 4 4\r\n', 'output': ['-1']}] | [{'input': '100 100\r\n96 73 23 74 35 44 75 13 62 50 76 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63\r\n', 'output': ['1 2 3 4 5 6 7 8 10 11 12 13 49 14 15 17 18 19 20 21 22 23 51 39 24 25 27 28 16 29 30 32 33 34 9 35 36 37 40 41 42 43 44 31 79 45 46 47 48 26 52 53 54 55 56 57 58 59 60 62 63 88 66 64 65 67 68 69 70 71 72 73 50 61 38 87 74 75 76 78 80 81 82 83 84 85 86 89 90 91 92 93 94 95 96 77 97 98 99 100']}, {'input': '6 5\r\n1 2 4 1 3\r\n', 'output': ['-1']}, {'input': '5 7\r\n4 3 4 3 3 4 5\r\n', 'output': ['-1']}, {'input': '3 4\r\n1 3 1 1\r\n', 'output': ['-1']}, {'input': '10 5\r\n7 7 9 9 3\r\n', 'output': ['-1']}] | 100 | 100 | 100 | 100 | 100 | 80.56 | 94.44 | 97.22 | 91.67 | 94.44 | 83.33 | 95.83 | 91.67 | 87.5 | 95.83 | 67 | 100 | 91.666 | 90.832 |
["5\n1 1 1 1 2 2 3 2 2 1 1 1", "0\n0 0 0 0 0 0 0 1 1 2 3 0", "11\n1 1 4 1 1 5 1 1 4 1 1 1"] | The first line contains exactly one integer k (0ββ€βkββ€β100). The next line contains twelve space-separated integers: the i-th (1ββ€βiββ€β12) number in the line represents ai (0ββ€βaiββ€β100). | 59dfa7a4988375febc5dccc27aca90a8 | #include<stdio.h>
#include<stdlib.h>
int compare(const void *a,const void *b)
{
return ( *(int*)a - *(int *)b );
}
int main()
{
int n,i,s=0,p=0,j=0;
scanf("%d",&n);
int a[12];
for(i=0;i<12;i++)
scanf("%d",&a[i]);
qsort(a,12,sizeof(int),compare);
if(n!=0)
{ for(i=11;i>=0;i--)
{
s=s+a[i];
if(s<n)
p++;
else
{ p++;
j++;
break;
}
}
if(j==0)
printf("-1");
else
printf("%d",p);
}
else
printf("0");
} | ["2", "0", "3"] | C | NoteLet's consider the first sample test. There it is enough to water the flower during the seventh and the ninth month. Then the flower grows by exactly five centimeters.In the second sample Petya's parents will believe him even if the flower doesn't grow at all (kβ=β0). So, it is possible for Petya not to water the flower at all. | Print the only integer β the minimum number of months when Petya has to water the flower so that the flower grows no less than by k centimeters. If the flower can't grow by k centimeters in a year, print -1. | What joy! Petya's parents went on a business trip for the whole year and the playful kid is left all by himself. Petya got absolutely happy. He jumped on the bed and threw pillows all day long, until... Today Petya opened the cupboard and found a scary note there. His parents had left him with duties: he should water their favourite flower all year, each day, in the morning, in the afternoon and in the evening. "Wait a second!" β thought Petya. He know for a fact that if he fulfills the parents' task in the i-th (1ββ€βiββ€β12) month of the year, then the flower will grow by ai centimeters, and if he doesn't water the flower in the i-th month, then the flower won't grow this month. Petya also knows that try as he might, his parents won't believe that he has been watering the flower if it grows strictly less than by k centimeters. Help Petya choose the minimum number of months when he will water the flower, given that the flower should grow no less than by k centimeters. | [{"input": "5\r\n1 1 1 1 2 2 3 2 2 1 1 1\r\n", "output": ["2"]}, {"input": "0\r\n0 0 0 0 0 0 0 1 1 2 3 0\r\n", "output": ["0"]}, {"input": "11\r\n1 1 4 1 1 5 1 1 4 1 1 1\r\n", "output": ["3"]}, {"input": "15\r\n20 1 1 1 1 2 2 1 2 2 1 1\r\n", "output": ["1"]}, {"input": "7\r\n8 9 100 12 14 17 21 10 11 100 23 10\r\n", "output": ["1"]}, {"input": "52\r\n1 12 3 11 4 5 10 6 9 7 8 2\r\n", "output": ["6"]}, {"input": "50\r\n2 2 3 4 5 4 4 5 7 3 2 7\r\n", "output": ["-1"]}, {"input": "0\r\n55 81 28 48 99 20 67 95 6 19 10 93\r\n", "output": ["0"]}, {"input": "93\r\n85 40 93 66 92 43 61 3 64 51 90 21\r\n", "output": ["1"]}, {"input": "99\r\n36 34 22 0 0 0 52 12 0 0 33 47\r\n", "output": ["2"]}, {"input": "99\r\n28 32 31 0 10 35 11 18 0 0 32 28\r\n", "output": ["3"]}, {"input": "99\r\n19 17 0 1 18 11 29 9 29 22 0 8\r\n", "output": ["4"]}, {"input": "76\r\n2 16 11 10 12 0 20 4 4 14 11 14\r\n", "output": ["5"]}, {"input": "41\r\n2 1 7 7 4 2 4 4 9 3 10 0\r\n", "output": ["6"]}, {"input": "47\r\n8 2 2 4 3 1 9 4 2 7 7 8\r\n", "output": ["7"]}, {"input": "58\r\n6 11 7 0 5 6 3 9 4 9 5 1\r\n", "output": ["8"]}, {"input": "32\r\n5 2 4 1 5 0 5 1 4 3 0 3\r\n", "output": ["9"]}, {"input": "31\r\n6 1 0 4 4 5 1 0 5 3 2 0\r\n", "output": ["9"]}, {"input": "35\r\n2 3 0 0 6 3 3 4 3 5 0 6\r\n", "output": ["9"]}, {"input": "41\r\n3 1 3 4 3 6 6 1 4 4 0 6\r\n", "output": ["11"]}, {"input": "97\r\n0 5 3 12 10 16 22 8 21 17 21 10\r\n", "output": ["5"]}, {"input": "100\r\n21 21 0 0 4 13 0 26 0 0 0 15\r\n", "output": ["6"]}, {"input": "100\r\n0 0 16 5 22 0 5 0 25 0 14 13\r\n", "output": ["7"]}, {"input": "97\r\n17 0 10 0 0 0 18 0 14 23 15 0\r\n", "output": ["6"]}, {"input": "100\r\n0 9 0 18 7 0 0 14 33 3 0 16\r\n", "output": ["7"]}, {"input": "95\r\n5 2 13 0 15 18 17 0 6 11 0 8\r\n", "output": ["9"]}, {"input": "94\r\n11 13 0 9 15 8 8 16 3 7 1 3\r\n", "output": ["11"]}, {"input": "96\r\n8 4 12 15 8 0 4 10 6 6 12 11\r\n", "output": ["11"]}, {"input": "100\r\n5 5 3 8 6 5 0 3 3 8 1 3\r\n", "output": ["-1"]}, {"input": "100\r\n1 0 0 1 1 0 1 1 1 1 2 1\r\n", "output": ["-1"]}, {"input": "100\r\n6 3 2 0 4 1 2 2 2 2 1 1\r\n", "output": ["-1"]}, {"input": "0\r\n0 0 0 0 0 0 0 0 0 0 0 0\r\n", "output": ["0"]}, {"input": "100\r\n0 0 0 0 0 0 0 0 0 0 0 0\r\n", "output": ["-1"]}, {"input": "0\r\n100 100 100 100 100 100 100 100 100 100 100 100\r\n", "output": ["0"]}, {"input": "100\r\n100 100 100 100 100 100 100 100 100 100 100 100\r\n", "output": ["1"]}, {"input": "12\r\n1 1 1 1 1 1 1 1 1 1 1 1\r\n", "output": ["12"]}, {"input": "13\r\n1 1 1 1 1 1 1 1 1 1 1 2\r\n", "output": ["12"]}, {"input": "15\r\n10 1 1 1 1 1 1 1 1 1 1 1\r\n", "output": ["6"]}, {"input": "1\r\n0 0 0 0 0 0 0 0 0 0 0 0\r\n", "output": ["-1"]}] | 100 | 100 | 100 | [{'input': '13\r\n1 1 1 1 1 1 1 1 1 1 1 2\r\n', 'output': ['12']}, {'input': '15\r\n20 1 1 1 1 2 2 1 2 2 1 1\r\n', 'output': ['1']}, {'input': '0\r\n0 0 0 0 0 0 0 0 0 0 0 0\r\n', 'output': ['0']}, {'input': '47\r\n8 2 2 4 3 1 9 4 2 7 7 8\r\n', 'output': ['7']}, {'input': '76\r\n2 16 11 10 12 0 20 4 4 14 11 14\r\n', 'output': ['5']}] | [{'input': '5\r\n1 1 1 1 2 2 3 2 2 1 1 1\r\n', 'output': ['2']}, {'input': '96\r\n8 4 12 15 8 0 4 10 6 6 12 11\r\n', 'output': ['11']}, {'input': '100\r\n6 3 2 0 4 1 2 2 2 2 1 1\r\n', 'output': ['-1']}, {'input': '100\r\n100 100 100 100 100 100 100 100 100 100 100 100\r\n', 'output': ['1']}, {'input': '97\r\n0 5 3 12 10 16 22 8 21 17 21 10\r\n', 'output': ['5']}] | [{'input': '0\r\n0 0 0 0 0 0 0 0 0 0 0 0\r\n', 'output': ['0']}, {'input': '47\r\n8 2 2 4 3 1 9 4 2 7 7 8\r\n', 'output': ['7']}, {'input': '15\r\n20 1 1 1 1 2 2 1 2 2 1 1\r\n', 'output': ['1']}, {'input': '41\r\n2 1 7 7 4 2 4 4 9 3 10 0\r\n', 'output': ['6']}, {'input': '7\r\n8 9 100 12 14 17 21 10 11 100 23 10\r\n', 'output': ['1']}] | [{'input': '11\r\n1 1 4 1 1 5 1 1 4 1 1 1\r\n', 'output': ['3']}, {'input': '100\r\n21 21 0 0 4 13 0 26 0 0 0 15\r\n', 'output': ['6']}, {'input': '31\r\n6 1 0 4 4 5 1 0 5 3 2 0\r\n', 'output': ['9']}, {'input': '100\r\n6 3 2 0 4 1 2 2 2 2 1 1\r\n', 'output': ['-1']}, {'input': '100\r\n0 0 16 5 22 0 5 0 25 0 14 13\r\n', 'output': ['7']}] | [{'input': '15\r\n20 1 1 1 1 2 2 1 2 2 1 1\r\n', 'output': ['1']}, {'input': '0\r\n55 81 28 48 99 20 67 95 6 19 10 93\r\n', 'output': ['0']}, {'input': '50\r\n2 2 3 4 5 4 4 5 7 3 2 7\r\n', 'output': ['-1']}, {'input': '99\r\n19 17 0 1 18 11 29 9 29 22 0 8\r\n', 'output': ['4']}, {'input': '100\r\n6 3 2 0 4 1 2 2 2 2 1 1\r\n', 'output': ['-1']}] | 100 | 100 | 100 | 100 | 100 | 95 | 95 | 95 | 95 | 100 | 80 | 90 | 80 | 90 | 100 | 68 | 100 | 96 | 88 |
["1 10\n7 2\n1", "2 2\n2 1\n2"] | The first line contains two integers c and d (1ββ€βc,βdββ€β100)Β β the number of problems in the main and additional rounds, correspondingly. The second line contains two integers n and m (1ββ€βn,βmββ€β100). Finally, the third line contains an integer k (1ββ€βkββ€β100)Β β the number of the pre-chosen winners. | c6ec932b852e0e8c30c822a226ef7bcb | /*!
* @file a.c
* @version 1.0
* @date 17/04/2014
* @author Anton Leontiev <bunder@t-25.ru>
*
* @copyright
*
* Copyright (c) 2014, Anton Leontiev
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
* 3. Neither the name of Anton Leontiev nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
int main(int argc, char *argv[]) {
int a, b, c, d, n, k, m, min = INT_MAX;
scanf("%u %u %u %u %u", &c, &d, &n, &m, &k);
for (a = 0; a <= m; a++) {
b = n * (m - a) - k;
b = b > 0 ? b : 0;
if (min > a * c + b * d) min = a * c + b * d;
}
printf("%u\n", min);
return EXIT_SUCCESS;
}
| ["2", "0"] | C | null | In the first line, print a single integer β the minimum number of problems the jury needs to prepare. | The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds.The elimination rounds are divided into main and additional. Each of the main elimination rounds consists of c problems, the winners of the round are the first n people in the rating list. Each of the additional elimination rounds consists of d problems. The winner of the additional round is one person. Besides, k winners of the past finals are invited to the finals without elimination.As a result of all elimination rounds at least nΒ·m people should go to the finals. You need to organize elimination rounds in such a way, that at least nΒ·m people go to the finals, and the total amount of used problems in all rounds is as small as possible. | [{"input": "1 10\r\n7 2\r\n1\r\n", "output": ["2"]}, {"input": "2 2\r\n2 1\r\n2\r\n", "output": ["0"]}, {"input": "8 9\r\n2 2\r\n3\r\n", "output": ["8"]}, {"input": "5 5\r\n8 8\r\n7\r\n", "output": ["40"]}, {"input": "1 8\r\n8 10\r\n8\r\n", "output": ["9"]}, {"input": "5 7\r\n9 1\r\n8\r\n", "output": ["5"]}, {"input": "35 28\r\n35 60\r\n44\r\n", "output": ["2065"]}, {"input": "19 76\r\n91 91\r\n87\r\n", "output": ["1729"]}, {"input": "20 38\r\n38 70\r\n58\r\n", "output": ["1380"]}, {"input": "2 81\r\n3 39\r\n45\r\n", "output": ["48"]}, {"input": "7 63\r\n18 69\r\n30\r\n", "output": ["476"]}, {"input": "89 69\r\n57 38\r\n15\r\n", "output": ["3382"]}, {"input": "3 30\r\n10 83\r\n57\r\n", "output": ["234"]}, {"input": "100 3\r\n93 23\r\n98\r\n", "output": ["2200"]}, {"input": "2 78\r\n21 24\r\n88\r\n", "output": ["40"]}, {"input": "40 80\r\n4 31\r\n63\r\n", "output": ["640"]}, {"input": "1 48\r\n89 76\r\n24\r\n", "output": ["76"]}, {"input": "5 25\r\n13 76\r\n86\r\n", "output": ["350"]}, {"input": "23 86\r\n83 88\r\n62\r\n", "output": ["2024"]}, {"input": "1 93\r\n76 40\r\n39\r\n", "output": ["40"]}, {"input": "53 93\r\n10 70\r\n9\r\n", "output": ["3710"]}, {"input": "100 100\r\n100 100\r\n100\r\n", "output": ["9900"]}, {"input": "10 100\r\n100 100\r\n99\r\n", "output": ["1000"]}, {"input": "1 100\r\n99 100\r\n1\r\n", "output": ["100"]}, {"input": "10 2\r\n7 2\r\n3\r\n", "output": ["18"]}, {"input": "4 1\r\n5 3\r\n8\r\n", "output": ["6"]}, {"input": "2 2\r\n2 1\r\n20\r\n", "output": ["0"]}, {"input": "7 5\r\n1 1\r\n10\r\n", "output": ["0"]}, {"input": "4 5\r\n9 10\r\n100\r\n", "output": ["0"]}, {"input": "10 1\r\n1 2\r\n1\r\n", "output": ["1"]}, {"input": "16 6\r\n3 12\r\n7\r\n", "output": ["156"]}, {"input": "10 1\r\n1 100\r\n1\r\n", "output": ["99"]}, {"input": "2 1\r\n3 4\r\n2\r\n", "output": ["7"]}, {"input": "2 1\r\n1 1\r\n10\r\n", "output": ["0"]}, {"input": "100 1\r\n2 3\r\n1\r\n", "output": ["5"]}, {"input": "10 2\r\n1 11\r\n1\r\n", "output": ["20"]}, {"input": "10 10\r\n1 1\r\n100\r\n", "output": ["0"]}, {"input": "100 1\r\n50 100\r\n1\r\n", "output": ["4999"]}, {"input": "10 1\r\n2 2\r\n3\r\n", "output": ["1"]}, {"input": "3 1\r\n9 10\r\n80\r\n", "output": ["4"]}, {"input": "100 1\r\n1 100\r\n1\r\n", "output": ["99"]}, {"input": "10 9\r\n10 10\r\n9\r\n", "output": ["99"]}, {"input": "1 1\r\n1 1\r\n99\r\n", "output": ["0"]}, {"input": "10 9\r\n1 1\r\n100\r\n", "output": ["0"]}, {"input": "4 1\r\n5 1\r\n10\r\n", "output": ["0"]}, {"input": "5 1\r\n6 3\r\n5\r\n", "output": ["11"]}, {"input": "10 1\r\n1 1\r\n10\r\n", "output": ["0"]}, {"input": "1 1\r\n1 1\r\n10\r\n", "output": ["0"]}] | 100 | 100 | 100 | [{'input': '100 1\r\n2 3\r\n1\r\n', 'output': ['5']}, {'input': '10 100\r\n100 100\r\n99\r\n', 'output': ['1000']}, {'input': '35 28\r\n35 60\r\n44\r\n', 'output': ['2065']}, {'input': '40 80\r\n4 31\r\n63\r\n', 'output': ['640']}, {'input': '3 1\r\n9 10\r\n80\r\n', 'output': ['4']}] | [{'input': '100 100\r\n100 100\r\n100\r\n', 'output': ['9900']}, {'input': '20 38\r\n38 70\r\n58\r\n', 'output': ['1380']}, {'input': '10 2\r\n7 2\r\n3\r\n', 'output': ['18']}, {'input': '2 2\r\n2 1\r\n2\r\n', 'output': ['0']}, {'input': '5 25\r\n13 76\r\n86\r\n', 'output': ['350']}] | [{'input': '10 9\r\n10 10\r\n9\r\n', 'output': ['99']}, {'input': '5 25\r\n13 76\r\n86\r\n', 'output': ['350']}, {'input': '2 78\r\n21 24\r\n88\r\n', 'output': ['40']}, {'input': '2 2\r\n2 1\r\n2\r\n', 'output': ['0']}, {'input': '10 2\r\n1 11\r\n1\r\n', 'output': ['20']}] | [{'input': '5 1\r\n6 3\r\n5\r\n', 'output': ['11']}, {'input': '10 1\r\n1 100\r\n1\r\n', 'output': ['99']}, {'input': '2 1\r\n3 4\r\n2\r\n', 'output': ['7']}, {'input': '1 8\r\n8 10\r\n8\r\n', 'output': ['9']}, {'input': '35 28\r\n35 60\r\n44\r\n', 'output': ['2065']}] | [{'input': '8 9\r\n2 2\r\n3\r\n', 'output': ['8']}, {'input': '5 1\r\n6 3\r\n5\r\n', 'output': ['11']}, {'input': '100 100\r\n100 100\r\n100\r\n', 'output': ['9900']}, {'input': '10 2\r\n7 2\r\n3\r\n', 'output': ['18']}, {'input': '2 1\r\n3 4\r\n2\r\n', 'output': ['7']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 69 | 100 | 100 | 100 |
["15 20", "14 8", "6 6"] | The first line contains two space-separated integers a and b (1ββ€βa,βbββ€β109). | 75a97f4d85d50ea0e1af0d46f7565b49 | #include<stdio.h>
typedef long long ll;
ll fox(ll a,ll b);
ll gcd(ll a,ll b);
int main()
{
ll a,b,c,d;
scanf("%lld%lld",&a,&b);
d = (a>b)?gcd(a,b):gcd(b,a);
c = fox(a/d,b/d);
printf("%lld",c);
return 0;
}
ll gcd(ll a,ll b)
{
if(b==(ll)0)
return a;
return gcd(b,a%b);
}
ll fox(ll a,ll b)
{
static ll count = (ll)0;
ll larger,smaller;
if(a==b)
return count;
count += (ll)1;
if(a>b)
{
larger = a,smaller = b;
}
else
{
smaller = a,larger = b;
}
if(larger % (ll)2==(ll)0)
{
if(larger==a)
a/=(ll)2;
else
b/=(ll)2;
return fox(a,b);
}
else if(larger % (ll)3==(ll)0)
{
if(larger == a)
a/=(ll)3;
else
b/=(ll)3;
return fox(a,b);
}
else if(larger % (ll)5==(ll)0)
{
if(larger == a)
a/=(ll)5;
else
b/=(ll)5;
return fox(a,b);
}
else
return -1;
}
| ["3", "-1", "0"] | C | null | If the fox is lying to the little bears and it is impossible to make the pieces equal, print -1. Otherwise, print the required minimum number of operations. If the pieces of the cheese are initially equal, the required number is 0. | Two little greedy bears have found two pieces of cheese in the forest of weight a and b grams, correspondingly. The bears are so greedy that they are ready to fight for the larger piece. That's where the fox comes in and starts the dialog: "Little bears, wait a little, I want to make your pieces equal" "Come off it fox, how are you going to do that?", the curious bears asked. "It's easy", said the fox. "If the mass of a certain piece is divisible by two, then I can eat exactly a half of the piece. If the mass of a certain piece is divisible by three, then I can eat exactly two-thirds, and if the mass is divisible by five, then I can eat four-fifths. I'll eat a little here and there and make the pieces equal". The little bears realize that the fox's proposal contains a catch. But at the same time they realize that they can not make the two pieces equal themselves. So they agreed to her proposal, but on one condition: the fox should make the pieces equal as quickly as possible. Find the minimum number of operations the fox needs to make pieces equal. | [{"input": "15 20\r\n", "output": ["3"]}, {"input": "14 8\r\n", "output": ["-1"]}, {"input": "6 6\r\n", "output": ["0"]}, {"input": "1 1\r\n", "output": ["0"]}, {"input": "1 1024\r\n", "output": ["10"]}, {"input": "1024 729\r\n", "output": ["16"]}, {"input": "1024 1048576\r\n", "output": ["10"]}, {"input": "36 30\r\n", "output": ["3"]}, {"input": "100 10\r\n", "output": ["2"]}, {"input": "21 35\r\n", "output": ["2"]}, {"input": "9900 7128\r\n", "output": ["5"]}, {"input": "7920 9900\r\n", "output": ["3"]}, {"input": "576000 972000\r\n", "output": ["7"]}, {"input": "691200 583200\r\n", "output": ["8"]}, {"input": "607500 506250\r\n", "output": ["3"]}, {"input": "881280 765000\r\n", "output": ["9"]}, {"input": "800000 729000\r\n", "output": ["13"]}, {"input": "792000 792000\r\n", "output": ["0"]}, {"input": "513600 513600\r\n", "output": ["0"]}, {"input": "847500 610200\r\n", "output": ["5"]}, {"input": "522784320 784176480\r\n", "output": ["2"]}, {"input": "689147136 861433920\r\n", "output": ["3"]}, {"input": "720212000 864254400\r\n", "output": ["3"]}, {"input": "673067520 807681024\r\n", "output": ["3"]}, {"input": "919536000 993098880\r\n", "output": ["5"]}, {"input": "648293430 540244525\r\n", "output": ["3"]}, {"input": "537814642 537814642\r\n", "output": ["0"]}, {"input": "100000007 800000011\r\n", "output": ["-1"]}, {"input": "900000011 800000011\r\n", "output": ["-1"]}, {"input": "900000011 999900017\r\n", "output": ["-1"]}, {"input": "536870912 387420489\r\n", "output": ["47"]}, {"input": "820125000 874800000\r\n", "output": ["6"]}, {"input": "864000000 607500000\r\n", "output": ["9"]}, {"input": "609120000 913680000\r\n", "output": ["2"]}, {"input": "509607936 306110016\r\n", "output": ["24"]}, {"input": "445906944 528482304\r\n", "output": ["8"]}, {"input": "119144448 423624704\r\n", "output": ["7"]}, {"input": "1 1000000000\r\n", "output": ["18"]}, {"input": "1000000000 1\r\n", "output": ["18"]}, {"input": "1000000000 2\r\n", "output": ["17"]}, {"input": "2 1000000000\r\n", "output": ["17"]}, {"input": "5 1000000000\r\n", "output": ["17"]}, {"input": "1000000000 5\r\n", "output": ["17"]}, {"input": "3 1000000000\r\n", "output": ["19"]}, {"input": "1000000000 3\r\n", "output": ["19"]}, {"input": "1000000000 7\r\n", "output": ["-1"]}, {"input": "2208870 122715\r\n", "output": ["3"]}, {"input": "4812500 7577955\r\n", "output": ["16"]}, {"input": "3303936 3097440\r\n", "output": ["6"]}, {"input": "55404 147744\r\n", "output": ["4"]}, {"input": "10332160 476643528\r\n", "output": ["19"]}, {"input": "21751200 43502400\r\n", "output": ["1"]}, {"input": "19500000 140400000\r\n", "output": ["5"]}, {"input": "1 22\r\n", "output": ["-1"]}] | 100 | 100 | 100 | [{'input': '900000011 999900017\r\n', 'output': ['-1']}, {'input': '1000000000 2\r\n', 'output': ['17']}, {'input': '15 20\r\n', 'output': ['3']}, {'input': '720212000 864254400\r\n', 'output': ['3']}, {'input': '1024 729\r\n', 'output': ['16']}] | [{'input': '673067520 807681024\r\n', 'output': ['3']}, {'input': '36 30\r\n', 'output': ['3']}, {'input': '7920 9900\r\n', 'output': ['3']}, {'input': '607500 506250\r\n', 'output': ['3']}, {'input': '900000011 800000011\r\n', 'output': ['-1']}] | [{'input': '100000007 800000011\r\n', 'output': ['-1']}, {'input': '4812500 7577955\r\n', 'output': ['16']}, {'input': '3 1000000000\r\n', 'output': ['19']}, {'input': '2 1000000000\r\n', 'output': ['17']}, {'input': '720212000 864254400\r\n', 'output': ['3']}] | [{'input': '1 1000000000\r\n', 'output': ['18']}, {'input': '1 1\r\n', 'output': ['0']}, {'input': '21 35\r\n', 'output': ['2']}, {'input': '1000000000 7\r\n', 'output': ['-1']}, {'input': '445906944 528482304\r\n', 'output': ['8']}] | [{'input': '691200 583200\r\n', 'output': ['8']}, {'input': '100 10\r\n', 'output': ['2']}, {'input': '3303936 3097440\r\n', 'output': ['6']}, {'input': '119144448 423624704\r\n', 'output': ['7']}, {'input': '100000007 800000011\r\n', 'output': ['-1']}] | 100 | 100 | 100 | 100 | 100 | 96.97 | 100 | 100 | 96.97 | 100 | 95 | 100 | 95 | 95 | 100 | 70 | 100 | 98.788 | 97 |
["12"] | 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. | e392be5411ffccc1df50e65ec1f5c589 | #include<stdio.h>
int main()
{
long long int n;
scanf("%lld",&n);
n=n-n/2-n/3-n/5-n/7+n/6+n/10+n/14+n/15+n/21+n/35-n/30-n/105-n/42-n/70+n/210;
printf("%lld\n",n);
return 0;
}
| ["2"] | C | null | Output one integer showing how many numbers from 1 to n are not divisible by any number from 2 to 10. | IT City company developing computer games decided to upgrade its way to reward its employees. Now it looks the following way. 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 not divisible by any number 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": "12\r\n", "output": ["2"]}, {"input": "2519\r\n", "output": ["576"]}, {"input": "2521\r\n", "output": ["577"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "314159265\r\n", "output": ["71807832"]}, {"input": "718281828459045235\r\n", "output": ["164178703647781768"]}, {"input": "1000000000000000000\r\n", "output": ["228571428571428571"]}, {"input": "987654321234567890\r\n", "output": ["225749559139329804"]}, {"input": "3628800\r\n", "output": ["829440"]}, {"input": "504000000000000000\r\n", "output": ["115200000000000000"]}] | 100 | 100 | 100 | [{'input': '12\r\n', 'output': ['2']}, {'input': '1\r\n', 'output': ['1']}, {'input': '718281828459045235\r\n', 'output': ['164178703647781768']}, {'input': '2519\r\n', 'output': ['576']}, {'input': '2521\r\n', 'output': ['577']}] | [{'input': '314159265\r\n', 'output': ['71807832']}, {'input': '1000000000000000000\r\n', 'output': ['228571428571428571']}, {'input': '12\r\n', 'output': ['2']}, {'input': '1\r\n', 'output': ['1']}, {'input': '3628800\r\n', 'output': ['829440']}] | [{'input': '1\r\n', 'output': ['1']}, {'input': '718281828459045235\r\n', 'output': ['164178703647781768']}, {'input': '987654321234567890\r\n', 'output': ['225749559139329804']}, {'input': '504000000000000000\r\n', 'output': ['115200000000000000']}, {'input': '314159265\r\n', 'output': ['71807832']}] | [{'input': '2521\r\n', 'output': ['577']}, {'input': '2519\r\n', 'output': ['576']}, {'input': '504000000000000000\r\n', 'output': ['115200000000000000']}, {'input': '3628800\r\n', 'output': ['829440']}, {'input': '314159265\r\n', 'output': ['71807832']}] | [{'input': '718281828459045235\r\n', 'output': ['164178703647781768']}, {'input': '987654321234567890\r\n', 'output': ['225749559139329804']}, {'input': '3628800\r\n', 'output': ['829440']}, {'input': '1000000000000000000\r\n', 'output': ['228571428571428571']}, {'input': '2519\r\n', 'output': ['576']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 71 | 100 | 100 | 100 |
["21 5", "9435152 272", "10 10"] | In the only line of the input two space-separated integers a and b (0ββ€βa,βbββ€β109) are given. | 6e0715f9239787e085b294139abb2475 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void)
{
int a, b, c, i, ans = 0;
scanf("%d%d", &a, &b);
c = a - b;
if (c == 0)
{
printf("infinity");
return 0;
}
for (i = 1; i * i <= c; i++)
{
if (c % i == 0)
{
if (i > b)
ans++;
if ((c / i != i) && (c / i > b))
ans++;
}
}
printf("%d", ans);
return 0;
}
| ["2", "282", "infinity"] | C | NoteIn the first sample the answers of the Modular Equation are 8 and 16 since | If there is an infinite number of answers to our equation, print "infinity" (without the quotes). Otherwise print the number of solutions of the Modular Equation . | Last week, Hamed learned about a new type of equations in his math class called Modular Equations. Lets define i modulo j as the remainder of division of i by j and denote it by . A Modular Equation, as Hamed's teacher described, is an equation of the form in which a and b are two non-negative integers and x is a variable. We call a positive integer x for which a solution of our equation.Hamed didn't pay much attention to the class since he was watching a movie. He only managed to understand the definitions of these equations.Now he wants to write his math exercises but since he has no idea how to do that, he asked you for help. He has told you all he knows about Modular Equations and asked you to write a program which given two numbers a and b determines how many answers the Modular Equation has. | [{"input": "21 5\r\n", "output": ["2"]}, {"input": "9435152 272\r\n", "output": ["282"]}, {"input": "10 10\r\n", "output": ["infinity"]}, {"input": "0 1000000000\r\n", "output": ["0"]}, {"input": "11 2\r\n", "output": ["2"]}, {"input": "1 0\r\n", "output": ["1"]}, {"input": "0 0\r\n", "output": ["infinity"]}, {"input": "121 0\r\n", "output": ["3"]}, {"input": "772930485 686893955\r\n", "output": ["0"]}, {"input": "257424 24\r\n", "output": ["127"]}, {"input": "295138437 589952171\r\n", "output": ["0"]}, {"input": "223093836 966\r\n", "output": ["399"]}, {"input": "233758336 10665466\r\n", "output": ["13"]}, {"input": "223092887 17\r\n", "output": ["500"]}, {"input": "223094728 1858\r\n", "output": ["371"]}, {"input": "223092899 29\r\n", "output": ["495"]}, {"input": "997920 0\r\n", "output": ["240"]}, {"input": "887043 3\r\n", "output": ["213"]}, {"input": "124 24\r\n", "output": ["3"]}, {"input": "982901 101\r\n", "output": ["193"]}, {"input": "357987 35\r\n", "output": ["45"]}, {"input": "954374 1030\r\n", "output": ["32"]}, {"input": "49106 46\r\n", "output": ["15"]}, {"input": "325508499 119510657\r\n", "output": ["1"]}, {"input": "89768760 885778845\r\n", "output": ["0"]}, {"input": "944387968 700818251\r\n", "output": ["0"]}, {"input": "12 3\r\n", "output": ["1"]}, {"input": "1000000000 1\r\n", "output": ["19"]}, {"input": "923456789 3\r\n", "output": ["14"]}, {"input": "1000000000 6\r\n", "output": ["6"]}, {"input": "1000000000 333333300\r\n", "output": ["2"]}, {"input": "5 2\r\n", "output": ["1"]}, {"input": "1 10\r\n", "output": ["0"]}, {"input": "15 3\r\n", "output": ["3"]}, {"input": "2 0\r\n", "output": ["2"]}, {"input": "77 75\r\n", "output": ["0"]}, {"input": "1000000000 1000000000\r\n", "output": ["infinity"]}] | 100 | 100 | 100 | [{'input': '1000000000 333333300\r\n', 'output': ['2']}, {'input': '223094728 1858\r\n', 'output': ['371']}, {'input': '223092887 17\r\n', 'output': ['500']}, {'input': '997920 0\r\n', 'output': ['240']}, {'input': '11 2\r\n', 'output': ['2']}] | [{'input': '997920 0\r\n', 'output': ['240']}, {'input': '325508499 119510657\r\n', 'output': ['1']}, {'input': '11 2\r\n', 'output': ['2']}, {'input': '887043 3\r\n', 'output': ['213']}, {'input': '223093836 966\r\n', 'output': ['399']}] | [{'input': '982901 101\r\n', 'output': ['193']}, {'input': '223092899 29\r\n', 'output': ['495']}, {'input': '0 1000000000\r\n', 'output': ['0']}, {'input': '1 0\r\n', 'output': ['1']}, {'input': '15 3\r\n', 'output': ['3']}] | [{'input': '9435152 272\r\n', 'output': ['282']}, {'input': '223092899 29\r\n', 'output': ['495']}, {'input': '923456789 3\r\n', 'output': ['14']}, {'input': '77 75\r\n', 'output': ['0']}, {'input': '89768760 885778845\r\n', 'output': ['0']}] | [{'input': '9435152 272\r\n', 'output': ['282']}, {'input': '5 2\r\n', 'output': ['1']}, {'input': '223094728 1858\r\n', 'output': ['371']}, {'input': '295138437 589952171\r\n', 'output': ['0']}, {'input': '1000000000 1\r\n', 'output': ['19']}] | 100 | 100 | 100 | 100 | 100 | 86.67 | 86.67 | 86.67 | 86.67 | 86.67 | 91.67 | 91.67 | 83.33 | 83.33 | 75 | 72 | 100 | 86.67 | 85 |
["1", "10"] | A single line contains a single integer x (1ββ€βxββ€β109). | ada94770281765f54ab264b4a1ef766e | #include <stdlib.h>
#include <string.h>
#include <stdio.h>
int x_digit[10], d_digit[10], count;
void find_digits(int *digit, int num) {
int i;
for (i = 0; i < 10; i++)
digit[i] = 0;
while (num > 0) {
digit[num%10] = 1;
num /= 10;
}
}
void check(int d) {
int i;
find_digits(d_digit, d);
for (i = 0; i < 10; i++)
if (x_digit[i] && d_digit[i]) {
count++;
break;
}
}
int main() {
int x, d;
scanf(" %d", &x);
find_digits(x_digit, x);
for (d = 1; d*d <= x; d++) {
if (x%d > 0)
continue;
check(d);
if (x/d != d)
check(x/d);
}
printf("%d\n", count);
return 0;
}
| ["1", "2"] | C | null | In a single line print an integer β the answer to the problem. | The Little Elephant loves numbers. He has a positive integer x. The Little Elephant wants to find the number of positive integers d, such that d is the divisor of x, and x and d have at least one common (the same) digit in their decimal representations. Help the Little Elephant to find the described number. | [{"input": "1\r\n", "output": ["1"]}, {"input": "10\r\n", "output": ["2"]}, {"input": "47\r\n", "output": ["1"]}, {"input": "100\r\n", "output": ["5"]}, {"input": "128\r\n", "output": ["6"]}, {"input": "2\r\n", "output": ["1"]}, {"input": "17\r\n", "output": ["2"]}, {"input": "1000000\r\n", "output": ["41"]}, {"input": "1000000000\r\n", "output": ["91"]}, {"input": "4584725\r\n", "output": ["5"]}, {"input": "999999999\r\n", "output": ["6"]}, {"input": "9\r\n", "output": ["1"]}, {"input": "3\r\n", "output": ["1"]}, {"input": "4\r\n", "output": ["1"]}, {"input": "20\r\n", "output": ["3"]}, {"input": "24\r\n", "output": ["4"]}, {"input": "48\r\n", "output": ["4"]}, {"input": "2458450\r\n", "output": ["11"]}, {"input": "97648850\r\n", "output": ["44"]}, {"input": "96488450\r\n", "output": ["21"]}, {"input": "879541\r\n", "output": ["7"]}, {"input": "111111111\r\n", "output": ["5"]}, {"input": "222222222\r\n", "output": ["6"]}, {"input": "777777777\r\n", "output": ["9"]}, {"input": "211768200\r\n", "output": ["244"]}, {"input": "536870912\r\n", "output": ["29"]}, {"input": "654885000\r\n", "output": ["698"]}, {"input": "223092870\r\n", "output": ["479"]}, {"input": "901800900\r\n", "output": ["639"]}, {"input": "101871000\r\n", "output": ["460"]}, {"input": "49\r\n", "output": ["1"]}, {"input": "999999993\r\n", "output": ["5"]}, {"input": "999999666\r\n", "output": ["8"]}, {"input": "999999997\r\n", "output": ["6"]}, {"input": "960690025\r\n", "output": ["8"]}, {"input": "16\r\n", "output": ["2"]}, {"input": "999000011\r\n", "output": ["2"]}, {"input": "999999937\r\n", "output": ["1"]}, {"input": "999999998\r\n", "output": ["6"]}] | 100 | 100 | 100 | [{'input': '17\r\n', 'output': ['2']}, {'input': '1000000\r\n', 'output': ['41']}, {'input': '960690025\r\n', 'output': ['8']}, {'input': '111111111\r\n', 'output': ['5']}, {'input': '999000011\r\n', 'output': ['2']}] | [{'input': '3\r\n', 'output': ['1']}, {'input': '999999937\r\n', 'output': ['1']}, {'input': '536870912\r\n', 'output': ['29']}, {'input': '901800900\r\n', 'output': ['639']}, {'input': '2\r\n', 'output': ['1']}] | [{'input': '999000011\r\n', 'output': ['2']}, {'input': '999999997\r\n', 'output': ['6']}, {'input': '20\r\n', 'output': ['3']}, {'input': '901800900\r\n', 'output': ['639']}, {'input': '999999666\r\n', 'output': ['8']}] | [{'input': '879541\r\n', 'output': ['7']}, {'input': '17\r\n', 'output': ['2']}, {'input': '47\r\n', 'output': ['1']}, {'input': '48\r\n', 'output': ['4']}, {'input': '111111111\r\n', 'output': ['5']}] | [{'input': '2\r\n', 'output': ['1']}, {'input': '211768200\r\n', 'output': ['244']}, {'input': '999999666\r\n', 'output': ['8']}, {'input': '17\r\n', 'output': ['2']}, {'input': '999999998\r\n', 'output': ['6']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 93.75 | 93.75 | 73 | 100 | 100 | 97.5 |
["abcd", "ababa", "zzz"] | The first input line contains the string. It's guaranteed, that the string is non-empty, consists of lower-case Latin letters, and its length doesn't exceed 100. | 13b5cf94f2fabd053375a5ccf3fd44c7 | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char s[100];
scanf("%s",s);
int l = strlen(s);
int len = 0;
for(int i = 0; i<l; i++)
{
for(int j = i+1; j<l; j++)
{
int n = 0;
while(s[i+n] == s[j+n])
n++;
if(n>len)
len = n;
}
}
printf("%d\n",len);
return 0;
}
| ["0", "3", "2"] | C | null | Output one number β length of the longest substring that can be met in the string at least twice. | You're given a string of lower-case Latin letters. Your task is to find the length of its longest substring that can be met in the string at least twice. These occurrences can overlap (see sample test 2). | [{"input": "abcd\r\n", "output": ["0"]}, {"input": "ababa\r\n", "output": ["3"]}, {"input": "zzz\r\n", "output": ["2"]}, {"input": "kmmm\r\n", "output": ["2"]}, {"input": "wzznz\r\n", "output": ["1"]}, {"input": "qlzazaaqll\r\n", "output": ["2"]}, {"input": "lzggglgpep\r\n", "output": ["2"]}, {"input": "iegdlraaidefgegiagrdfhihe\r\n", "output": ["2"]}, {"input": "esxpqmdrtidgtkxojuxyrcwxlycywtzbjzpxvbngnlepgzcaeg\r\n", "output": ["1"]}, {"input": "garvpaimjdjiivamusjdwfcaoswuhxyyxvrxzajoyihggvuxumaadycfphrzbprraicvjjlsdhojihaw\r\n", "output": ["2"]}, {"input": "ckvfndqgkmhcyojaqgdkenmbexufryhqejdhctxujmtrwkpbqxufxamgoeigzfyzbhevpbkvviwntdhqscvkmphnkkljizndnbjt\r\n", "output": ["3"]}, {"input": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\r\n", "output": ["99"]}, {"input": "ikiikiikikiiikkkkkikkkkiiiiikkiiikkiikiikkkkikkkikikkikiiikkikikiiikikkkiiikkkikkikkikkkkiiikkiiiiii\r\n", "output": ["10"]}, {"input": "ovovhoovvhohhhvhhvhhvhovoohovhhoooooovohvooooohvvoooohvvovhhvhovhhvoovhvhvoovovvhooovhhooovohvhhovhv\r\n", "output": ["8"]}, {"input": "ccwckkkycccccckwckwkwkwkkkkyycykcccycyckwywcckwykcycykkkwcycwwcykcwkwkwwykwkwcykywwwyyykckkyycckwcwk\r\n", "output": ["5"]}, {"input": "ttketfkefktfztezzkzfkkeetkkfktftzktezekkeezkeeetteeteefetefkzzzetekfftkeffzkktffzkzzeftfeezfefzffeef\r\n", "output": ["4"]}, {"input": "rtharczpfznrgdnkltchafduydgbgkdjqrmjqyfmpwjwphrtsjbmswkanjlprbnduaqbcjqxlxmkspkhkcnzbqwxonzxxdmoigti\r\n", "output": ["2"]}, {"input": "fplrkfklvwdeiynbjgaypekambmbjfnoknlhczhkdmljicookdywdgpnlnqlpunnkebnikgcgcjefeqhknvlynmvjcegvcdgvvdb\r\n", "output": ["2"]}, {"input": "txbciieycswqpniwvzipwlottivvnfsysgzvzxwbctcchfpvlbcjikdofhpvsknptpjdbxemtmjcimetkemdbettqnbvzzbdyxxb\r\n", "output": ["2"]}, {"input": "fmubmfwefikoxtqvmaavwjxmoqltapexkqxcsztpezfcltqavuicefxovuswmqimuikoppgqpiapqutkczgcvxzutavkujxvpklv\r\n", "output": ["3"]}, {"input": "ipsrjylhpkjvlzncfixipstwcicxqygqcfrawpzzvckoveyqhathglblhpkjvlzncfixipfajaqobtzvthmhgbuawoxoknirclxg\r\n", "output": ["15"]}, {"input": "kcnjsntjzcbgzjscrsrjkrbytqsrptzspzctjrorsyggrtkcnjsntjzcbgzjscrsrjyqbrtpcgqirsrrjbbbrnyqstnrozcoztt\r\n", "output": ["20"]}, {"input": "unhcfnrhsqetuerjqcetrhlsqgfnqfntvkgxsscquolxxroqgtchffyccetrhlsqgfnqfntvkgxsscquolxxroqgtchffhfqvx\r\n", "output": ["37"]}, {"input": "kkcckkccckkcckcccckcckkkkcckkkkckkkcckckkkkkckkkkkcckkccckkcckcccckcckkkkcckkkkckkkcckckkkkkckckckkc\r\n", "output": ["46"]}, {"input": "mlhsyijxeydqxhtkmpdeqwzogjvxahmssyhfhqessbxzvydbrxdmlhsyijxeydqxhtkmpdeqwzogjvxahmssyhfhqessbxzvydik\r\n", "output": ["47"]}, {"input": "abcdefghijklmnopqrstuvwxyz\r\n", "output": ["0"]}, {"input": "tttttbttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttmttttttt\r\n", "output": ["85"]}, {"input": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffffffffffffffffffffffffffffffffffff\r\n", "output": ["61"]}, {"input": "cccccccccccccccccccccccwcccccccccccccccccccccuccccccccccccccnccccccccccccccccccccccccccccccccccccccc\r\n", "output": ["38"]}, {"input": "ffffffffffffffffffffffffffufffgfffffffffffffffffffffffffffffffffffffffgffffffftffffffgffffffffffffff\r\n", "output": ["38"]}, {"input": "rrrrrrrrrrrrrrrrrrrlhbrrrrrrrrurrrrrrrfrrqrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrewrrrrrrryrrxrrrrrrrrrrr\r\n", "output": ["33"]}, {"input": "vyvvvvvvvvzvvvvvzvvvwvvvvrvvvvvvvvvvvvvvvrvvvvvvvvvpkvvpvgvvvvvvvvvvvvvgvvvvvvvvvvvvvvvvvvysvvvbvvvv\r\n", "output": ["17"]}, {"input": "cbubbbbbbbbbbfbbbbbbbbjbobbbbbbbbbbibbubbbbjbbbnzgbbzbbfbbbbbbbbbbbfbpbbbbbbbbbbygbbbgbabbbbbbbhibbb\r\n", "output": ["12"]}, {"input": "lrqrrrrrrrjrrrrrcdrrgrrmwvrrrrrrrrrxfzrmrmrryrrrurrrdrrrrrrrrrrererrrsrrrrrrrrrrrqrrrrcrrwjsrrlrrrrr\r\n", "output": ["10"]}, {"input": "ssssusisisosscssssztzessssyspskjssvosiissussszsosssslsssdsssvssvsssslsssmsfjasjsssssowscsjsssszsspss\r\n", "output": ["8"]}, {"input": "uukuuuumueuuuujuukgdhbztuuuubbguuocuozfaunqufjujuguyuuvkuuauubuubuucuvtjuuuuuusduduuuuuuuueunuuuuuzu\r\n", "output": ["7"]}, {"input": "jpkkgwklngwqcfzmwkkpcwkkkkkekkkekkkdsykqwjkkkhkkkxdnukkkkkkmkqykkkxqklkskkrkkkkkqqjikkkkkkpknkkkkkoh\r\n", "output": ["7"]}, {"input": "bmzbbfbbhqxwthtbbisbbbbbtbbfbbpbfbbpbkbjfbcbbbbzbbbdwmbbbrnvqdbbtbbuglrnbbbbvmbyblebbabibrevaxbbjbqb\r\n", "output": ["6"]}, {"input": "qqqmqqqsbteqqopsuqiqumrqzpqnqgqeniqqkyqqyqqqpxzqeqqquhdqquhqqqfqjirqaqqaquxqoqqjqqqqbjbgqcqqqqicnkqc\r\n", "output": ["4"]}, {"input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasaaaavaaaaaaauaaeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n", "output": ["44"]}, {"input": "a\r\n", "output": ["0"]}, {"input": "fg\r\n", "output": ["0"]}, {"input": "yy\r\n", "output": ["1"]}, {"input": "abcabcabc\r\n", "output": ["6"]}, {"input": "qwerqwedqwes\r\n", "output": ["3"]}] | 100 | 100 | 100 | [{'input': 'fmubmfwefikoxtqvmaavwjxmoqltapexkqxcsztpezfcltqavuicefxovuswmqimuikoppgqpiapqutkczgcvxzutavkujxvpklv\r\n', 'output': ['3']}, {'input': 'ttketfkefktfztezzkzfkkeetkkfktftzktezekkeezkeeetteeteefetefkzzzetekfftkeffzkktffzkzzeftfeezfefzffeef\r\n', 'output': ['4']}, {'input': 'qqqmqqqsbteqqopsuqiqumrqzpqnqgqeniqqkyqqyqqqpxzqeqqquhdqquhqqqfqjirqaqqaquxqoqqjqqqqbjbgqcqqqqicnkqc\r\n', 'output': ['4']}, {'input': 'ccwckkkycccccckwckwkwkwkkkkyycykcccycyckwywcckwykcycykkkwcycwwcykcwkwkwwykwkwcykywwwyyykckkyycckwcwk\r\n', 'output': ['5']}, {'input': 'kcnjsntjzcbgzjscrsrjkrbytqsrptzspzctjrorsyggrtkcnjsntjzcbgzjscrsrjyqbrtpcgqirsrrjbbbrnyqstnrozcoztt\r\n', 'output': ['20']}] | [{'input': 'mlhsyijxeydqxhtkmpdeqwzogjvxahmssyhfhqessbxzvydbrxdmlhsyijxeydqxhtkmpdeqwzogjvxahmssyhfhqessbxzvydik\r\n', 'output': ['47']}, {'input': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasaaaavaaaaaaauaaeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n', 'output': ['44']}, {'input': 'abcabcabc\r\n', 'output': ['6']}, {'input': 'kmmm\r\n', 'output': ['2']}, {'input': 'abcd\r\n', 'output': ['0']}] | [{'input': 'garvpaimjdjiivamusjdwfcaoswuhxyyxvrxzajoyihggvuxumaadycfphrzbprraicvjjlsdhojihaw\r\n', 'output': ['2']}, {'input': 'ipsrjylhpkjvlzncfixipstwcicxqygqcfrawpzzvckoveyqhathglblhpkjvlzncfixipfajaqobtzvthmhgbuawoxoknirclxg\r\n', 'output': ['15']}, {'input': 'txbciieycswqpniwvzipwlottivvnfsysgzvzxwbctcchfpvlbcjikdofhpvsknptpjdbxemtmjcimetkemdbettqnbvzzbdyxxb\r\n', 'output': ['2']}, {'input': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasaaaavaaaaaaauaaeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n', 'output': ['44']}, {'input': 'a\r\n', 'output': ['0']}] | [{'input': 'abcd\r\n', 'output': ['0']}, {'input': 'ababa\r\n', 'output': ['3']}, {'input': 'kcnjsntjzcbgzjscrsrjkrbytqsrptzspzctjrorsyggrtkcnjsntjzcbgzjscrsrjyqbrtpcgqirsrrjbbbrnyqstnrozcoztt\r\n', 'output': ['20']}, {'input': 'ttketfkefktfztezzkzfkkeetkkfktftzktezekkeezkeeetteeteefetefkzzzetekfftkeffzkktffzkzzeftfeezfefzffeef\r\n', 'output': ['4']}, {'input': 'yy\r\n', 'output': ['1']}] | [{'input': 'rrrrrrrrrrrrrrrrrrrlhbrrrrrrrrurrrrrrrfrrqrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrewrrrrrrryrrxrrrrrrrrrrr\r\n', 'output': ['33']}, {'input': 'fmubmfwefikoxtqvmaavwjxmoqltapexkqxcsztpezfcltqavuicefxovuswmqimuikoppgqpiapqutkczgcvxzutavkujxvpklv\r\n', 'output': ['3']}, {'input': 'qlzazaaqll\r\n', 'output': ['2']}, {'input': 'mlhsyijxeydqxhtkmpdeqwzogjvxahmssyhfhqessbxzvydbrxdmlhsyijxeydqxhtkmpdeqwzogjvxahmssyhfhqessbxzvydik\r\n', 'output': ['47']}, {'input': 'cbubbbbbbbbbbfbbbbbbbbjbobbbbbbbbbbibbubbbbjbbbnzgbbzbbfbbbbbbbbbbbfbpbbbbbbbbbbygbbbgbabbbbbbbhibbb\r\n', 'output': ['12']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 74 | 100 | 100 | 100 |
["7 3\n3 5 7 1 6 2 8\n1 2 7", "4 4\n3 4 1 0\n0 1 7 9"] | The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 10$$$) representing the number of digits in the sequence you have and the number of keys on the keypad that have fingerprints. The next line contains $$$n$$$ distinct space-separated integers $$$x_1, x_2, \ldots, x_n$$$ ($$$0 \le x_i \le 9$$$) representing the sequence. The next line contains $$$m$$$ distinct space-separated integers $$$y_1, y_2, \ldots, y_m$$$ ($$$0 \le y_i \le 9$$$) β the keys with fingerprints. | f9044a4b4c3a0c2751217d9b31cd0c72 | #include<stdio.h>
#include<stdlib.h>
int main()
{
int n1,n2,a1[100],a2[100];
scanf("%d%d",&n1,&n2);
for(int i=0;i<n1;i++)
{
scanf("%d",&a1[i]);
}
for(int i=0;i<n2;i++)
{
scanf("%d",&a2[i]);
}
for(int i=0;i<n1;i++)
{
for(int j=0;j<n2;j++)
{
if(a1[i]==a2[j]) printf("%d ",a1[i]);
}
}
}
| ["7 1 2", "1 0"] | C | NoteIn the first example, the only digits with fingerprints are $$$1$$$, $$$2$$$ and $$$7$$$. All three of them appear in the sequence you know, $$$7$$$ first, then $$$1$$$ and then $$$2$$$. Therefore the output is 7 1 2. Note that the order is important, and shall be the same as the order in the original sequence.In the second example digits $$$0$$$, $$$1$$$, $$$7$$$ and $$$9$$$ have fingerprints, however only $$$0$$$ and $$$1$$$ appear in the original sequence. $$$1$$$ appears earlier, so the output is 1 0. Again, the order is important. | In a single line print a space-separated sequence of integers representing the code. If the resulting sequence is empty, both printing nothing and printing a single line break is acceptable. | You are locked in a room with a door that has a keypad with 10 keys corresponding to digits from 0 to 9. To escape from the room, you need to enter a correct code. You also have a sequence of digits.Some keys on the keypad have fingerprints. You believe the correct code is the longest not necessarily contiguous subsequence of the sequence you have that only contains digits with fingerprints on the corresponding keys. Find such code. | [{"input": "7 3\r\n3 5 7 1 6 2 8\r\n1 2 7\r\n", "output": ["7 1 2"]}, {"input": "4 4\r\n3 4 1 0\r\n0 1 7 9\r\n", "output": ["1 0"]}, {"input": "9 4\r\n9 8 7 6 5 4 3 2 1\r\n2 4 6 8\r\n", "output": ["8 6 4 2"]}, {"input": "10 5\r\n3 7 1 2 4 6 9 0 5 8\r\n4 3 0 7 9\r\n", "output": ["3 7 4 9 0"]}, {"input": "5 5\r\n1 2 3 4 5\r\n6 7 8 9 0\r\n", "output": [""]}, {"input": "10 10\r\n1 2 3 4 5 6 7 8 9 0\r\n4 5 6 7 1 2 3 0 9 8\r\n", "output": ["1 2 3 4 5 6 7 8 9 0"]}, {"input": "1 1\r\n4\r\n4\r\n", "output": ["4"]}, {"input": "3 7\r\n6 3 4\r\n4 9 0 1 7 8 6\r\n", "output": ["6 4"]}, {"input": "10 1\r\n9 0 8 1 7 4 6 5 2 3\r\n0\r\n", "output": ["0"]}, {"input": "6 1\r\n4 2 7 3 1 8\r\n9\r\n", "output": [""]}, {"input": "5 10\r\n6 0 3 8 1\r\n3 1 0 5 4 7 2 8 9 6\r\n", "output": ["6 0 3 8 1"]}, {"input": "8 2\r\n7 2 9 6 1 0 3 4\r\n6 3\r\n", "output": ["6 3"]}, {"input": "5 4\r\n7 0 1 4 9\r\n0 9 5 3\r\n", "output": ["0 9"]}, {"input": "10 1\r\n9 6 2 0 1 8 3 4 7 5\r\n6\r\n", "output": ["6"]}, {"input": "10 2\r\n7 1 0 2 4 6 5 9 3 8\r\n3 2\r\n", "output": ["2 3"]}, {"input": "5 9\r\n3 7 9 2 4\r\n3 8 4 5 9 6 1 0 2\r\n", "output": ["3 9 2 4"]}, {"input": "10 6\r\n7 1 2 3 8 0 6 4 5 9\r\n1 5 8 2 3 6\r\n", "output": ["1 2 3 8 6 5"]}, {"input": "8 2\r\n7 4 8 9 2 5 6 1\r\n6 4\r\n", "output": ["4 6"]}, {"input": "10 2\r\n1 0 3 5 8 9 4 7 6 2\r\n0 3\r\n", "output": ["0 3"]}, {"input": "7 6\r\n9 2 8 6 1 3 7\r\n4 2 0 3 1 8\r\n", "output": ["2 8 1 3"]}, {"input": "1 6\r\n3\r\n6 8 2 4 5 3\r\n", "output": ["3"]}, {"input": "1 8\r\n0\r\n9 2 4 8 1 5 0 7\r\n", "output": ["0"]}, {"input": "6 9\r\n7 3 9 4 1 0\r\n9 1 5 8 0 6 2 7 4\r\n", "output": ["7 9 4 1 0"]}, {"input": "10 2\r\n4 9 6 8 3 0 1 5 7 2\r\n0 1\r\n", "output": ["0 1"]}, {"input": "10 5\r\n5 2 8 0 9 7 6 1 4 3\r\n9 6 4 1 2\r\n", "output": ["2 9 6 1 4"]}, {"input": "6 3\r\n8 3 9 2 7 6\r\n5 4 3\r\n", "output": ["3"]}, {"input": "4 10\r\n8 3 9 6\r\n4 9 6 2 7 0 8 1 3 5\r\n", "output": ["8 3 9 6"]}, {"input": "1 2\r\n1\r\n1 0\r\n", "output": ["1"]}, {"input": "3 6\r\n1 2 3\r\n4 5 6 1 2 3\r\n", "output": ["1 2 3"]}, {"input": "1 2\r\n2\r\n1 2\r\n", "output": ["2"]}, {"input": "1 10\r\n9\r\n0 1 2 3 4 5 6 7 8 9\r\n", "output": ["9"]}] | 100 | 100 | 100 | [{'input': '4 10\r\n8 3 9 6\r\n4 9 6 2 7 0 8 1 3 5\r\n', 'output': ['8 3 9 6']}, {'input': '3 6\r\n1 2 3\r\n4 5 6 1 2 3\r\n', 'output': ['1 2 3']}, {'input': '5 10\r\n6 0 3 8 1\r\n3 1 0 5 4 7 2 8 9 6\r\n', 'output': ['6 0 3 8 1']}, {'input': '1 2\r\n2\r\n1 2\r\n', 'output': ['2']}, {'input': '8 2\r\n7 4 8 9 2 5 6 1\r\n6 4\r\n', 'output': ['4 6']}] | [{'input': '9 4\r\n9 8 7 6 5 4 3 2 1\r\n2 4 6 8\r\n', 'output': ['8 6 4 2']}, {'input': '10 1\r\n9 6 2 0 1 8 3 4 7 5\r\n6\r\n', 'output': ['6']}, {'input': '1 8\r\n0\r\n9 2 4 8 1 5 0 7\r\n', 'output': ['0']}, {'input': '10 5\r\n3 7 1 2 4 6 9 0 5 8\r\n4 3 0 7 9\r\n', 'output': ['3 7 4 9 0']}, {'input': '6 9\r\n7 3 9 4 1 0\r\n9 1 5 8 0 6 2 7 4\r\n', 'output': ['7 9 4 1 0']}] | [{'input': '1 6\r\n3\r\n6 8 2 4 5 3\r\n', 'output': ['3']}, {'input': '8 2\r\n7 2 9 6 1 0 3 4\r\n6 3\r\n', 'output': ['6 3']}, {'input': '7 3\r\n3 5 7 1 6 2 8\r\n1 2 7\r\n', 'output': ['7 1 2']}, {'input': '1 2\r\n1\r\n1 0\r\n', 'output': ['1']}, {'input': '3 6\r\n1 2 3\r\n4 5 6 1 2 3\r\n', 'output': ['1 2 3']}] | [{'input': '10 10\r\n1 2 3 4 5 6 7 8 9 0\r\n4 5 6 7 1 2 3 0 9 8\r\n', 'output': ['1 2 3 4 5 6 7 8 9 0']}, {'input': '5 10\r\n6 0 3 8 1\r\n3 1 0 5 4 7 2 8 9 6\r\n', 'output': ['6 0 3 8 1']}, {'input': '8 2\r\n7 4 8 9 2 5 6 1\r\n6 4\r\n', 'output': ['4 6']}, {'input': '8 2\r\n7 2 9 6 1 0 3 4\r\n6 3\r\n', 'output': ['6 3']}, {'input': '6 1\r\n4 2 7 3 1 8\r\n9\r\n', 'output': ['']}] | [{'input': '10 1\r\n9 0 8 1 7 4 6 5 2 3\r\n0\r\n', 'output': ['0']}, {'input': '5 5\r\n1 2 3 4 5\r\n6 7 8 9 0\r\n', 'output': ['']}, {'input': '7 6\r\n9 2 8 6 1 3 7\r\n4 2 0 3 1 8\r\n', 'output': ['2 8 1 3']}, {'input': '10 5\r\n3 7 1 2 4 6 9 0 5 8\r\n4 3 0 7 9\r\n', 'output': ['3 7 4 9 0']}, {'input': '6 3\r\n8 3 9 2 7 6\r\n5 4 3\r\n', 'output': ['3']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 75 | 100 | 100 | 100 |
["4\n1 1 0 1", "6\n0 1 0 0 1 0", "1\n0"] | The first line contains one integer number n (1ββ€βnββ€β100). The second line contains n space-separated integer numbers s1,βs2,β...,βsn (0ββ€βsiββ€β1). 0 corresponds to an unsuccessful game, 1 β to a successful one. | c7b1f0b40e310f99936d1c33e4816b95 | #include <stdio.h>
int countzeroes(int x, int s[])
{
int count=0;
for(int j=0;j<=x;j++){
if(s[j]==0)
count++;
}
return count;
}
int countones(int x, int s[])
{
int count=0;
for(int j=0;j<=x;j++){
if(s[j]==1)
count++;
}
return count;
}
int main(void) {
int n,i; //n is the total number of games.
scanf("%d",&n);
int s[n];
for(i=0;i<n;i++)
scanf("%d",&s[i]);
/*for(i=0;i<n;i++)
printf("%d",s[i]); */
int zeroes,ones;
zeroes=countzeroes(n-1,s);
ones=countones(n-1,s);
int zero[zeroes],x,y,counter=0;
for(i=0;i<n;i++){
if(s[i]==0){
x=countzeroes(i,s);
y=ones-countones(i,s);
//printf("%d %d %d\n",x,y,x+y);
zero[counter]=x+y;
counter++;
}
}
/*for(i=0;i<zeroes;i++)
printf("%d",zero[i]);
printf("\n");*/
int ans;
if(zeroes>ones)
ans=zeroes;
else
ans=ones;
//printf("ans is %d \n", ans);
for(i=0;i<zeroes;i++){
if(zero[i]>ans)
ans=zero[i];
}
printf("%d\n", ans);
return 0;
}
| ["3", "4", "1"] | C | null | Print one integer β the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one. | Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.During all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.More formally, you are given an array s1,βs2,β...,βsn of zeros and ones. Zero corresponds to an unsuccessful game, one β to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.Besides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV. | [{"input": "4\r\n1 1 0 1\r\n", "output": ["3"]}, {"input": "6\r\n0 1 0 0 1 0\r\n", "output": ["4"]}, {"input": "1\r\n0\r\n", "output": ["1"]}, {"input": "100\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n", "output": ["100"]}, {"input": "100\r\n0 0 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 1 1 0 0 1 0 1 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n", "output": ["80"]}, {"input": "1\r\n1\r\n", "output": ["1"]}, {"input": "100\r\n1 1 0 1 1 0 0 0 0 1 0 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 0 1 1 0 0 1 1 1 0 0 0 1 0 0 1 0 1 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 1 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 1 1 0 1 1 0 1 1 1 0 0 1 1 0 0 0 0 1\r\n", "output": ["53"]}, {"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": ["100"]}, {"input": "3\r\n1 0 0\r\n", "output": ["2"]}, {"input": "10\r\n1 1 0 0 0 1 1 0 0 0\r\n", "output": ["6"]}, {"input": "90\r\n1 0 0 1 1 0 0 1 0 0 0 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 0 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 0 1 0\r\n", "output": ["52"]}, {"input": "78\r\n0 0 1 0 1 0 1 1 0 0 0 1 1 1 1 0 0 0 1 0 1 1 1 0 1 0 0 0 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 0 1 1 1 0 0 1 0 0 0 0 1 0 1 0 0 1 0\r\n", "output": ["42"]}, {"input": "4\r\n1 0 0 1\r\n", "output": ["3"]}, {"input": "2\r\n0 1\r\n", "output": ["2"]}, {"input": "5\r\n0 1 0 0 1\r\n", "output": ["4"]}, {"input": "3\r\n1 0 1\r\n", "output": ["2"]}, {"input": "3\r\n1 1 0\r\n", "output": ["2"]}, {"input": "16\r\n1 1 1 1 1 0 0 0 0 0 1 0 1 0 0 1\r\n", "output": ["9"]}] | 100 | 100 | 100 | [{'input': '1\r\n1\r\n', 'output': ['1']}, {'input': '4\r\n1 1 0 1\r\n', 'output': ['3']}, {'input': '3\r\n1 0 1\r\n', 'output': ['2']}, {'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': ['100']}, {'input': '2\r\n0 1\r\n', 'output': ['2']}] | [{'input': '100\r\n1 1 0 1 1 0 0 0 0 1 0 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 0 1 1 0 0 1 1 1 0 0 0 1 0 0 1 0 1 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 1 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 1 1 0 1 1 0 1 1 1 0 0 1 1 0 0 0 0 1\r\n', 'output': ['53']}, {'input': '100\r\n0 0 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 1 1 0 0 1 0 1 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n', 'output': ['80']}, {'input': '78\r\n0 0 1 0 1 0 1 1 0 0 0 1 1 1 1 0 0 0 1 0 1 1 1 0 1 0 0 0 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 0 1 1 1 0 0 1 0 0 0 0 1 0 1 0 0 1 0\r\n', 'output': ['42']}, {'input': '10\r\n1 1 0 0 0 1 1 0 0 0\r\n', 'output': ['6']}, {'input': '3\r\n1 1 0\r\n', 'output': ['2']}] | [{'input': '100\r\n1 1 0 1 1 0 0 0 0 1 0 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 0 1 1 0 0 1 1 1 0 0 0 1 0 0 1 0 1 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 1 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 1 1 0 1 1 0 1 1 1 0 0 1 1 0 0 0 0 1\r\n', 'output': ['53']}, {'input': '6\r\n0 1 0 0 1 0\r\n', 'output': ['4']}, {'input': '3\r\n1 0 1\r\n', 'output': ['2']}, {'input': '2\r\n0 1\r\n', 'output': ['2']}, {'input': '4\r\n1 1 0 1\r\n', 'output': ['3']}] | [{'input': '90\r\n1 0 0 1 1 0 0 1 0 0 0 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 0 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 0 1 0\r\n', 'output': ['52']}, {'input': '100\r\n0 0 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 1 1 0 0 1 0 1 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n', 'output': ['80']}, {'input': '78\r\n0 0 1 0 1 0 1 1 0 0 0 1 1 1 1 0 0 0 1 0 1 1 1 0 1 0 0 0 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 0 1 1 1 0 0 1 0 0 0 0 1 0 1 0 0 1 0\r\n', 'output': ['42']}, {'input': '2\r\n0 1\r\n', 'output': ['2']}, {'input': '3\r\n1 1 0\r\n', 'output': ['2']}] | [{'input': '3\r\n1 1 0\r\n', 'output': ['2']}, {'input': '6\r\n0 1 0 0 1 0\r\n', 'output': ['4']}, {'input': '16\r\n1 1 1 1 1 0 0 0 0 0 1 0 1 0 0 1\r\n', 'output': ['9']}, {'input': '2\r\n0 1\r\n', 'output': ['2']}, {'input': '3\r\n1 0 0\r\n', 'output': ['2']}] | 100 | 100 | 100 | 100 | 100 | 97.06 | 100 | 100 | 100 | 100 | 95 | 100 | 100 | 100 | 100 | 76 | 100 | 99.412 | 99 |
["1", "3"] | The only line contains single integer: 1ββ€βnββ€β1000 β number of hassocks. | 4bd174a997707ed3a368bd0f2424590f | #include <stdio.h>
#include <stdlib.h>
//#include <string.h>
int main()
{
int n,i,j,f=0;
scanf("%d",&n);
int *a=(int *)calloc(n+1,sizeof(int));
a[1]=1;
j=1;
for(i=1;i<n;i++)
{
if((i+j)<=n)
{
a[i+j]=1;
j=j+i;
}
else
{
a[i+j-n]=1;
j=j+i-n;
}
// printf("j=%d\n",j);
}
for(i=1;i<=n;i++)
{
if(a[i]!=1)
{
f=1;
break;
}
}
if(f==1)
{
printf("NO");
}
else printf("YES");
}
| ["YES", "NO"] | C | null | Output "YES" if all the hassocks will be visited and "NO" otherwise. | A flea is sitting at one of the n hassocks, arranged in a circle, at the moment. After minute number k the flea jumps through kβ-β1 hassoΡks (clockwise). For example, after the first minute the flea jumps to the neighboring hassock. You should answer: will the flea visit all the hassocks or not. We assume that flea has infinitely much time for this jumping. | [{"input": "1\r\n", "output": ["YES"]}, {"input": "3\r\n", "output": ["NO"]}, {"input": "2\r\n", "output": ["YES"]}, {"input": "4\r\n", "output": ["YES"]}, {"input": "5\r\n", "output": ["NO"]}, {"input": "6\r\n", "output": ["NO"]}, {"input": "7\r\n", "output": ["NO"]}, {"input": "8\r\n", "output": ["YES"]}, {"input": "9\r\n", "output": ["NO"]}, {"input": "10\r\n", "output": ["NO"]}, {"input": "11\r\n", "output": ["NO"]}, {"input": "12\r\n", "output": ["NO"]}, {"input": "13\r\n", "output": ["NO"]}, {"input": "14\r\n", "output": ["NO"]}, {"input": "15\r\n", "output": ["NO"]}, {"input": "16\r\n", "output": ["YES"]}, {"input": "17\r\n", "output": ["NO"]}, {"input": "18\r\n", "output": ["NO"]}, {"input": "19\r\n", "output": ["NO"]}, {"input": "20\r\n", "output": ["NO"]}, {"input": "21\r\n", "output": ["NO"]}, {"input": "22\r\n", "output": ["NO"]}, {"input": "23\r\n", "output": ["NO"]}, {"input": "24\r\n", "output": ["NO"]}, {"input": "25\r\n", "output": ["NO"]}, {"input": "26\r\n", "output": ["NO"]}, {"input": "27\r\n", "output": ["NO"]}, {"input": "28\r\n", "output": ["NO"]}, {"input": "29\r\n", "output": ["NO"]}, {"input": "30\r\n", "output": ["NO"]}, {"input": "31\r\n", "output": ["NO"]}, {"input": "32\r\n", "output": ["YES"]}, {"input": "33\r\n", "output": ["NO"]}, {"input": "34\r\n", "output": ["NO"]}, {"input": "35\r\n", "output": ["NO"]}, {"input": "36\r\n", "output": ["NO"]}, {"input": "37\r\n", "output": ["NO"]}, {"input": "38\r\n", "output": ["NO"]}, {"input": "39\r\n", "output": ["NO"]}, {"input": "40\r\n", "output": ["NO"]}, {"input": "41\r\n", "output": ["NO"]}, {"input": "42\r\n", "output": ["NO"]}, {"input": "43\r\n", "output": ["NO"]}, {"input": "44\r\n", "output": ["NO"]}, {"input": "45\r\n", "output": ["NO"]}, {"input": "46\r\n", "output": ["NO"]}, {"input": "47\r\n", "output": ["NO"]}, {"input": "48\r\n", "output": ["NO"]}, {"input": "49\r\n", "output": ["NO"]}, {"input": "50\r\n", "output": ["NO"]}, {"input": "64\r\n", "output": ["YES"]}, {"input": "289\r\n", "output": ["NO"]}, {"input": "170\r\n", "output": ["NO"]}, {"input": "639\r\n", "output": ["NO"]}, {"input": "700\r\n", "output": ["NO"]}, {"input": "95\r\n", "output": ["NO"]}, {"input": "240\r\n", "output": ["NO"]}, {"input": "1000\r\n", "output": ["NO"]}, {"input": "200\r\n", "output": ["NO"]}, {"input": "57\r\n", "output": ["NO"]}, {"input": "871\r\n", "output": ["NO"]}, {"input": "840\r\n", "output": ["NO"]}, {"input": "705\r\n", "output": ["NO"]}, {"input": "685\r\n", "output": ["NO"]}, {"input": "213\r\n", "output": ["NO"]}, {"input": "665\r\n", "output": ["NO"]}, {"input": "868\r\n", "output": ["NO"]}, {"input": "897\r\n", "output": ["NO"]}, {"input": "61\r\n", "output": ["NO"]}, {"input": "817\r\n", "output": ["NO"]}, {"input": "688\r\n", "output": ["NO"]}, {"input": "580\r\n", "output": ["NO"]}, {"input": "373\r\n", "output": ["NO"]}, {"input": "613\r\n", "output": ["NO"]}, {"input": "685\r\n", "output": ["NO"]}, {"input": "116\r\n", "output": ["NO"]}, {"input": "518\r\n", "output": ["NO"]}, {"input": "383\r\n", "output": ["NO"]}, {"input": "260\r\n", "output": ["NO"]}, {"input": "728\r\n", "output": ["NO"]}, {"input": "1000\r\n", "output": ["NO"]}, {"input": "256\r\n", "output": ["YES"]}, {"input": "512\r\n", "output": ["YES"]}, {"input": "1\r\n", "output": ["YES"]}, {"input": "3\r\n", "output": ["NO"]}, {"input": "2\r\n", "output": ["YES"]}, {"input": "4\r\n", "output": ["YES"]}, {"input": "5\r\n", "output": ["NO"]}, {"input": "6\r\n", "output": ["NO"]}, {"input": "7\r\n", "output": ["NO"]}, {"input": "8\r\n", "output": ["YES"]}, {"input": "9\r\n", "output": ["NO"]}, {"input": "10\r\n", "output": ["NO"]}, {"input": "11\r\n", "output": ["NO"]}, {"input": "12\r\n", "output": ["NO"]}, {"input": "13\r\n", "output": ["NO"]}, {"input": "14\r\n", "output": ["NO"]}, {"input": "15\r\n", "output": ["NO"]}, {"input": "16\r\n", "output": ["YES"]}, {"input": "17\r\n", "output": ["NO"]}, {"input": "18\r\n", "output": ["NO"]}, {"input": "19\r\n", "output": ["NO"]}, {"input": "20\r\n", "output": ["NO"]}, {"input": "21\r\n", "output": ["NO"]}, {"input": "22\r\n", "output": ["NO"]}, {"input": "23\r\n", "output": ["NO"]}, {"input": "24\r\n", "output": ["NO"]}, {"input": "25\r\n", "output": ["NO"]}, {"input": "26\r\n", "output": ["NO"]}, {"input": "27\r\n", "output": ["NO"]}, {"input": "28\r\n", "output": ["NO"]}, {"input": "29\r\n", "output": ["NO"]}, {"input": "30\r\n", "output": ["NO"]}, {"input": "31\r\n", "output": ["NO"]}, {"input": "32\r\n", "output": ["YES"]}, {"input": "33\r\n", "output": ["NO"]}, {"input": "34\r\n", "output": ["NO"]}, {"input": "35\r\n", "output": ["NO"]}, {"input": "36\r\n", "output": ["NO"]}, {"input": "37\r\n", "output": ["NO"]}, {"input": "38\r\n", "output": ["NO"]}, {"input": "39\r\n", "output": ["NO"]}, {"input": "40\r\n", "output": ["NO"]}, {"input": "41\r\n", "output": ["NO"]}, {"input": "42\r\n", "output": ["NO"]}, {"input": "43\r\n", "output": ["NO"]}, {"input": "44\r\n", "output": ["NO"]}, {"input": "45\r\n", "output": ["NO"]}, {"input": "46\r\n", "output": ["NO"]}, {"input": "47\r\n", "output": ["NO"]}, {"input": "48\r\n", "output": ["NO"]}, {"input": "49\r\n", "output": ["NO"]}, {"input": "50\r\n", "output": ["NO"]}, {"input": "64\r\n", "output": ["YES"]}, {"input": "289\r\n", "output": ["NO"]}, {"input": "170\r\n", "output": ["NO"]}, {"input": "639\r\n", "output": ["NO"]}, {"input": "700\r\n", "output": ["NO"]}, {"input": "95\r\n", "output": ["NO"]}, {"input": "240\r\n", "output": ["NO"]}, {"input": "1000\r\n", "output": ["NO"]}, {"input": "200\r\n", "output": ["NO"]}, {"input": "57\r\n", "output": ["NO"]}, {"input": "871\r\n", "output": ["NO"]}, {"input": "840\r\n", "output": ["NO"]}, {"input": "705\r\n", "output": ["NO"]}, {"input": "685\r\n", "output": ["NO"]}, {"input": "213\r\n", "output": ["NO"]}, {"input": "665\r\n", "output": ["NO"]}, {"input": "868\r\n", "output": ["NO"]}, {"input": "897\r\n", "output": ["NO"]}, {"input": "61\r\n", "output": ["NO"]}, {"input": "817\r\n", "output": ["NO"]}, {"input": "688\r\n", "output": ["NO"]}, {"input": "580\r\n", "output": ["NO"]}, {"input": "373\r\n", "output": ["NO"]}, {"input": "613\r\n", "output": ["NO"]}, {"input": "116\r\n", "output": ["NO"]}, {"input": "518\r\n", "output": ["NO"]}, {"input": "383\r\n", "output": ["NO"]}, {"input": "260\r\n", "output": ["NO"]}, {"input": "728\r\n", "output": ["NO"]}, {"input": "256\r\n", "output": ["YES"]}, {"input": "512\r\n", "output": ["YES"]}] | 100 | 100 | 100 | [{'input': '27\r\n', 'output': ['NO']}, {'input': '32\r\n', 'output': ['YES']}, {'input': '3\r\n', 'output': ['NO']}, {'input': '14\r\n', 'output': ['NO']}, {'input': '41\r\n', 'output': ['NO']}] | [{'input': '840\r\n', 'output': ['NO']}, {'input': '37\r\n', 'output': ['NO']}, {'input': '29\r\n', 'output': ['NO']}, {'input': '116\r\n', 'output': ['NO']}, {'input': '13\r\n', 'output': ['NO']}] | [{'input': '45\r\n', 'output': ['NO']}, {'input': '12\r\n', 'output': ['NO']}, {'input': '25\r\n', 'output': ['NO']}, {'input': '897\r\n', 'output': ['NO']}, {'input': '665\r\n', 'output': ['NO']}] | [{'input': '613\r\n', 'output': ['NO']}, {'input': '373\r\n', 'output': ['NO']}, {'input': '23\r\n', 'output': ['NO']}, {'input': '19\r\n', 'output': ['NO']}, {'input': '170\r\n', 'output': ['NO']}] | [{'input': '24\r\n', 'output': ['NO']}, {'input': '44\r\n', 'output': ['NO']}, {'input': '42\r\n', 'output': ['NO']}, {'input': '383\r\n', 'output': ['NO']}, {'input': '15\r\n', 'output': ['NO']}] | 100 | 100 | 100 | 100 | 100 | 100 | 94.74 | 94.74 | 94.74 | 94.74 | 100 | 80 | 80 | 80 | 80 | 77 | 100 | 95.792 | 84 |
["5 4 3", "1 1 1", "2 3 3"] | The single line contains three integers r, g and b (0ββ€βr,βg,βbββ€β2Β·109) β the number of red, green and blue baloons respectively. The numbers are separated by exactly one space. | bae7cbcde19114451b8712d6361d2b01 | #include <stdio.h>
int main(void)
{
int r, g, bb;
long long int a, b, c;
for (;;) {
if (scanf(" %d %d %d", &r, &g, &bb) != 3)
return 0;
if (r >= g && r >= bb) {
a = r;
if (g >= bb) {
b = g;
c = bb;
} else {
b = bb;
c = g;
}
} else if (g >= bb) {
a = g;
if (r >= bb) {
b = r;
c = bb;
} else {
b = bb;
c = r;
}
} else {
a = bb;
if (r >= g) {
b = r;
c = g;
} else {
b = g;
c = r;
}
}
if (a >= ((b + c) * 2)) {
printf("%ld\n", (long int)(b+c));
} else {
printf("%ld\n", (long int)( c + ((a - c) + (b - c)) / 3) );
}
}
return 0;
} | ["4", "1", "2"] | C | NoteIn the first sample you can decorate the tables with the following balloon sets: "rgg", "gbb", "brr", "rrg", where "r", "g" and "b" represent the red, green and blue balls, respectively. | Print a single integer t β the maximum number of tables that can be decorated in the required manner. | You have r red, g green and b blue balloons. To decorate a single table for the banquet you need exactly three balloons. Three balloons attached to some table shouldn't have the same color. What maximum number t of tables can be decorated if we know number of balloons of each color?Your task is to write a program that for given values r, g and b will find the maximum number t of tables, that can be decorated in the required manner. | [{"input": "5 4 3\r\n", "output": ["4"]}, {"input": "1 1 1\r\n", "output": ["1"]}, {"input": "2 3 3\r\n", "output": ["2"]}, {"input": "0 1 0\r\n", "output": ["0"]}, {"input": "0 3 3\r\n", "output": ["2"]}, {"input": "4 0 4\r\n", "output": ["2"]}, {"input": "1000000000 1000000000 1000000000\r\n", "output": ["1000000000"]}, {"input": "100 99 56\r\n", "output": ["85"]}, {"input": "1000 1000 1002\r\n", "output": ["1000"]}, {"input": "0 1 1000000000\r\n", "output": ["1"]}, {"input": "500000000 1000000000 500000000\r\n", "output": ["666666666"]}, {"input": "1000000000 2000000000 1000000000\r\n", "output": ["1333333333"]}, {"input": "2000000000 2000000000 2000000000\r\n", "output": ["2000000000"]}, {"input": "0 0 0\r\n", "output": ["0"]}, {"input": "1 2000000000 1000000000\r\n", "output": ["1000000000"]}, {"input": "1585222789 1889821127 2000000000\r\n", "output": ["1825014638"]}, {"input": "10000 7500 7500\r\n", "output": ["8333"]}, {"input": "150000 75000 75000\r\n", "output": ["100000"]}, {"input": "999288131 55884921 109298382\r\n", "output": ["165183303"]}, {"input": "100500 100500 3\r\n", "output": ["67001"]}, {"input": "1463615122 1988383731 837331500\r\n", "output": ["1429776784"]}, {"input": "1938 8999 1882\r\n", "output": ["3820"]}, {"input": "45 33 76\r\n", "output": ["51"]}, {"input": "100000 1 2\r\n", "output": ["3"]}, {"input": "198488 50 18\r\n", "output": ["68"]}, {"input": "82728372 939848 100139442\r\n", "output": ["61269220"]}, {"input": "99 5747 5298\r\n", "output": ["3714"]}, {"input": "3 5 2\r\n", "output": ["3"]}, {"input": "7511 7512 7513\r\n", "output": ["7512"]}, {"input": "1234567890 123456789 987654321\r\n", "output": ["781893000"]}, {"input": "500000000 2000000000 500000000\r\n", "output": ["1000000000"]}, {"input": "500000002 2000000000 500000001\r\n", "output": ["1000000001"]}, {"input": "520000000 1000000033 501000000\r\n", "output": ["673666677"]}, {"input": "10000 1000 100000\r\n", "output": ["11000"]}, {"input": "2000000000 500000000 499999999\r\n", "output": ["999999999"]}, {"input": "1999999999 500000000 500000000\r\n", "output": ["999999999"]}, {"input": "1 1 9\r\n", "output": ["2"]}, {"input": "3 0 0\r\n", "output": ["0"]}, {"input": "6 1 1\r\n", "output": ["2"]}, {"input": "2000000000 1999999999 1999999999\r\n", "output": ["1999999999"]}, {"input": "3 4 9\r\n", "output": ["5"]}, {"input": "3 3 6\r\n", "output": ["4"]}] | 100 | 100 | 100 | [{'input': '500000000 1000000000 500000000\r\n', 'output': ['666666666']}, {'input': '1234567890 123456789 987654321\r\n', 'output': ['781893000']}, {'input': '100500 100500 3\r\n', 'output': ['67001']}, {'input': '999288131 55884921 109298382\r\n', 'output': ['165183303']}, {'input': '0 1 0\r\n', 'output': ['0']}] | [{'input': '6 1 1\r\n', 'output': ['2']}, {'input': '3 5 2\r\n', 'output': ['3']}, {'input': '1 1 1\r\n', 'output': ['1']}, {'input': '0 1 1000000000\r\n', 'output': ['1']}, {'input': '1 2000000000 1000000000\r\n', 'output': ['1000000000']}] | [{'input': '999288131 55884921 109298382\r\n', 'output': ['165183303']}, {'input': '82728372 939848 100139442\r\n', 'output': ['61269220']}, {'input': '520000000 1000000033 501000000\r\n', 'output': ['673666677']}, {'input': '3 0 0\r\n', 'output': ['0']}, {'input': '1000000000 2000000000 1000000000\r\n', 'output': ['1333333333']}] | [{'input': '2000000000 500000000 499999999\r\n', 'output': ['999999999']}, {'input': '150000 75000 75000\r\n', 'output': ['100000']}, {'input': '1000000000 2000000000 1000000000\r\n', 'output': ['1333333333']}, {'input': '2000000000 2000000000 2000000000\r\n', 'output': ['2000000000']}, {'input': '82728372 939848 100139442\r\n', 'output': ['61269220']}] | [{'input': '0 0 0\r\n', 'output': ['0']}, {'input': '1 2000000000 1000000000\r\n', 'output': ['1000000000']}, {'input': '1000 1000 1002\r\n', 'output': ['1000']}, {'input': '520000000 1000000033 501000000\r\n', 'output': ['673666677']}, {'input': '1585222789 1889821127 2000000000\r\n', 'output': ['1825014638']}] | 100 | 100 | 100 | 100 | 100 | 69.23 | 84.62 | 84.62 | 76.92 | 92.31 | 68.75 | 81.25 | 87.5 | 81.25 | 93.75 | 78 | 100 | 81.54 | 82.5 |
["5 5 3 2", "7 5 5 2"] | The first line contains four space-separated integers n, a, b and c (1ββ€βn,βa,βb,βcββ€β4000) β the length of the original ribbon and the acceptable lengths of the ribbon pieces after the cutting, correspondingly. The numbers a, b and c can coincide. | 062a171cc3ea717ea95ede9d7a1c3a43 | #include <stdio.h>
int main()
{
int n,a[3],i;
scanf("%d %d %d %d",&n,&a[0],&a[1],&a[2]);
int dp[n];
for(i=0;i<n;i++){dp[i] = -1;}
int j,c;
for(i=0;i<3;i++)
{
j = 1;
while(a[i]*j <= n)
{
if(dp[a[i]*j - 1]==(-1)){dp[a[i]*j - 1] = j;}
for(c=0;c<n;c++)
{
if(dp[c]!=(-1) && c+a[i]*j < n)
{ if(dp[c + a[i]*j] < dp[c] + j)
{dp[c + a[i]*j] = dp[c] + j;}}
}
j++;
}
}
printf("%d",dp[n-1]);
return 0;
} | ["2", "2"] | C | NoteIn the first example Polycarpus can cut the ribbon in such way: the first piece has length 2, the second piece has length 3.In the second example Polycarpus can cut the ribbon in such way: the first piece has length 5, the second piece has length 2. | Print a single number β the maximum possible number of ribbon pieces. It is guaranteed that at least one correct ribbon cutting exists. | Polycarpus has a ribbon, its length is n. He wants to cut the ribbon in a way that fulfils the following two conditions: After the cutting each ribbon piece should have length a, b or c. After the cutting the number of ribbon pieces should be maximum. Help Polycarpus and find the number of ribbon pieces after the required cutting. | [{"input": "5 5 3 2\r\n", "output": ["2"]}, {"input": "7 5 5 2\r\n", "output": ["2"]}, {"input": "4 4 4 4\r\n", "output": ["1"]}, {"input": "1 1 1 1\r\n", "output": ["1"]}, {"input": "4000 1 2 3\r\n", "output": ["4000"]}, {"input": "4000 3 4 5\r\n", "output": ["1333"]}, {"input": "10 3 4 5\r\n", "output": ["3"]}, {"input": "100 23 15 50\r\n", "output": ["2"]}, {"input": "3119 3515 1021 7\r\n", "output": ["11"]}, {"input": "918 102 1327 1733\r\n", "output": ["9"]}, {"input": "3164 42 430 1309\r\n", "output": ["15"]}, {"input": "3043 317 1141 2438\r\n", "output": ["7"]}, {"input": "26 1 772 2683\r\n", "output": ["26"]}, {"input": "370 2 1 15\r\n", "output": ["370"]}, {"input": "734 12 6 2\r\n", "output": ["367"]}, {"input": "418 18 14 17\r\n", "output": ["29"]}, {"input": "18 16 28 9\r\n", "output": ["2"]}, {"input": "14 6 2 17\r\n", "output": ["7"]}, {"input": "29 27 18 2\r\n", "output": ["2"]}, {"input": "29 12 7 10\r\n", "output": ["3"]}, {"input": "27 23 4 3\r\n", "output": ["9"]}, {"input": "5 14 5 2\r\n", "output": ["1"]}, {"input": "5 17 26 5\r\n", "output": ["1"]}, {"input": "9 1 10 3\r\n", "output": ["9"]}, {"input": "2 19 15 1\r\n", "output": ["2"]}, {"input": "4 6 4 9\r\n", "output": ["1"]}, {"input": "10 6 2 9\r\n", "output": ["5"]}, {"input": "2 2 9 6\r\n", "output": ["1"]}, {"input": "6 2 4 1\r\n", "output": ["6"]}, {"input": "27 24 5 27\r\n", "output": ["1"]}, {"input": "2683 83 26 2709\r\n", "output": ["101"]}, {"input": "728 412 789 158\r\n", "output": ["3"]}, {"input": "3964 4 2916 176\r\n", "output": ["991"]}, {"input": "3399 2035 2 3334\r\n", "output": ["683"]}, {"input": "3455 244 3301 3\r\n", "output": ["991"]}, {"input": "595 2263 3625 1\r\n", "output": ["595"]}, {"input": "4000 1 1 1\r\n", "output": ["4000"]}, {"input": "3999 2 2 3999\r\n", "output": ["1"]}, {"input": "25 6 8 11\r\n", "output": ["3"]}, {"input": "4000 500 1000 2000\r\n", "output": ["8"]}, {"input": "53 10 11 23\r\n", "output": ["5"]}, {"input": "100 100 1 1\r\n", "output": ["100"]}, {"input": "17 3 4 10\r\n", "output": ["5"]}, {"input": "413 101 102 105\r\n", "output": ["4"]}, {"input": "490 4 49 50\r\n", "output": ["111"]}, {"input": "3999 2 3 3\r\n", "output": ["1999"]}, {"input": "8 3 8 4\r\n", "output": ["2"]}, {"input": "5 1 3 3\r\n", "output": ["5"]}, {"input": "100 3 17 22\r\n", "output": ["27"]}, {"input": "4000 2 3 4\r\n", "output": ["2000"]}, {"input": "4000 3 3 5\r\n", "output": ["1332"]}, {"input": "13 4 6 7\r\n", "output": ["2"]}, {"input": "4000 5 2 2\r\n", "output": ["2000"]}, {"input": "3999 2 2 3\r\n", "output": ["1999"]}, {"input": "4000 33 7 3333\r\n", "output": ["564"]}, {"input": "60 33 20 9\r\n", "output": ["4"]}, {"input": "100 9 11 99\r\n", "output": ["10"]}, {"input": "2009 6 8 9\r\n", "output": ["334"]}] | 100 | 100 | 100 | [{'input': '6 2 4 1\r\n', 'output': ['6']}, {'input': '3999 2 2 3\r\n', 'output': ['1999']}, {'input': '3964 4 2916 176\r\n', 'output': ['991']}, {'input': '8 3 8 4\r\n', 'output': ['2']}, {'input': '100 100 1 1\r\n', 'output': ['100']}] | [{'input': '734 12 6 2\r\n', 'output': ['367']}, {'input': '6 2 4 1\r\n', 'output': ['6']}, {'input': '14 6 2 17\r\n', 'output': ['7']}, {'input': '100 23 15 50\r\n', 'output': ['2']}, {'input': '4000 33 7 3333\r\n', 'output': ['564']}] | [{'input': '4000 5 2 2\r\n', 'output': ['2000']}, {'input': '5 5 3 2\r\n', 'output': ['2']}, {'input': '3399 2035 2 3334\r\n', 'output': ['683']}, {'input': '728 412 789 158\r\n', 'output': ['3']}, {'input': '3119 3515 1021 7\r\n', 'output': ['11']}] | [{'input': '3043 317 1141 2438\r\n', 'output': ['7']}, {'input': '10 6 2 9\r\n', 'output': ['5']}, {'input': '4000 2 3 4\r\n', 'output': ['2000']}, {'input': '3999 2 2 3\r\n', 'output': ['1999']}, {'input': '25 6 8 11\r\n', 'output': ['3']}] | [{'input': '3399 2035 2 3334\r\n', 'output': ['683']}, {'input': '9 1 10 3\r\n', 'output': ['9']}, {'input': '3999 2 3 3\r\n', 'output': ['1999']}, {'input': '100 3 17 22\r\n', 'output': ['27']}, {'input': '918 102 1327 1733\r\n', 'output': ['9']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 79 | 100 | 100 | 100 |
["6", "20"] | The first line of the input contains a positive integer n (1ββ€βnββ€β2Β·109) β the length of Pasha's stick. | 32b59d23f71800bc29da74a3fe2e2b37 | #include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(void)
{
long int n;
scanf("%ld",&n);
if(n<=3)
printf("0");
else
{
if(n%2==0)
{
n=n/2;
if(n%2==0)
printf("%d",(n-2)/2);
else
printf("%d",(n-1)/2);
}
else
printf("0");
}
}
| ["1", "4"] | C | NoteThere is only one way to divide the stick in the first sample {1, 1, 2, 2}.Four ways to divide the stick in the second sample are {1, 1, 9, 9}, {2, 2, 8, 8}, {3, 3, 7, 7} and {4, 4, 6, 6}. Note that {5, 5, 5, 5} doesn't work. | The output should contain a single integerΒ β the number of ways to split Pasha's stick into four parts of positive integer length so that it's possible to make a rectangle by connecting the ends of these parts, but is impossible to form a square. | Pasha has a wooden stick of some positive integer length n. He wants to perform exactly three cuts to get four parts of the stick. Each part must have some positive integer length and the sum of these lengths will obviously be n. Pasha likes rectangles but hates squares, so he wonders, how many ways are there to split a stick into four parts so that it's possible to form a rectangle using these parts, but is impossible to form a square.Your task is to help Pasha and count the number of such ways. Two ways to cut the stick are considered distinct if there exists some integer x, such that the number of parts of length x in the first way differ from the number of parts of length x in the second way. | [{"input": "6\r\n", "output": ["1"]}, {"input": "20\r\n", "output": ["4"]}, {"input": "1\r\n", "output": ["0"]}, {"input": "2\r\n", "output": ["0"]}, {"input": "3\r\n", "output": ["0"]}, {"input": "4\r\n", "output": ["0"]}, {"input": "2000000000\r\n", "output": ["499999999"]}, {"input": "1924704072\r\n", "output": ["481176017"]}, {"input": "73740586\r\n", "output": ["18435146"]}, {"input": "1925088820\r\n", "output": ["481272204"]}, {"input": "593070992\r\n", "output": ["148267747"]}, {"input": "1925473570\r\n", "output": ["481368392"]}, {"input": "629490186\r\n", "output": ["157372546"]}, {"input": "1980649112\r\n", "output": ["495162277"]}, {"input": "36661322\r\n", "output": ["9165330"]}, {"input": "1943590793\r\n", "output": ["0"]}, {"input": "71207034\r\n", "output": ["17801758"]}, {"input": "1757577394\r\n", "output": ["439394348"]}, {"input": "168305294\r\n", "output": ["42076323"]}, {"input": "1934896224\r\n", "output": ["483724055"]}, {"input": "297149088\r\n", "output": ["74287271"]}, {"input": "1898001634\r\n", "output": ["474500408"]}, {"input": "176409698\r\n", "output": ["44102424"]}, {"input": "1873025522\r\n", "output": ["468256380"]}, {"input": "5714762\r\n", "output": ["1428690"]}, {"input": "1829551192\r\n", "output": ["457387797"]}, {"input": "16269438\r\n", "output": ["4067359"]}, {"input": "1663283390\r\n", "output": ["415820847"]}, {"input": "42549941\r\n", "output": ["0"]}, {"input": "1967345604\r\n", "output": ["491836400"]}, {"input": "854000\r\n", "output": ["213499"]}, {"input": "1995886626\r\n", "output": ["498971656"]}, {"input": "10330019\r\n", "output": ["0"]}, {"input": "1996193634\r\n", "output": ["499048408"]}, {"input": "9605180\r\n", "output": ["2401294"]}, {"input": "1996459740\r\n", "output": ["499114934"]}, {"input": "32691948\r\n", "output": ["8172986"]}, {"input": "1975903308\r\n", "output": ["493975826"]}, {"input": "1976637136\r\n", "output": ["494159283"]}, {"input": "29803038\r\n", "output": ["7450759"]}, {"input": "1977979692\r\n", "output": ["494494922"]}, {"input": "1978595336\r\n", "output": ["494648833"]}, {"input": "27379344\r\n", "output": ["6844835"]}, {"input": "1979729912\r\n", "output": ["494932477"]}, {"input": "1980253780\r\n", "output": ["495063444"]}, {"input": "1980751584\r\n", "output": ["495187895"]}, {"input": "53224878\r\n", "output": ["13306219"]}, {"input": "5\r\n", "output": ["0"]}, {"input": "7\r\n", "output": ["0"]}, {"input": "8\r\n", "output": ["1"]}, {"input": "9\r\n", "output": ["0"]}, {"input": "10\r\n", "output": ["2"]}, {"input": "11\r\n", "output": ["0"]}, {"input": "12\r\n", "output": ["2"]}, {"input": "13\r\n", "output": ["0"]}, {"input": "14\r\n", "output": ["3"]}, {"input": "15\r\n", "output": ["0"]}, {"input": "16\r\n", "output": ["3"]}, {"input": "17\r\n", "output": ["0"]}, {"input": "18\r\n", "output": ["4"]}, {"input": "19\r\n", "output": ["0"]}, {"input": "21\r\n", "output": ["0"]}, {"input": "22\r\n", "output": ["5"]}, {"input": "23\r\n", "output": ["0"]}, {"input": "24\r\n", "output": ["5"]}, {"input": "25\r\n", "output": ["0"]}, {"input": "26\r\n", "output": ["6"]}, {"input": "27\r\n", "output": ["0"]}, {"input": "28\r\n", "output": ["6"]}, {"input": "29\r\n", "output": ["0"]}, {"input": "30\r\n", "output": ["7"]}, {"input": "111\r\n", "output": ["0"]}, {"input": "55\r\n", "output": ["0"]}, {"input": "105\r\n", "output": ["0"]}, {"input": "199\r\n", "output": ["0"]}, {"input": "151\r\n", "output": ["0"]}] | 100 | 100 | 100 | [{'input': '1873025522\r\n', 'output': ['468256380']}, {'input': '27379344\r\n', 'output': ['6844835']}, {'input': '25\r\n', 'output': ['0']}, {'input': '593070992\r\n', 'output': ['148267747']}, {'input': '1925088820\r\n', 'output': ['481272204']}] | [{'input': '17\r\n', 'output': ['0']}, {'input': '854000\r\n', 'output': ['213499']}, {'input': '111\r\n', 'output': ['0']}, {'input': '2\r\n', 'output': ['0']}, {'input': '27\r\n', 'output': ['0']}] | [{'input': '30\r\n', 'output': ['7']}, {'input': '1980253780\r\n', 'output': ['495063444']}, {'input': '27\r\n', 'output': ['0']}, {'input': '176409698\r\n', 'output': ['44102424']}, {'input': '10330019\r\n', 'output': ['0']}] | [{'input': '14\r\n', 'output': ['3']}, {'input': '151\r\n', 'output': ['0']}, {'input': '42549941\r\n', 'output': ['0']}, {'input': '168305294\r\n', 'output': ['42076323']}, {'input': '1996459740\r\n', 'output': ['499114934']}] | [{'input': '10330019\r\n', 'output': ['0']}, {'input': '22\r\n', 'output': ['5']}, {'input': '25\r\n', 'output': ['0']}, {'input': '168305294\r\n', 'output': ['42076323']}, {'input': '1925473570\r\n', 'output': ['481368392']}] | 100 | 100 | 100 | 100 | 100 | 90 | 90 | 90 | 90 | 80 | 83.33 | 83.33 | 83.33 | 83.33 | 66.67 | 80 | 100 | 88 | 79.998 |
["1 0.50 1", "1 0.50 4", "4 0.20 2"] | The first line of the input contains three numbers n,βp,βt (1ββ€βn,βtββ€β2000, 0ββ€βpββ€β1). Numbers n and t are integers, number p is real, given with exactly two digits after the decimal point. | 20873b1e802c7aa0e409d9f430516c1e | #include<stdio.h>
double prob[2005][2005];
int main()
{
int n,t,i,j;
double p,cp;
double tmp;
scanf("%d",&n);
scanf("%lf",&p);
scanf("%d",&t);
cp = 1.0-p;
prob[0][0] = 1.0;
for(i=1;i<=t;i++)
prob[0][i] = 0.0;
for(i=1;i<=t;i++)
prob[i][0] = prob[i-1][0]*(cp);
for(i=1;i<=t;i++)
{
for(j=1;j<=t;j++)
{
if(j>i||j>n)
tmp = 0.0;
else if(j+1<=n)
tmp = cp*prob[i-1][j] + prob[i-1][j-1]*p;
else
tmp = prob[i-1][j] + prob[i-1][j-1]*p;
prob[i][j] = tmp;
}
}
double res = 0;
for(i=0;i<=t;i++)
{
res+=i*prob[t][i];
}
printf("%lf\n",res);
return 0;
} | ["0.5", "0.9375", "0.4"] | C | null | Print a single real number β the expected number of people who will be standing on the escalator after t seconds. The absolute or relative error mustn't exceed 10β-β6. | Ilya got tired of sports programming, left university and got a job in the subway. He was given the task to determine the escalator load factor. Let's assume that n people stand in the queue for the escalator. At each second one of the two following possibilities takes place: either the first person in the queue enters the escalator with probability p, or the first person in the queue doesn't move with probability (1β-βp), paralyzed by his fear of escalators and making the whole queue wait behind him.Formally speaking, the i-th person in the queue cannot enter the escalator until people with indices from 1 to iβ-β1 inclusive enter it. In one second only one person can enter the escalator. The escalator is infinite, so if a person enters it, he never leaves it, that is he will be standing on the escalator at any following second. Ilya needs to count the expected value of the number of people standing on the escalator after t seconds. Your task is to help him solve this complicated task. | [{"input": "1 0.50 1\r\n", "output": ["0.500000", "0.5000000", "0.5", "0.500000000000", "0.50000000000000000000"]}, {"input": "1 0.50 4\r\n", "output": ["0.9375", "0.9375000", "0.937500000000", "0.937500", "0.93750000000000000000"]}, {"input": "4 0.20 2\r\n", "output": ["0.4", "0.400000", "0.40000000000000002220", "0.400000000000", "0.4000000"]}, {"input": "2000 0.61 2000\r\n", "output": ["1220.000000000000", "1220", "1219.99999999999977262632", "1220.000000", "1220.0000000", "1220.0"]}, {"input": "100 1.00 200\r\n", "output": ["100.00000000000000000000", "100.0000000", "100.0", "100.000000", "100.000000000000", "100"]}, {"input": "417 0.57 742\r\n", "output": ["414.0744421", "414.07444214206202559581", "414.074442142062", "414.074442142", "414.074442", "414.0744"]}, {"input": "100 0.01 53\r\n", "output": ["0.53000000000000002665", "0.530000", "0.53", "0.530000000000", "0.5300000"]}, {"input": "300 0.05 55\r\n", "output": ["2.750000000000", "2.75000000000000044409", "2.75", "2.7500000", "2.750000"]}, {"input": "1400 0.02 200\r\n", "output": ["4.00000000000000000000", "4.000000000000", "4.0000000", "4", "4.0", "4.000000"]}, {"input": "2000 0.01 234\r\n", "output": ["2.34", "2.340000", "2.340000000000", "2.33999999999999985789", "2.3400000"]}, {"input": "1 0.01 2000\r\n", "output": ["1", "0.999999998136", "1.0000000", "1.000000", "0.99999999813624351752", "0.9999999981"]}, {"input": "300 0.99 1000\r\n", "output": ["300.000000000000", "300", "300.000000", "300.0000000", "300.0", "300.00000000000005684342"]}, {"input": "400 0.96 1754\r\n", "output": ["400.000000000000", "400.0000000", "400.00000000000000000000", "400", "400.0", "400.000000"]}, {"input": "2000 0.93 100\r\n", "output": ["93.000000", "93.0", "93.0000000", "93", "93.000000000000", "92.99999999999998578915"]}, {"input": "1000 0.90 1733\r\n", "output": ["999.99999999999988631316", "1000.0000000", "1000.000000", "1000.000000000000", "1000", "1000.0"]}, {"input": "1 1.00 1\r\n", "output": ["1", "1.000000000000", "1.0000000", "1.000000", "1.0", "1.00000000000000000000"]}, {"input": "2000 1.00 2000\r\n", "output": ["2000", "2000.0000000", "2000.00000000000000000000", "2000.000000", "2000.0", "2000.000000000000"]}, {"input": "2000 0.00 2000\r\n", "output": ["0.000000000000", "0", "0.0000000", "0.00000000000000000000", "0.0", "0.000000"]}, {"input": "2000 0.01 2000\r\n", "output": ["20.00000000000000000000", "20.000000000000", "20.000000", "20.0", "20.0000000", "20"]}, {"input": "2000 0.99 2000\r\n", "output": ["1980.0", "1980", "1980.0000000", "1980.00000000000000000000", "1980.000000", "1980.000000000000"]}, {"input": "654 0.67 999\r\n", "output": ["652.82192512620599700313", "652.821925126", "652.8219251", "652.8219", "652.821925", "652.821925126206"]}, {"input": "132 0.34 241\r\n", "output": ["81.940000", "81.94", "81.939999999978", "81.9400000", "81.93999999997761563009"]}, {"input": "984 0.19 1565\r\n", "output": ["297.350000000000", "297.34999999999996589395", "297.3500000", "297.350000", "297.35"]}, {"input": "439 0.83 790\r\n", "output": ["439.00000000000005684342", "439", "439.000000000000", "439.0", "439.000000", "439.0000000"]}, {"input": "559 0.92 1006\r\n", "output": ["559", "559.0", "559.000000000000", "559.0000000", "559.000000", "559.00000000000000000000"]}, {"input": "887 0.69 1596\r\n", "output": ["886.99999999999988631316", "886.999999999999", "887.0000000", "887", "887.000000", "887.0"]}, {"input": "211 0.78 379\r\n", "output": ["211.0000000", "211.000000000000", "211.00000000000000000000", "211", "211.000000", "211.0"]}, {"input": "539 0.54 970\r\n", "output": ["522.4592966", "522.45929661603338445275", "522.459296616034", "522.4593", "522.459297", "522.459296616"]}, {"input": "659 0.97 1186\r\n", "output": ["659.0000000", "659.00000000000034106051", "659.000000000000", "659.000000", "659.0", "659"]}, {"input": "87 0.95 156\r\n", "output": ["87.0000000", "87.0", "87.000000000000", "87.000000", "87", "86.99999999999998578915"]}, {"input": "415 0.72 747\r\n", "output": ["415.000000", "415", "415.0", "415.000000000000", "414.99999999999977262632", "415.0000000"]}, {"input": "639 0.81 1150\r\n", "output": ["639.00000000000011368684", "639.000000", "639", "639.0", "639.000000000000", "639.0000000"]}, {"input": "818 0.99 1472\r\n", "output": ["818.000000000000", "818.000000", "818", "818.0", "818.00000000000022737368", "818.0000000"]}, {"input": "246 0.98 442\r\n", "output": ["246", "246.000000", "246.0", "246.00000000000000000000", "246.000000000000", "246.0000000"]}, {"input": "470 0.74 846\r\n", "output": ["470.00000000000011368684", "470.000000", "470.0", "470.0000000", "470", "470.000000000000"]}] | 100 | 100 | 100 | [{'input': '100 1.00 200\r\n', 'output': ['100.00000000000000000000', '100.0000000', '100.0', '100.000000', '100.000000000000', '100']}, {'input': '818 0.99 1472\r\n', 'output': ['818.000000000000', '818.000000', '818', '818.0', '818.00000000000022737368', '818.0000000']}, {'input': '415 0.72 747\r\n', 'output': ['415.000000', '415', '415.0', '415.000000000000', '414.99999999999977262632', '415.0000000']}, {'input': '2000 0.00 2000\r\n', 'output': ['0.000000000000', '0', '0.0000000', '0.00000000000000000000', '0.0', '0.000000']}, {'input': '1 0.01 2000\r\n', 'output': ['1', '0.999999998136', '1.0000000', '1.000000', '0.99999999813624351752', '0.9999999981']}] | [{'input': '1400 0.02 200\r\n', 'output': ['4.00000000000000000000', '4.000000000000', '4.0000000', '4', '4.0', '4.000000']}, {'input': '211 0.78 379\r\n', 'output': ['211.0000000', '211.000000000000', '211.00000000000000000000', '211', '211.000000', '211.0']}, {'input': '246 0.98 442\r\n', 'output': ['246', '246.000000', '246.0', '246.00000000000000000000', '246.000000000000', '246.0000000']}, {'input': '1 0.50 4\r\n', 'output': ['0.9375', '0.9375000', '0.937500000000', '0.937500', '0.93750000000000000000']}, {'input': '2000 0.00 2000\r\n', 'output': ['0.000000000000', '0', '0.0000000', '0.00000000000000000000', '0.0', '0.000000']}] | [{'input': '439 0.83 790\r\n', 'output': ['439.00000000000005684342', '439', '439.000000000000', '439.0', '439.000000', '439.0000000']}, {'input': '539 0.54 970\r\n', 'output': ['522.4592966', '522.45929661603338445275', '522.459296616034', '522.4593', '522.459297', '522.459296616']}, {'input': '984 0.19 1565\r\n', 'output': ['297.350000000000', '297.34999999999996589395', '297.3500000', '297.350000', '297.35']}, {'input': '400 0.96 1754\r\n', 'output': ['400.000000000000', '400.0000000', '400.00000000000000000000', '400', '400.0', '400.000000']}, {'input': '2000 0.00 2000\r\n', 'output': ['0.000000000000', '0', '0.0000000', '0.00000000000000000000', '0.0', '0.000000']}] | [{'input': '1400 0.02 200\r\n', 'output': ['4.00000000000000000000', '4.000000000000', '4.0000000', '4', '4.0', '4.000000']}, {'input': '2000 0.00 2000\r\n', 'output': ['0.000000000000', '0', '0.0000000', '0.00000000000000000000', '0.0', '0.000000']}, {'input': '300 0.99 1000\r\n', 'output': ['300.000000000000', '300', '300.000000', '300.0000000', '300.0', '300.00000000000005684342']}, {'input': '639 0.81 1150\r\n', 'output': ['639.00000000000011368684', '639.000000', '639', '639.0', '639.000000000000', '639.0000000']}, {'input': '1000 0.90 1733\r\n', 'output': ['999.99999999999988631316', '1000.0000000', '1000.000000', '1000.000000000000', '1000', '1000.0']}] | [{'input': '1 0.50 1\r\n', 'output': ['0.500000', '0.5000000', '0.5', '0.500000000000', '0.50000000000000000000']}, {'input': '100 0.01 53\r\n', 'output': ['0.53000000000000002665', '0.530000', '0.53', '0.530000000000', '0.5300000']}, {'input': '132 0.34 241\r\n', 'output': ['81.940000', '81.94', '81.939999999978', '81.9400000', '81.93999999997761563009']}, {'input': '439 0.83 790\r\n', 'output': ['439.00000000000005684342', '439', '439.000000000000', '439.0', '439.000000', '439.0000000']}, {'input': '415 0.72 747\r\n', 'output': ['415.000000', '415', '415.0', '415.000000000000', '414.99999999999977262632', '415.0000000']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 81 | 100 | 100 | 100 |
["2 2 1", "2 2 2", "3 2 2"] | The first line contains space-separated integers n, m and k (1ββ€βn,βmββ€β1000,β1ββ€βkββ€β106) β the board's vertical and horizontal sizes and the number of colors respectively. | f22f28e2d8933f4199ba5ccfc0de8cda | #include <stdio.h>
#define mod 1000000007
int f[1001],c[1001][1001],r1[1001],r2[2001];
int mi(int a,long long b)
{
int t;
if (!b)
return 1;
t=mi(a,b>>1);
t=(long long)t*t%mod;
if (b&1)
t=(long long)t*a%mod;
return t;
}
int main()
{
int i,j,n,m,k,x,s=0,t=1;
scanf("%d%d%d",&n,&m,&k);
if (m==1)
s=mi(k,n);
else
{
for (i=0;i<=n;i++)
{
c[i][0]=1;
for (j=1;j<=i;j++)
c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
}
for (i=1;i<=n;i++)
{
f[i]=mi(i,n);
for (j=1;j<i;j++)
f[i]=(f[i]-(long long)f[j]*c[i][j]%mod+mod)%mod;
}
r1[0]=r2[0]=1;
for (i=1;i<=n;i++)
r1[i]=(long long)r1[i-1]*mi(i,mod-2)%mod;
for (i=1;i<=2*n&&i<=k;i++)
r2[i]=(long long)r2[i-1]*(k-i+1)%mod;
for (i=0;i<=n;i++)
{
x=mi(i,(long long)(m-2)*n);
for (j=0;i+j<=n&&i+2*j<=k;j++)
s=(s+(long long)r2[2*j+i]*r1[j]%mod*r1[j]%mod*r1[i]%mod*f[i+j]%mod*f[i+j]%mod*x)%mod;
}
}
printf("%d\n",s);
return 0;
}
| ["1", "8", "40"] | C | null | Print the answer to the problem. As the answer can be quite a large number, you should print it modulo 109β+β7 (1000000007). | Little Petya loves counting. He wants to count the number of ways to paint a rectangular checkered board of size nβΓβm (n rows, m columns) in k colors. Besides, the coloring should have the following property: for any vertical line that passes along the grid lines and divides the board in two non-empty parts the number of distinct colors in both these parts should be the same. Help Petya to count these colorings. | [{"input": "2 2 1\r\n", "output": ["1"]}, {"input": "2 2 2\r\n", "output": ["8"]}, {"input": "3 2 2\r\n", "output": ["40"]}, {"input": "7 8 15\r\n", "output": ["422409918"]}, {"input": "5 3 1\r\n", "output": ["1"]}, {"input": "5 100 1\r\n", "output": ["1"]}, {"input": "5 20 25\r\n", "output": ["375284458"]}, {"input": "6 6 8\r\n", "output": ["522449402"]}, {"input": "1 1 1000000\r\n", "output": ["1000000"]}, {"input": "3 3 2\r\n", "output": ["290"]}, {"input": "1000 1000 1000000\r\n", "output": ["396597934"]}, {"input": "1000 2 1000000\r\n", "output": ["356256162"]}, {"input": "1000 1 992929\r\n", "output": ["466214417"]}, {"input": "997 752 10001\r\n", "output": ["353027886"]}, {"input": "994 2 999999\r\n", "output": ["273778994"]}, {"input": "1 1000 298298\r\n", "output": ["298298"]}, {"input": "2 1000 100202\r\n", "output": ["648728052"]}, {"input": "3 997 999997\r\n", "output": ["291903372"]}, {"input": "777 777 777777\r\n", "output": ["874869916"]}, {"input": "105 3 2\r\n", "output": ["207720058"]}, {"input": "105 3 3\r\n", "output": ["481254277"]}, {"input": "126 125 440715\r\n", "output": ["387326012"]}, {"input": "755 51 70160\r\n", "output": ["188325679"]}, {"input": "385 978 699604\r\n", "output": ["207434967"]}, {"input": "663 904 329049\r\n", "output": ["599285820"]}, {"input": "293 183 442142\r\n", "output": ["427008206"]}, {"input": "922 109 71587\r\n", "output": ["433271191"]}, {"input": "552 36 701031\r\n", "output": ["203545141"]}, {"input": "182 314 814124\r\n", "output": ["753768028"]}, {"input": "812 240 443569\r\n", "output": ["570986336"]}, {"input": "595 881 798832\r\n", "output": ["551206173"]}, {"input": "694 685 739154\r\n", "output": ["621135202"]}, {"input": "793 840 679477\r\n", "output": ["737614679"]}, {"input": "892 996 619800\r\n", "output": ["499746149"]}, {"input": "990 800 43771\r\n", "output": ["959043509"]}, {"input": "89 955 984094\r\n", "output": ["559468061"]}, {"input": "188 759 924417\r\n", "output": ["709624881"]}, {"input": "287 915 864740\r\n", "output": ["945465938"]}, {"input": "738 718 805063\r\n", "output": ["428428914"]}, {"input": "837 874 229034\r\n", "output": ["359437873"]}, {"input": "991 301 743241\r\n", "output": ["583160905"]}] | 100 | 100 | 100 | [{'input': '2 1000 100202\r\n', 'output': ['648728052']}, {'input': '922 109 71587\r\n', 'output': ['433271191']}, {'input': '1000 1 992929\r\n', 'output': ['466214417']}, {'input': '777 777 777777\r\n', 'output': ['874869916']}, {'input': '1 1000 298298\r\n', 'output': ['298298']}] | [{'input': '990 800 43771\r\n', 'output': ['959043509']}, {'input': '89 955 984094\r\n', 'output': ['559468061']}, {'input': '385 978 699604\r\n', 'output': ['207434967']}, {'input': '5 3 1\r\n', 'output': ['1']}, {'input': '2 1000 100202\r\n', 'output': ['648728052']}] | [{'input': '385 978 699604\r\n', 'output': ['207434967']}, {'input': '105 3 3\r\n', 'output': ['481254277']}, {'input': '991 301 743241\r\n', 'output': ['583160905']}, {'input': '777 777 777777\r\n', 'output': ['874869916']}, {'input': '595 881 798832\r\n', 'output': ['551206173']}] | [{'input': '3 997 999997\r\n', 'output': ['291903372']}, {'input': '552 36 701031\r\n', 'output': ['203545141']}, {'input': '991 301 743241\r\n', 'output': ['583160905']}, {'input': '777 777 777777\r\n', 'output': ['874869916']}, {'input': '694 685 739154\r\n', 'output': ['621135202']}] | [{'input': '994 2 999999\r\n', 'output': ['273778994']}, {'input': '663 904 329049\r\n', 'output': ['599285820']}, {'input': '126 125 440715\r\n', 'output': ['387326012']}, {'input': '755 51 70160\r\n', 'output': ['188325679']}, {'input': '5 3 1\r\n', 'output': ['1']}] | 100 | 100 | 100 | 100 | 100 | 100 | 96.88 | 96.88 | 96.88 | 96.88 | 92.31 | 96.15 | 96.15 | 88.46 | 96.15 | 82 | 100 | 97.504 | 93.844 |
["8 6 4 5", "8 6 4 6", "10 3 11 4", "4 2 1 4"] | The only line contains four integers n, t, k, d (1ββ€βn,βt,βk,βdββ€β1β000)Β β the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven. | 32c866d3d394e269724b4930df5e4407 | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n,t,k,d;
scanf("%d%d%d%d",&n,&t,&k,&d);
int ans=((d/t)+1)*k;
if(ans<n)
printf("YES");
else
printf("NO");
return 0;
}
| ["YES", "NO", "NO", "YES"] | C | NoteIn the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6 minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven. In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven. | If it is reasonable to build the second oven, print "YES". Otherwise print "NO". | In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable. | [{"input": "8 6 4 5\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "8 6 4 6\r\n", "output": ["No", "NO", "no"]}, {"input": "10 3 11 4\r\n", "output": ["No", "NO", "no"]}, {"input": "4 2 1 4\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "28 17 16 26\r\n", "output": ["No", "NO", "no"]}, {"input": "60 69 9 438\r\n", "output": ["No", "NO", "no"]}, {"input": "599 97 54 992\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "11 22 18 17\r\n", "output": ["No", "NO", "no"]}, {"input": "1 13 22 11\r\n", "output": ["No", "NO", "no"]}, {"input": "1 1 1 1\r\n", "output": ["No", "NO", "no"]}, {"input": "3 1 1 1\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "1000 1000 1000 1000\r\n", "output": ["No", "NO", "no"]}, {"input": "1000 1000 1 1\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "1000 1000 1 400\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "1000 1000 1 1000\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "1000 1000 1 999\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "53 11 3 166\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "313 2 3 385\r\n", "output": ["No", "NO", "no"]}, {"input": "214 9 9 412\r\n", "output": ["No", "NO", "no"]}, {"input": "349 9 5 268\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "611 16 8 153\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "877 13 3 191\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "340 9 9 10\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "31 8 2 205\r\n", "output": ["No", "NO", "no"]}, {"input": "519 3 2 148\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "882 2 21 219\r\n", "output": ["No", "NO", "no"]}, {"input": "982 13 5 198\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "428 13 6 272\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "436 16 14 26\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "628 10 9 386\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "77 33 18 31\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "527 36 4 8\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "128 18 2 169\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "904 4 2 288\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "986 4 3 25\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "134 8 22 162\r\n", "output": ["No", "NO", "no"]}, {"input": "942 42 3 69\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "894 4 9 4\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "953 8 10 312\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "43 8 1 121\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "12 13 19 273\r\n", "output": ["No", "NO", "no"]}, {"input": "204 45 10 871\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "342 69 50 425\r\n", "output": ["No", "NO", "no"]}, {"input": "982 93 99 875\r\n", "output": ["No", "NO", "no"]}, {"input": "283 21 39 132\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "1000 45 83 686\r\n", "output": ["No", "NO", "no"]}, {"input": "246 69 36 432\r\n", "output": ["No", "NO", "no"]}, {"input": "607 93 76 689\r\n", "output": ["No", "NO", "no"]}, {"input": "503 21 24 435\r\n", "output": ["No", "NO", "no"]}, {"input": "1000 45 65 989\r\n", "output": ["No", "NO", "no"]}, {"input": "30 21 2 250\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "1000 49 50 995\r\n", "output": ["No", "NO", "no"]}, {"input": "383 69 95 253\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "393 98 35 999\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "1000 22 79 552\r\n", "output": ["No", "NO", "no"]}, {"input": "268 294 268 154\r\n", "output": ["No", "NO", "no"]}, {"input": "963 465 706 146\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "304 635 304 257\r\n", "output": ["No", "NO", "no"]}, {"input": "4 2 1 6\r\n", "output": ["No", "NO", "no"]}, {"input": "1 51 10 50\r\n", "output": ["No", "NO", "no"]}, {"input": "5 5 4 4\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "3 2 1 1\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "3 4 3 3\r\n", "output": ["No", "NO", "no"]}, {"input": "7 3 4 1\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "101 10 1 1000\r\n", "output": ["No", "NO", "no"]}, {"input": "5 1 1 1\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "5 10 5 5\r\n", "output": ["No", "NO", "no"]}, {"input": "19 1 7 1\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "763 572 745 262\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "1 2 1 1\r\n", "output": ["No", "NO", "no"]}, {"input": "5 1 1 3\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "170 725 479 359\r\n", "output": ["No", "NO", "no"]}, {"input": "6 2 1 7\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "6 2 5 1\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "1 2 2 1\r\n", "output": ["No", "NO", "no"]}, {"input": "24 2 8 3\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "7 3 3 3\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "5 2 2 2\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "3 2 1 2\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "1000 2 200 8\r\n", "output": ["No", "NO", "no"]}, {"input": "3 100 2 100\r\n", "output": ["No", "NO", "no"]}, {"input": "2 999 1 1000\r\n", "output": ["No", "NO", "no"]}, {"input": "2 1 1 1\r\n", "output": ["No", "NO", "no"]}, {"input": "2 3 5 1\r\n", "output": ["No", "NO", "no"]}, {"input": "100 1 5 1\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "7 2 3 3\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "4 1 1 3\r\n", "output": ["No", "NO", "no"]}, {"input": "3 2 2 1\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "1 1 1 2\r\n", "output": ["No", "NO", "no"]}, {"input": "91 8 7 13\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "3 1 2 1\r\n", "output": ["No", "NO", "no"]}, {"input": "5 3 2 3\r\n", "output": ["YES", "Yes", "yes"]}, {"input": "9 6 6 3\r\n", "output": ["YES", "Yes", "yes"]}] | 100 | 100 | 100 | [{'input': '5 1 1 3\r\n', 'output': ['YES', 'Yes', 'yes']}, {'input': '3 4 3 3\r\n', 'output': ['No', 'NO', 'no']}, {'input': '3 1 2 1\r\n', 'output': ['No', 'NO', 'no']}, {'input': '4 2 1 4\r\n', 'output': ['YES', 'Yes', 'yes']}, {'input': '4 1 1 3\r\n', 'output': ['No', 'NO', 'no']}] | [{'input': '4 2 1 4\r\n', 'output': ['YES', 'Yes', 'yes']}, {'input': '7 2 3 3\r\n', 'output': ['YES', 'Yes', 'yes']}, {'input': '4 1 1 3\r\n', 'output': ['No', 'NO', 'no']}, {'input': '3 1 2 1\r\n', 'output': ['No', 'NO', 'no']}, {'input': '128 18 2 169\r\n', 'output': ['YES', 'Yes', 'yes']}] | [{'input': '6 2 5 1\r\n', 'output': ['YES', 'Yes', 'yes']}, {'input': '128 18 2 169\r\n', 'output': ['YES', 'Yes', 'yes']}, {'input': '1 1 1 2\r\n', 'output': ['No', 'NO', 'no']}, {'input': '1 1 1 1\r\n', 'output': ['No', 'NO', 'no']}, {'input': '882 2 21 219\r\n', 'output': ['No', 'NO', 'no']}] | [{'input': '30 21 2 250\r\n', 'output': ['YES', 'Yes', 'yes']}, {'input': '5 10 5 5\r\n', 'output': ['No', 'NO', 'no']}, {'input': '599 97 54 992\r\n', 'output': ['YES', 'Yes', 'yes']}, {'input': '1 13 22 11\r\n', 'output': ['No', 'NO', 'no']}, {'input': '4 2 1 4\r\n', 'output': ['YES', 'Yes', 'yes']}] | [{'input': '982 13 5 198\r\n', 'output': ['YES', 'Yes', 'yes']}, {'input': '1 2 2 1\r\n', 'output': ['No', 'NO', 'no']}, {'input': '19 1 7 1\r\n', 'output': ['YES', 'Yes', 'yes']}, {'input': '77 33 18 31\r\n', 'output': ['YES', 'Yes', 'yes']}, {'input': '28 17 16 26\r\n', 'output': ['No', 'NO', 'no']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 83 | 100 | 100 | 100 |
["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<stdio.h>
int main(void){
int x,y,z,x0,y0,z0;
int a[6],*p=a-1;
int i,j,k,num=0;
scanf("%d%d%d",&x,&y,&z);
scanf("%d%d%d",&x0,&y0,&z0);
for(i=1;i<=6;i++) scanf("%d",p+i);
if(y<0) num+=p[1];
else if(y>y0) num+=p[2];
if(z<0) num+=p[3];
else if(z>z0) num+=p[4];
if(x<0) num+=p[5];
else if(x>x0) num+=p[6];
printf("%d\n",num);
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': '381718 587052 14730\r\n290055 960762 231879\r\n646112 249417 451908 49140 819134 575870\r\n', 'output': ['575870']}, {'input': '701521 392984 524392\r\n462491 968267 126043\r\n328074 993331 895443 352976 984911 318865\r\n', 'output': ['671841']}, {'input': '298742 556311 628232\r\n360973 607625 301540\r\n278905 531131 923271 701344 873950 969819\r\n', 'output': ['701344']}, {'input': '3 10 3\r\n6 6 6\r\n2 4 8 16 32 64\r\n', 'output': ['4']}, {'input': '409501 -349039 -285847\r\n4386 1034 7566\r\n166804 981888 780353 956617 563457 238748\r\n', 'output': ['1185905']}] | [{'input': '-263980 -876063 613611\r\n2 3 14\r\n63640 300066 460766 222639 51956 412622\r\n', 'output': ['338235']}, {'input': '0 1 2\r\n1 1 1\r\n634728 627299 454463 927148 298618 186257\r\n', 'output': ['927148']}, {'input': '30 68 72\r\n51 54 95\r\n480054 561470 308678 472768 90393 992511\r\n', 'output': ['561470']}, {'input': '298742 556311 628232\r\n360973 607625 301540\r\n278905 531131 923271 701344 873950 969819\r\n', 'output': ['701344']}, {'input': '34271 -17508 -6147\r\n456 567 112\r\n804178 307516 306399 18981 989216 228388\r\n', 'output': ['1338965']}] | [{'input': '0 1 2\r\n1 1 1\r\n634728 627299 454463 927148 298618 186257\r\n', 'output': ['927148']}, {'input': '7412 -524 9621\r\n8748 8870 1521\r\n1043 894084 881852 56954 415764 946495\r\n', 'output': ['57997']}, {'input': '-263980 -876063 613611\r\n2 3 14\r\n63640 300066 460766 222639 51956 412622\r\n', 'output': ['338235']}, {'input': '5 5 0\r\n3 1 3\r\n832224 636838 995053 211585 505442 341920\r\n', 'output': ['978758']}, {'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': '5 2 -4\r\n1 1 1\r\n279519 704273 181008 670653 198973 996401\r\n', 'output': ['1881682']}, {'input': '3 10 3\r\n6 6 6\r\n2 4 8 16 32 64\r\n', 'output': ['4']}, {'input': '1 1 3\r\n2 2 2\r\n1 2 3 4 5 6\r\n', 'output': ['4']}, {'input': '1 3 1\r\n2 2 2\r\n1 2 4 8 16 32\r\n', 'output': ['2']}] | [{'input': '19 60 75\r\n11 64 92\r\n768641 208726 47379 514231 858941 959876\r\n', 'output': ['959876']}, {'input': '58224 94433 40185\r\n55683 99614 33295\r\n137430 61976 671256 929825 499631 90071\r\n', 'output': ['1019896']}, {'input': '95892 79497 69936\r\n7 4 6\r\n873850 132840 469930 271591 257864 626722\r\n', 'output': ['1031153']}, {'input': '298742 556311 628232\r\n360973 607625 301540\r\n278905 531131 923271 701344 873950 969819\r\n', 'output': ['701344']}, {'input': '722477 814197 501318\r\n670293 164127 180084\r\n665889 389403 663253 449990 909406 240043\r\n', 'output': ['1079436']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 92.86 | 100 | 92.86 | 85.71 | 78.57 | 84 | 100 | 100 | 90 |
["6\n1 2 6", "10\n1 2 3 4 5"] | The first line of the input contains one integer n (2ββ€βnββ€β100, n is even) β the size of the chessboard. The second line of the input contains integer numbers (1ββ€βpiββ€βn) β initial positions of the pieces. It is guaranteed that all the positions are distinct. | 0efe9afd8e6be9e00f7949be93f0ca1a | #include <stdio.h>
int v[51];
int main(){
int n, i, aux, f, cn, s, s2;
s=s2=0;
scanf("%d", &n);
cn=n/2;
for(i=0; i<cn; i++)
scanf("%d", &v[i]);
f=0;
while(f==0){
f=1;
for(i=0; i<cn-1; i++)
if(v[i]>v[i+1]){
aux=v[i];
v[i]=v[i+1];
v[i+1]=aux;
f=0;
}
}
for(i=1; i<=n; i+=2)
s=s+abs(v[(i-1)/2]-i);
for(i=2; i<=n; i+=2)
s2=s2+abs(v[(i-2)/2]-i);
if(s>s2)
printf("%d", s2);
else
printf("%d", s);
return 0;
}
| ["2", "10"] | C | NoteIn the first example the only possible strategy is to move the piece at the position 6 to the position 5 and move the piece at the position 2 to the position 3. Notice that if you decide to place the pieces in the white cells the minimum number of moves will be 3.In the second example the possible strategy is to move in 4 moves, then in 3 moves, in 2 moves and in 1 move. | Print one integer β the minimum number of moves you have to make to place all the pieces in the cells of the same color. | You are given a chessboard of size 1βΓβn. It is guaranteed that n is even. The chessboard is painted like this: "BWBW...BW".Some cells of the board are occupied by the chess pieces. Each cell contains no more than one chess piece. It is known that the total number of pieces equals to .In one step you can move one of the pieces one cell to the left or to the right. You cannot move pieces beyond the borders of the board. You also cannot move pieces to the cells that are already occupied.Your task is to place all the pieces in the cells of the same color using the minimum number of moves (all the pieces must occupy only the black cells or only the white cells after all the moves are made). | [{"input": "6\r\n1 2 6\r\n", "output": ["2"]}, {"input": "10\r\n1 2 3 4 5\r\n", "output": ["10"]}, {"input": "2\r\n2\r\n", "output": ["0"]}, {"input": "100\r\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100\r\n", "output": ["0"]}, {"input": "100\r\n93 54 57 61 68 66 70 96 64 82 80 75 69 77 76 94 67 86 90 73 74 58 100 83 92 89 56 99 88 59 95 72 81 51 85 71 97 60 91 63 65 98 79 84 53 62 87 55 52 78\r\n", "output": ["1225"]}, {"input": "100\r\n41 13 29 11 25 15 6 23 28 50 48 17 3 9 44 24 5 19 34 22 33 32 20 16 35 37 4 10 46 2 39 40 47 49 36 42 1 30 43 21 14 7 18 45 31 8 12 26 27 38\r\n", "output": ["1225"]}, {"input": "96\r\n12 58 70 19 65 61 41 46 15 92 64 72 9 26 53 37 2 3 1 40 10 8 94 66 50 34 36 96 47 78 7 57 5 6 17 69 28 88 89 49 55 81 35 22 25 79 86 59\r\n", "output": ["152"]}, {"input": "10\r\n5 6 7 8 9\r\n", "output": ["7"]}, {"input": "20\r\n1 2 3 4 5 6 7 8 9 10\r\n", "output": ["45"]}, {"input": "10\r\n6 7 8 9 10\r\n", "output": ["10"]}, {"input": "10\r\n9 8 7 6 5\r\n", "output": ["7"]}, {"input": "6\r\n1 5 6\r\n", "output": ["2"]}, {"input": "12\r\n1 7 8 9 10 12\r\n", "output": ["7"]}, {"input": "6\r\n1 4 5\r\n", "output": ["1"]}, {"input": "24\r\n10 21 15 3 11 4 18 24 16 22 14 9\r\n", "output": ["11"]}, {"input": "20\r\n3 4 6 7 8 10 11 13 14 17\r\n", "output": ["15"]}, {"input": "10\r\n10 9 8 1 5\r\n", "output": ["5"]}, {"input": "100\r\n84 10 26 79 58 93 67 85 7 2 99 4 47 45 75 22 32 82 65 53 63 49 42 52 12 69 86 46 25 76 40 15 13 78 8 81 62 28 60 21 27 80 98 56 3 36 54 16 50 43\r\n", "output": ["104"]}, {"input": "10\r\n1 7 8 9 10\r\n", "output": ["7"]}, {"input": "10\r\n1 4 6 8 10\r\n", "output": ["1"]}, {"input": "80\r\n41 70 18 53 32 79 51 49 21 27 47 65 50 15 62 60 5 40 14 25 64 9 19 58 38 76 66 52 17 34 13 2 80 43 3 42 33 36 6 72\r\n", "output": ["47"]}, {"input": "50\r\n27 42 41 4 10 45 44 26 49 50 17 28 2 36 18 39 23 12 21 24 19 29 22 40 37\r\n", "output": ["59"]}, {"input": "10\r\n2 3 4 5 6\r\n", "output": ["7"]}, {"input": "6\r\n3 5 6\r\n", "output": ["2"]}, {"input": "100\r\n9 63 62 88 3 67 54 33 79 51 71 80 37 46 43 57 69 17 34 6 18 40 59 83 76 86 8 55 90 89 45 42 28 98 30 38 77 91 73 58 23 61 41 65 64 93 14 44 16 24\r\n", "output": ["160"]}, {"input": "10\r\n1 6 7 8 9\r\n", "output": ["5"]}, {"input": "6\r\n3 4 5\r\n", "output": ["2"]}] | 100 | 100 | 100 | [{'input': '10\r\n6 7 8 9 10\r\n', 'output': ['10']}, {'input': '10\r\n10 9 8 1 5\r\n', 'output': ['5']}, {'input': '100\r\n84 10 26 79 58 93 67 85 7 2 99 4 47 45 75 22 32 82 65 53 63 49 42 52 12 69 86 46 25 76 40 15 13 78 8 81 62 28 60 21 27 80 98 56 3 36 54 16 50 43\r\n', 'output': ['104']}, {'input': '24\r\n10 21 15 3 11 4 18 24 16 22 14 9\r\n', 'output': ['11']}, {'input': '2\r\n2\r\n', 'output': ['0']}] | [{'input': '6\r\n1 2 6\r\n', 'output': ['2']}, {'input': '80\r\n41 70 18 53 32 79 51 49 21 27 47 65 50 15 62 60 5 40 14 25 64 9 19 58 38 76 66 52 17 34 13 2 80 43 3 42 33 36 6 72\r\n', 'output': ['47']}, {'input': '2\r\n2\r\n', 'output': ['0']}, {'input': '6\r\n1 4 5\r\n', 'output': ['1']}, {'input': '100\r\n93 54 57 61 68 66 70 96 64 82 80 75 69 77 76 94 67 86 90 73 74 58 100 83 92 89 56 99 88 59 95 72 81 51 85 71 97 60 91 63 65 98 79 84 53 62 87 55 52 78\r\n', 'output': ['1225']}] | [{'input': '10\r\n1 2 3 4 5\r\n', 'output': ['10']}, {'input': '100\r\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100\r\n', 'output': ['0']}, {'input': '96\r\n12 58 70 19 65 61 41 46 15 92 64 72 9 26 53 37 2 3 1 40 10 8 94 66 50 34 36 96 47 78 7 57 5 6 17 69 28 88 89 49 55 81 35 22 25 79 86 59\r\n', 'output': ['152']}, {'input': '24\r\n10 21 15 3 11 4 18 24 16 22 14 9\r\n', 'output': ['11']}, {'input': '10\r\n1 4 6 8 10\r\n', 'output': ['1']}] | [{'input': '2\r\n2\r\n', 'output': ['0']}, {'input': '10\r\n1 2 3 4 5\r\n', 'output': ['10']}, {'input': '10\r\n10 9 8 1 5\r\n', 'output': ['5']}, {'input': '10\r\n1 4 6 8 10\r\n', 'output': ['1']}, {'input': '6\r\n3 5 6\r\n', 'output': ['2']}] | [{'input': '50\r\n27 42 41 4 10 45 44 26 49 50 17 28 2 36 18 39 23 12 21 24 19 29 22 40 37\r\n', 'output': ['59']}, {'input': '6\r\n3 4 5\r\n', 'output': ['2']}, {'input': '2\r\n2\r\n', 'output': ['0']}, {'input': '10\r\n1 7 8 9 10\r\n', 'output': ['7']}, {'input': '10\r\n2 3 4 5 6\r\n', 'output': ['7']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 85 | 100 | 100 | 100 |
["6 1", "4 2"] | The first line contains a pair of integers n and t (3ββ€βnββ€β20, 1ββ€βtββ€β10). | 6d67559744583229455c5eafe68f7952 | #include <stdio.h>
int dp[21][12][5][5];
int main() {
int i,j,k,l,x,n,t;;
scanf("%d %d\n",&n,&t);
for (i=1;i<4;i++)
for (j=i+1;j<=4;j++)
dp[2][0][i][j]=1;
for (x=3;x<=n;x++)
for (i=1;i<=4;i++)
for (j=1;j<=4;j++)
if (i!=j) for (k=1;k<=4;k++)
if (j!=k) for (l=0;l<=t;l++)
if (i<j&&j>k) dp[x][l+1][j][k]+=dp[x-1][l][i][j];
else dp[x][l][j][k]+=dp[x-1][l][i][j];
int cnt=0;
for (i=2;i<=4;i++)
for (j=1;j<i;j++)
cnt+=dp[n][t][i][j];
printf("%d\n",cnt);
return 0;
}
| ["6", "0"] | C | NoteIn the first sample test sequences of y-coordinates for six camels are: 123421, 123431, 123432, 124321, 134321 ΠΈ 234321 (each digit corresponds to one value of yi). | Output the required amount of camels with t humps. | Bob likes to draw camels: with a single hump, two humps, three humps, etc. He draws a camel by connecting points on a coordinate plane. Now he's drawing camels with t humps, representing them as polylines in the plane. Each polyline consists of n vertices with coordinates (x1,βy1), (x2,βy2), ..., (xn,βyn). The first vertex has a coordinate x1β=β1, the second β x2β=β2, etc. Coordinates yi might be any, but should satisfy the following conditions: there should be t humps precisely, i.e. such indexes j (2ββ€βjββ€βnβ-β1), so that yjβ-β1β<βyjβ>βyjβ+β1, there should be precisely tβ-β1 such indexes j (2ββ€βjββ€βnβ-β1), so that yjβ-β1β>βyjβ<βyjβ+β1, no segment of a polyline should be parallel to the Ox-axis, all yi are integers between 1 and 4. For a series of his drawings of camels with t humps Bob wants to buy a notebook, but he doesn't know how many pages he will need. Output the amount of different polylines that can be drawn to represent camels with t humps for a given number n. | [{"input": "6 1\r\n", "output": ["6"]}, {"input": "4 2\r\n", "output": ["0"]}, {"input": "3 1\r\n", "output": ["14"]}, {"input": "3 2\r\n", "output": ["0"]}, {"input": "3 3\r\n", "output": ["0"]}, {"input": "3 10\r\n", "output": ["0"]}, {"input": "4 1\r\n", "output": ["22"]}, {"input": "4 3\r\n", "output": ["0"]}, {"input": "4 9\r\n", "output": ["0"]}, {"input": "5 1\r\n", "output": ["16"]}, {"input": "5 2\r\n", "output": ["70"]}, {"input": "5 3\r\n", "output": ["0"]}, {"input": "5 5\r\n", "output": ["0"]}, {"input": "5 9\r\n", "output": ["0"]}, {"input": "5 10\r\n", "output": ["0"]}, {"input": "6 1\r\n", "output": ["6"]}, {"input": "6 2\r\n", "output": ["232"]}, {"input": "6 3\r\n", "output": ["0"]}, {"input": "6 4\r\n", "output": ["0"]}, {"input": "6 10\r\n", "output": ["0"]}, {"input": "19 1\r\n", "output": ["0"]}, {"input": "19 2\r\n", "output": ["0"]}, {"input": "19 3\r\n", "output": ["1"]}, {"input": "19 4\r\n", "output": ["32632"]}, {"input": "19 5\r\n", "output": ["4594423"]}, {"input": "19 6\r\n", "output": ["69183464"]}, {"input": "19 7\r\n", "output": ["197939352"]}, {"input": "19 8\r\n", "output": ["109824208"]}, {"input": "19 9\r\n", "output": ["5846414"]}, {"input": "19 10\r\n", "output": ["0"]}, {"input": "20 1\r\n", "output": ["0"]}, {"input": "20 2\r\n", "output": ["0"]}, {"input": "20 3\r\n", "output": ["0"]}, {"input": "20 4\r\n", "output": ["12628"]}, {"input": "20 5\r\n", "output": ["3715462"]}, {"input": "20 6\r\n", "output": ["96046590"]}, {"input": "20 7\r\n", "output": ["468541040"]}, {"input": "20 8\r\n", "output": ["503245466"]}, {"input": "20 9\r\n", "output": ["90700276"]}, {"input": "20 10\r\n", "output": ["0"]}] | 100 | 100 | 100 | [{'input': '20 9\r\n', 'output': ['90700276']}, {'input': '4 3\r\n', 'output': ['0']}, {'input': '20 8\r\n', 'output': ['503245466']}, {'input': '19 7\r\n', 'output': ['197939352']}, {'input': '4 2\r\n', 'output': ['0']}] | [{'input': '19 7\r\n', 'output': ['197939352']}, {'input': '20 8\r\n', 'output': ['503245466']}, {'input': '5 9\r\n', 'output': ['0']}, {'input': '6 1\r\n', 'output': ['6']}, {'input': '5 1\r\n', 'output': ['16']}] | [{'input': '20 5\r\n', 'output': ['3715462']}, {'input': '19 8\r\n', 'output': ['109824208']}, {'input': '6 2\r\n', 'output': ['232']}, {'input': '19 4\r\n', 'output': ['32632']}, {'input': '6 3\r\n', 'output': ['0']}] | [{'input': '20 3\r\n', 'output': ['0']}, {'input': '20 10\r\n', 'output': ['0']}, {'input': '19 10\r\n', 'output': ['0']}, {'input': '6 4\r\n', 'output': ['0']}, {'input': '6 2\r\n', 'output': ['232']}] | [{'input': '6 1\r\n', 'output': ['6']}, {'input': '19 1\r\n', 'output': ['0']}, {'input': '20 3\r\n', 'output': ['0']}, {'input': '6 10\r\n', 'output': ['0']}, {'input': '19 6\r\n', 'output': ['69183464']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 86 | 100 | 100 | 100 |
["3 6 9", "4 4 4", "0 0 0"] | The first line contains three integers r, g and b (0ββ€βr,βg,βbββ€β109) β the number of red, green and blue flowers. | acddc9b0db312b363910a84bd4f14d8e | #include<stdio.h>
int main()
{
int r,b,g,mix,a[10],i;
scanf("%d %d %d",&r,&b,&g);
if(r==0 || b==0 || g==0)
{
printf("%d",(r/3+g/3+b/3));
return 0;
}
for(i=0;i<=2;i++)
{
a[i]=(i+((r-i)/3+(b-i)/3+(g-i)/3));
}
int max=0;
for(i=0;i<=2;i++)
{
if(a[i]>max)
max=a[i];
}
printf("%d",max);
return 0;
}
| ["6", "4", "0"] | C | NoteIn test case 1, we can make 1 red bouquet, 2 green bouquets and 3 blue bouquets.In test case 2, we can make 1 red, 1 green, 1 blue and 1 mixing bouquet. | Print the maximal number of bouquets Fox Ciel can make. | Fox Ciel has some flowers: r red flowers, g green flowers and b blue flowers. She wants to use these flowers to make several bouquets. There are 4 types of bouquets: To make a "red bouquet", it needs 3 red flowers. To make a "green bouquet", it needs 3 green flowers. To make a "blue bouquet", it needs 3 blue flowers. To make a "mixing bouquet", it needs 1 red, 1 green and 1 blue flower. Help Fox Ciel to find the maximal number of bouquets she can make. | [{"input": "3 6 9\r\n", "output": ["6"]}, {"input": "4 4 4\r\n", "output": ["4"]}, {"input": "0 0 0\r\n", "output": ["0"]}, {"input": "0 3 6\r\n", "output": ["3"]}, {"input": "7 8 9\r\n", "output": ["7"]}, {"input": "8 8 9\r\n", "output": ["8"]}, {"input": "15 3 999\r\n", "output": ["339"]}, {"input": "32 62 92\r\n", "output": ["62"]}, {"input": "123456789 123456789 123456789\r\n", "output": ["123456789"]}, {"input": "3 5 5\r\n", "output": ["4"]}, {"input": "666806767 385540591 357848286\r\n", "output": ["470065214"]}, {"input": "80010646 727118126 817880463\r\n", "output": ["541669744"]}, {"input": "829651016 732259171 572879931\r\n", "output": ["711596705"]}, {"input": "242854896 442432924 180395753\r\n", "output": ["288561190"]}, {"input": "139978911 5123031 935395222\r\n", "output": ["360165721"]}, {"input": "553182792 10264076 395427398\r\n", "output": ["319624755"]}, {"input": "597790453 720437830 855459575\r\n", "output": ["724562619"]}, {"input": "494914467 356982656 757942689\r\n", "output": ["536613270"]}, {"input": "908118348 67156409 217974865\r\n", "output": ["397749873"]}, {"input": "952726009 629846517 972974334\r\n", "output": ["851848953"]}, {"input": "775140200 616574841 630329230\r\n", "output": ["674014756"]}, {"input": "524780569 326748594 90361407\r\n", "output": ["313963523"]}, {"input": "937984449 184405994 992844522\r\n", "output": ["705078321"]}, {"input": "835108464 525983528 452876698\r\n", "output": ["604656229"]}, {"input": "879716125 531124573 207876166\r\n", "output": ["539572288"]}, {"input": "292920005 241298326 667908343\r\n", "output": ["400708891"]}, {"input": "1000000000 1000000000 1000000000\r\n", "output": ["1000000000"]}, {"input": "1000000000 999999999 999999998\r\n", "output": ["999999998"]}, {"input": "999999998 999999998 999999999\r\n", "output": ["999999998"]}, {"input": "0 1 1\r\n", "output": ["0"]}, {"input": "0 1000000000 0\r\n", "output": ["333333333"]}, {"input": "0 1 0\r\n", "output": ["0"]}, {"input": "1 0 0\r\n", "output": ["0"]}, {"input": "0 2 2\r\n", "output": ["0"]}, {"input": "3 3 5\r\n", "output": ["3"]}, {"input": "2 2 0\r\n", "output": ["0"]}, {"input": "0 5 5\r\n", "output": ["2"]}, {"input": "2 0 11\r\n", "output": ["3"]}, {"input": "9 9 7\r\n", "output": ["8"]}, {"input": "65 30 74\r\n", "output": ["56"]}] | 100 | 100 | 100 | [{'input': '835108464 525983528 452876698\r\n', 'output': ['604656229']}, {'input': '0 1 1\r\n', 'output': ['0']}, {'input': '0 1 0\r\n', 'output': ['0']}, {'input': '952726009 629846517 972974334\r\n', 'output': ['851848953']}, {'input': '0 5 5\r\n', 'output': ['2']}] | [{'input': '952726009 629846517 972974334\r\n', 'output': ['851848953']}, {'input': '0 1 1\r\n', 'output': ['0']}, {'input': '3 3 5\r\n', 'output': ['3']}, {'input': '597790453 720437830 855459575\r\n', 'output': ['724562619']}, {'input': '1000000000 999999999 999999998\r\n', 'output': ['999999998']}] | [{'input': '242854896 442432924 180395753\r\n', 'output': ['288561190']}, {'input': '0 0 0\r\n', 'output': ['0']}, {'input': '0 5 5\r\n', 'output': ['2']}, {'input': '1000000000 999999999 999999998\r\n', 'output': ['999999998']}, {'input': '3 5 5\r\n', 'output': ['4']}] | [{'input': '0 2 2\r\n', 'output': ['0']}, {'input': '952726009 629846517 972974334\r\n', 'output': ['851848953']}, {'input': '999999998 999999998 999999999\r\n', 'output': ['999999998']}, {'input': '0 0 0\r\n', 'output': ['0']}, {'input': '123456789 123456789 123456789\r\n', 'output': ['123456789']}] | [{'input': '0 1000000000 0\r\n', 'output': ['333333333']}, {'input': '3 6 9\r\n', 'output': ['6']}, {'input': '32 62 92\r\n', 'output': ['62']}, {'input': '0 2 2\r\n', 'output': ['0']}, {'input': '139978911 5123031 935395222\r\n', 'output': ['360165721']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 83.33 | 83.33 | 83.33 | 83.33 | 83.33 | 87 | 100 | 100 | 83.33 |
["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<stdio.h>
int main()
{
char myarray[1000];
scanf("%s",&myarray);
int i,cnt=0,j,k,l,len=0;
len=strlen(myarray);
for(i=0; i<len; i++)
{
if(myarray[i]=='Q')
{
for(j=i+1; j<len; j++)
{
if(myarray[j]=='A')
{
for(l=j+1; l<len; l++)
{
if(myarray[l]=='Q')
{
cnt++;
}
}
}
}
}
}
printf("%d",cnt);
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': 'QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ\r\n', 'output': ['0']}, {'input': 'AMQQAAQAAQAAAAAAQQQBOAAANAAKQJCYQAE\r\n', 'output': ['254']}, {'input': 'QORZOYAQ\r\n', 'output': ['1']}, {'input': 'QQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQAQAA\r\n', 'output': ['15296']}, {'input': 'QNQKQQQLASQBAVQQQQAAQQOQRJQQAQQQEQZUOANAADAAQQJAQAQARAAAQQQEQBHTQAAQAAAAQQMKQQQIAOJJQQAQAAADADQUQQQA\r\n', 'output': ['9114']}] | [{'input': 'MAQQWAQOYQMAAAQAQPQZAOAAQAUAQNAAQAAAITQSAQAKAQKAQQWSQAAQQAGUCDQMQWKQUXKWQQAAQQAAQQZQDQQQAABXQUUXQOA\r\n', 'output': ['5422']}, {'input': 'AAQQAXBQQBQQXBNQRJAQKQNAQNQVDQASAGGANQQQQTJFFQQQTQQA\r\n', 'output': ['568']}, {'input': 'AQEGQHQQKQAQQPQKAQQQAAAAQQQAQEQAAQAAQAQFSLAAQQAQOQQAVQAAAPQQAWAQAQAFQAXAQQQQTRLOQAQQJQNQXQQQQSQVDQQQ\r\n', 'output': ['12488']}, {'input': 'AQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQAQAAAA\r\n', 'output': ['14270']}, {'input': 'KAZXAVLPJQBQVQQQQQAPAQQGQTQVZQAAAOYA\r\n', 'output': ['70']}] | [{'input': 'QQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQAQAA\r\n', 'output': ['15296']}, {'input': 'AQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQAQAAAA\r\n', 'output': ['14270']}, {'input': 'LQMAQQARQAQBJQQQAGAAZQQXALQQAARQAQQQQAAQQAQQQAQQCAQQAQQAYQQQRAAZATQALYQQAAHHAAQHAAAAAAAAQQMAAQNAKQ\r\n', 'output': ['7768']}, {'input': 'AQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQQAA\r\n', 'output': ['14231']}, {'input': 'MAQQWAQOYQMAAAQAQPQZAOAAQAUAQNAAQAAAITQSAQAKAQKAQQWSQAAQQAGUCDQMQWKQUXKWQQAAQQAAQQZQDQQQAABXQUUXQOA\r\n', 'output': ['5422']}] | [{'input': 'AAAAAA\r\n', 'output': ['0']}, {'input': 'DBA\r\n', 'output': ['0']}, {'input': 'Q\r\n', 'output': ['0']}, {'input': 'QQAAQASGAYAAAAKAKAQIQEAQAIAAIAQQQQQ\r\n', 'output': ['378']}, {'input': 'AQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQAQAA\r\n', 'output': ['14270']}] | [{'input': 'Q\r\n', 'output': ['0']}, {'input': 'KAZXAVLPJQBQVQQQQQAPAQQGQTQVZQAAAOYA\r\n', 'output': ['70']}, {'input': 'QAQQQZZYNOIWIN\r\n', 'output': ['3']}, {'input': 'AQQQQAQAAQQAQAQAAAAAAAAAQAQAAAAAQAQAQQQAQQQAAAQQQAAAAAAAQAAAAQQQQQQQAQQQQAQAAAQAAAAAQAQAAAAAQAQAAAA\r\n', 'output': ['14270']}, {'input': 'QCQAQAGAWAQQQAQAVQAQQQQAQAQQQAQAAATQAAVAAAQQQQAAAUUQAQQNQQWQQWAQAAQQKQYAQAAQQQAAQRAQQQWBQQQQAPBAQGQA\r\n', 'output': ['13174']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 88 | 100 | 100 | 100 |
["1 7", "100 47"] | The only line contains two integers a and b (1ββ€βa,βbββ€β105). It is guaranteed that number b is lucky. | e5e4ea7a5bf785e059e10407b25d73fb | #include<stdio.h>
int b;
int check(int i){
int temp=0,t=0;
while(i>0){
if(i%10==4||i%10==7) temp=temp*10+i%10;
i/=10;
}
while(temp>0){
t=t*10+temp%10;
temp/=10;
}
return t==b;
}
int main(){
int a,i;
scanf("%d%d",&a,&b);
for(i=a+1;;i++){
if(check(i)){
printf("%d",i);
return 0;
}
}
return 0;
}
| ["7", "147"] | C | null | In the only line print a single number β the number c that is sought by Petya. | Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record 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 mask of a positive integer n the number that is obtained after successive writing of all lucky digits of number n from the left to the right. For example, the mask of number 72174994 is number 7744, the mask of 7 is 7, the mask of 9999047 is 47. Obviously, mask of any number is always a lucky number.Petya has two numbers β an arbitrary integer a and a lucky number b. Help him find the minimum number c (cβ>βa) such that the mask of number c equals b. | [{"input": "1 7\r\n", "output": ["7"]}, {"input": "100 47\r\n", "output": ["147"]}, {"input": "458 47\r\n", "output": ["467"]}, {"input": "7 7\r\n", "output": ["17"]}, {"input": "547 47\r\n", "output": ["647"]}, {"input": "77 77\r\n", "output": ["177"]}, {"input": "44 4\r\n", "output": ["45"]}, {"input": "740 4\r\n", "output": ["804"]}, {"input": "100000 77777\r\n", "output": ["177777"]}, {"input": "77777 77777\r\n", "output": ["177777"]}, {"input": "47 74\r\n", "output": ["74"]}, {"input": "74 77\r\n", "output": ["77"]}, {"input": "77 74\r\n", "output": ["174"]}, {"input": "98545 7474\r\n", "output": ["107474"]}, {"input": "99997 4\r\n", "output": ["100004"]}, {"input": "100000 7\r\n", "output": ["100007"]}, {"input": "99997 47\r\n", "output": ["100047"]}, {"input": "47774 774\r\n", "output": ["50774"]}, {"input": "47744 7\r\n", "output": ["50007"]}, {"input": "45896 4\r\n", "output": ["45898"]}, {"input": "45679 77777\r\n", "output": ["77777"]}, {"input": "99979 77\r\n", "output": ["100077"]}, {"input": "10 77777\r\n", "output": ["77777"]}, {"input": "1 47774\r\n", "output": ["47774"]}, {"input": "47774 47774\r\n", "output": ["147774"]}, {"input": "47580 47774\r\n", "output": ["47774"]}, {"input": "55557 74\r\n", "output": ["55574"]}, {"input": "59765 4774\r\n", "output": ["64774"]}, {"input": "76492 447\r\n", "output": ["80447"]}, {"input": "69700 77477\r\n", "output": ["77477"]}, {"input": "31975 74\r\n", "output": ["32074"]}, {"input": "369 47\r\n", "output": ["407"]}, {"input": "39999 4\r\n", "output": ["40000"]}, {"input": "39999 4774\r\n", "output": ["40774"]}, {"input": "474 74\r\n", "output": ["574"]}, {"input": "40007 74444\r\n", "output": ["74444"]}, {"input": "40007 74\r\n", "output": ["50074"]}, {"input": "1 4\r\n", "output": ["4"]}, {"input": "4 4\r\n", "output": ["14"]}, {"input": "700 74\r\n", "output": ["704"]}, {"input": "476 47\r\n", "output": ["478"]}, {"input": "99999 77\r\n", "output": ["100077"]}, {"input": "46 7\r\n", "output": ["57"]}] | 100 | 100 | 100 | [{'input': '1 7\r\n', 'output': ['7']}, {'input': '59765 4774\r\n', 'output': ['64774']}, {'input': '31975 74\r\n', 'output': ['32074']}, {'input': '100000 77777\r\n', 'output': ['177777']}, {'input': '74 77\r\n', 'output': ['77']}] | [{'input': '69700 77477\r\n', 'output': ['77477']}, {'input': '10 77777\r\n', 'output': ['77777']}, {'input': '99997 47\r\n', 'output': ['100047']}, {'input': '39999 4774\r\n', 'output': ['40774']}, {'input': '100 47\r\n', 'output': ['147']}] | [{'input': '40007 74444\r\n', 'output': ['74444']}, {'input': '46 7\r\n', 'output': ['57']}, {'input': '47744 7\r\n', 'output': ['50007']}, {'input': '474 74\r\n', 'output': ['574']}, {'input': '10 77777\r\n', 'output': ['77777']}] | [{'input': '100000 7\r\n', 'output': ['100007']}, {'input': '98545 7474\r\n', 'output': ['107474']}, {'input': '10 77777\r\n', 'output': ['77777']}, {'input': '47774 774\r\n', 'output': ['50774']}, {'input': '7 7\r\n', 'output': ['17']}] | [{'input': '74 77\r\n', 'output': ['77']}, {'input': '31975 74\r\n', 'output': ['32074']}, {'input': '474 74\r\n', 'output': ['574']}, {'input': '458 47\r\n', 'output': ['467']}, {'input': '700 74\r\n', 'output': ['704']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 89 | 100 | 100 | 100 |
["2\n1 2", "3\n2 4 6", "2\n12 18", "5\n45 12 27 30 18"] | The first line contains an integer n (2ββ€βnββ€β100). Then the second line contains n integers: x1, x2, ..., xn (1ββ€βxiββ€β100). | 042cf938dc4a0f46ff33d47b97dc6ad4 | #include <stdio.h>
int main(){
int n,m,a[100],i,j,tr=1,min;
scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d",&a[i]);
while(tr){
tr=0;
min=a[0];
for(i=1;i<n;i++)if(min>a[i])min=a[i];
for(i=0;i<n;i++)if(a[i]>min){
tr=1;
a[i]-=min;
}
}
m=0;
for(i=0;i<n;i++)m+=a[i];
printf("%d",m);
return 0;
}
| ["2", "6", "12", "15"] | C | NoteIn the first example the optimal way is to do the assignment: x2 = x2 - x1.In the second example the optimal sequence of operations is: x3 = x3 - x2, x2 = x2 - x1. | Output a single integer β the required minimal sum. | Fox Ciel is playing a game with numbers now. Ciel has n positive integers: x1, x2, ..., xn. She can do the following operation as many times as needed: select two different indexes i and j such that xi > xj hold, and then apply assignment xi = xi - xj. The goal is to make the sum of all numbers as small as possible.Please help Ciel to find this minimal sum. | [{"input": "2\r\n1 2\r\n", "output": ["2"]}, {"input": "3\r\n2 4 6\r\n", "output": ["6"]}, {"input": "2\r\n12 18\r\n", "output": ["12"]}, {"input": "5\r\n45 12 27 30 18\r\n", "output": ["15"]}, {"input": "2\r\n1 1\r\n", "output": ["2"]}, {"input": "2\r\n100 100\r\n", "output": ["200"]}, {"input": "2\r\n87 58\r\n", "output": ["58"]}, {"input": "39\r\n52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52\r\n", "output": ["2028"]}, {"input": "59\r\n96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96\r\n", "output": ["5664"]}, {"input": "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": ["10000"]}, {"input": "100\r\n70 70 77 42 98 84 56 91 35 21 7 70 77 77 56 63 14 84 56 14 77 77 63 70 14 7 28 91 63 49 21 84 98 56 77 98 98 84 98 14 7 56 49 28 91 98 7 56 14 91 14 98 49 28 98 14 98 98 14 70 35 28 63 28 49 63 63 56 91 98 35 42 42 35 63 35 42 14 63 21 77 56 42 77 35 91 56 21 28 84 56 70 70 91 98 70 84 63 21 98\r\n", "output": ["700"]}, {"input": "39\r\n63 21 21 42 21 63 21 84 42 21 84 63 42 63 84 84 84 42 42 84 21 63 42 63 42 42 63 42 42 63 84 42 21 84 21 63 42 21 42\r\n", "output": ["819"]}, {"input": "59\r\n70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70\r\n", "output": ["4130"]}, {"input": "87\r\n44 88 88 88 88 66 88 22 22 88 88 44 88 22 22 22 88 88 88 88 66 22 88 88 88 88 66 66 44 88 44 44 66 22 88 88 22 44 66 44 88 66 66 22 22 22 22 88 22 22 44 66 88 22 22 88 66 66 88 22 66 88 66 88 66 44 88 44 22 44 44 22 44 88 44 44 44 44 22 88 88 88 66 66 88 44 22\r\n", "output": ["1914"]}, {"input": "15\r\n63 63 63 63 63 63 63 63 63 63 63 63 63 63 63\r\n", "output": ["945"]}, {"input": "39\r\n63 77 21 14 14 35 21 21 70 42 21 70 28 77 28 77 7 42 63 7 98 49 98 84 35 70 70 91 14 42 98 7 42 7 98 42 56 35 91\r\n", "output": ["273"]}, {"input": "18\r\n18 18 18 36 36 36 54 72 54 36 72 54 36 36 36 36 18 36\r\n", "output": ["324"]}, {"input": "46\r\n71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71\r\n", "output": ["3266"]}, {"input": "70\r\n66 11 66 11 44 11 44 99 55 22 88 11 11 22 55 44 22 77 44 77 77 22 44 55 88 11 99 99 88 22 77 77 66 11 11 66 99 55 55 44 66 44 77 44 44 55 33 55 44 88 77 77 22 66 33 44 11 22 55 44 22 66 77 33 33 44 44 44 22 33\r\n", "output": ["770"]}, {"input": "10\r\n60 12 96 48 60 24 60 36 60 60\r\n", "output": ["120"]}, {"input": "20\r\n51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51\r\n", "output": ["1020"]}, {"input": "50\r\n58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58\r\n", "output": ["2900"]}, {"input": "98\r\n70 60 100 30 70 20 30 50 50 30 90 40 30 40 60 80 60 60 80 50 10 80 20 10 20 10 50 70 30 80 30 50 60 90 90 100 60 30 90 20 30 60 90 80 60 60 10 90 10 50 40 40 80 90 100 40 70 40 30 50 60 50 60 30 40 20 90 60 20 20 20 70 60 70 50 100 90 50 20 40 80 60 10 60 50 40 40 10 50 10 40 10 80 100 100 90 10 90\r\n", "output": ["980"]}, {"input": "100\r\n82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82\r\n", "output": ["8200"]}, {"input": "100\r\n11 87 77 93 3 54 21 93 9 71 37 23 69 85 74 3 48 99 51 31 56 19 21 96 39 6 4 4 29 69 100 42 1 22 81 53 48 49 81 61 10 7 40 61 7 71 51 59 79 44 50 35 95 80 83 8 98 40 18 94 84 49 52 74 66 69 39 37 100 44 38 62 2 80 46 31 35 53 5 60 21 49 63 55 20 53 80 53 66 34 23 92 77 50 86 63 65 24 12 70\r\n", "output": ["100"]}, {"input": "2\r\n100 1\r\n", "output": ["2"]}, {"input": "2\r\n18 30\r\n", "output": ["12"]}, {"input": "2\r\n3 5\r\n", "output": ["2"]}, {"input": "2\r\n1 10\r\n", "output": ["2"]}, {"input": "2\r\n8 5\r\n", "output": ["2"]}, {"input": "5\r\n2 3 5 8 18\r\n", "output": ["5"]}, {"input": "5\r\n2 4 1 6 8\r\n", "output": ["5"]}, {"input": "3\r\n12 10 5\r\n", "output": ["3"]}, {"input": "3\r\n6 10 15\r\n", "output": ["3"]}] | 100 | 100 | 100 | [{'input': '2\r\n1 10\r\n', 'output': ['2']}, {'input': '2\r\n87 58\r\n', 'output': ['58']}, {'input': '2\r\n3 5\r\n', 'output': ['2']}, {'input': '10\r\n60 12 96 48 60 24 60 36 60 60\r\n', 'output': ['120']}, {'input': '2\r\n100 1\r\n', 'output': ['2']}] | [{'input': '100\r\n82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82\r\n', 'output': ['8200']}, {'input': '2\r\n1 10\r\n', 'output': ['2']}, {'input': '5\r\n2 3 5 8 18\r\n', 'output': ['5']}, {'input': '3\r\n12 10 5\r\n', 'output': ['3']}, {'input': '2\r\n100 1\r\n', 'output': ['2']}] | [{'input': '2\r\n1 2\r\n', 'output': ['2']}, {'input': '46\r\n71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71\r\n', 'output': ['3266']}, {'input': '3\r\n6 10 15\r\n', 'output': ['3']}, {'input': '2\r\n12 18\r\n', 'output': ['12']}, {'input': '39\r\n63 77 21 14 14 35 21 21 70 42 21 70 28 77 28 77 7 42 63 7 98 49 98 84 35 70 70 91 14 42 98 7 42 7 98 42 56 35 91\r\n', 'output': ['273']}] | [{'input': '100\r\n11 87 77 93 3 54 21 93 9 71 37 23 69 85 74 3 48 99 51 31 56 19 21 96 39 6 4 4 29 69 100 42 1 22 81 53 48 49 81 61 10 7 40 61 7 71 51 59 79 44 50 35 95 80 83 8 98 40 18 94 84 49 52 74 66 69 39 37 100 44 38 62 2 80 46 31 35 53 5 60 21 49 63 55 20 53 80 53 66 34 23 92 77 50 86 63 65 24 12 70\r\n', 'output': ['100']}, {'input': '59\r\n70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70\r\n', 'output': ['4130']}, {'input': '2\r\n3 5\r\n', 'output': ['2']}, {'input': '2\r\n18 30\r\n', 'output': ['12']}, {'input': '15\r\n63 63 63 63 63 63 63 63 63 63 63 63 63 63 63\r\n', 'output': ['945']}] | [{'input': '2\r\n1 10\r\n', 'output': ['2']}, {'input': '18\r\n18 18 18 36 36 36 54 72 54 36 72 54 36 36 36 36 18 36\r\n', 'output': ['324']}, {'input': '2\r\n1 1\r\n', 'output': ['2']}, {'input': '2\r\n3 5\r\n', 'output': ['2']}, {'input': '98\r\n70 60 100 30 70 20 30 50 50 30 90 40 30 40 60 80 60 60 80 50 10 80 20 10 20 10 50 70 30 80 30 50 60 90 90 100 60 30 90 20 30 60 90 80 60 60 10 90 10 50 40 40 80 90 100 40 70 40 30 50 60 50 60 30 40 20 90 60 20 20 20 70 60 70 50 100 90 50 20 40 80 60 10 60 50 40 40 10 50 10 40 10 80 100 100 90 10 90\r\n', 'output': ['980']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 90 | 100 | 100 | 100 |
["2", "3"] | A single line contains integer n (1ββ€βnββ€β2000) β the number of buttons the lock has. | 6df251ac8bf27427a24bc23d64cb9884 | #include<stdio.h>
int main()
{
int n,i,l=0;
scanf("%d",&n);
for(i=1;i<n;i++) l=l+(n-i)*i;
printf("%d",l+n);
}
| ["3", "7"] | C | NoteConsider the first test sample. Manao can fail his first push and push the wrong button. In this case he will already be able to guess the right one with his second push. And his third push will push the second right button. Thus, in the worst-case scenario he will only need 3 pushes. | In a single line print the number of times Manao has to push a button in the worst-case scenario. | Manao is trying to open a rather challenging lock. The lock has n buttons on it and to open it, you should press the buttons in a certain order to open the lock. When you push some button, it either stays pressed into the lock (that means that you've guessed correctly and pushed the button that goes next in the sequence), or all pressed buttons return to the initial position. When all buttons are pressed into the lock at once, the lock opens.Consider an example with three buttons. Let's say that the opening sequence is: {2, 3, 1}. If you first press buttons 1 or 3, the buttons unpress immediately. If you first press button 2, it stays pressed. If you press 1 after 2, all buttons unpress. If you press 3 after 2, buttons 3 and 2 stay pressed. As soon as you've got two pressed buttons, you only need to press button 1 to open the lock.Manao doesn't know the opening sequence. But he is really smart and he is going to act in the optimal way. Calculate the number of times he's got to push a button in order to open the lock in the worst-case scenario. | [{"input": "2\r\n", "output": ["3"]}, {"input": "3\r\n", "output": ["7"]}, {"input": "4\r\n", "output": ["14"]}, {"input": "1\r\n", "output": ["1"]}, {"input": "10\r\n", "output": ["175"]}, {"input": "2000\r\n", "output": ["1333335000"]}, {"input": "1747\r\n", "output": ["888644743"]}, {"input": "889\r\n", "output": ["117099969"]}, {"input": "1999\r\n", "output": ["1331335999"]}, {"input": "914\r\n", "output": ["127259419"]}, {"input": "996\r\n", "output": ["164675486"]}, {"input": "17\r\n", "output": ["833"]}, {"input": "50\r\n", "output": ["20875"]}, {"input": "91\r\n", "output": ["125671"]}, {"input": "92\r\n", "output": ["129858"]}, {"input": "256\r\n", "output": ["2796416"]}, {"input": "512\r\n", "output": ["22370048"]}, {"input": "666\r\n", "output": ["49235271"]}, {"input": "667\r\n", "output": ["49457383"]}, {"input": "314\r\n", "output": ["5160119"]}, {"input": "1241\r\n", "output": ["318541121"]}, {"input": "1500\r\n", "output": ["562501250"]}, {"input": "1837\r\n", "output": ["1033182073"]}, {"input": "1000\r\n", "output": ["166667500"]}] | 100 | 100 | 100 | [{'input': '92\r\n', 'output': ['129858']}, {'input': '889\r\n', 'output': ['117099969']}, {'input': '256\r\n', 'output': ['2796416']}, {'input': '914\r\n', 'output': ['127259419']}, {'input': '17\r\n', 'output': ['833']}] | [{'input': '256\r\n', 'output': ['2796416']}, {'input': '10\r\n', 'output': ['175']}, {'input': '314\r\n', 'output': ['5160119']}, {'input': '2\r\n', 'output': ['3']}, {'input': '2000\r\n', 'output': ['1333335000']}] | [{'input': '1837\r\n', 'output': ['1033182073']}, {'input': '996\r\n', 'output': ['164675486']}, {'input': '1999\r\n', 'output': ['1331335999']}, {'input': '92\r\n', 'output': ['129858']}, {'input': '1241\r\n', 'output': ['318541121']}] | [{'input': '4\r\n', 'output': ['14']}, {'input': '92\r\n', 'output': ['129858']}, {'input': '2000\r\n', 'output': ['1333335000']}, {'input': '914\r\n', 'output': ['127259419']}, {'input': '889\r\n', 'output': ['117099969']}] | [{'input': '3\r\n', 'output': ['7']}, {'input': '1000\r\n', 'output': ['166667500']}, {'input': '914\r\n', 'output': ['127259419']}, {'input': '2000\r\n', 'output': ['1333335000']}, {'input': '2\r\n', 'output': ['3']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 91 | 100 | 100 | 100 |
["LLUUUR", "RRUULLDD"] | The first line of the input file contains the recording of the robot's movements. This recording is a non-empty string, consisting of uppercase Latin letters L, R, U and D, standing for movements left, right, up and down respectively. The length of the string does not exceed 100. | bb7805cc9d1cc907b64371b209c564b3 | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAXN 210
int main ()
{
static char data[MAXN];
static int a[MAXN][MAXN];
memset(a,0,sizeof(a));
scanf("%s",data);
int N = strlen(data);
int x = 105;
int y = 105;
a[x][y] = 1;
int i;
for (i = 2; i <= (N+1); i++)
{
int nx = x;
int ny = y;
if (data[i-2] == 'L') nx--;
else if (data[i-2] == 'R') nx++;
else if (data[i-2] == 'U') ny++;
else ny--;
if ((a[nx-1][ny] > 0) && (a[nx-1][ny] < (i-1)))
{
printf("BUG\n");
return 0;
}
if ((a[nx+1][ny] > 0) && (a[nx+1][ny] < (i-1)))
{
printf("BUG\n");
return 0;
}
if ((a[nx][ny-1] > 0) && (a[nx][ny-1] < (i-1)))
{
printf("BUG\n");
return 0;
}
if ((a[nx][ny+1] > 0) && (a[nx][ny+1] < (i-1)))
{
printf("BUG\n");
return 0;
}
if (a[nx][ny] > 0)
{
printf("BUG\n");
return 0;
}
a[nx][ny] = i;
x = nx;
y = ny;
}
printf("OK\n");
return 0;
}
| ["OK", "BUG"] | C | null | In the first line output the only word OK (if the above described map exists), or BUG (if such a map does not exist). | The whole world got obsessed with robots,and to keep pace with the progress, great Berland's programmer Draude decided to build his own robot. He was working hard at the robot. He taught it to walk the shortest path from one point to another, to record all its movements, but like in many Draude's programs, there was a bug β the robot didn't always walk the shortest path. Fortunately, the robot recorded its own movements correctly. Now Draude wants to find out when his robot functions wrong. Heh, if Draude only remembered the map of the field, where he tested the robot, he would easily say if the robot walked in the right direction or not. But the field map was lost never to be found, that's why he asks you to find out if there exist at least one map, where the path recorded by the robot is the shortest.The map is an infinite checkered field, where each square is either empty, or contains an obstruction. It is also known that the robot never tries to run into the obstruction. By the recorded robot's movements find out if there exist at least one such map, that it is possible to choose for the robot a starting square (the starting square should be empty) such that when the robot moves from this square its movements coincide with the recorded ones (the robot doesn't run into anything, moving along empty squares only), and the path from the starting square to the end one is the shortest.In one movement the robot can move into the square (providing there are no obstrutions in this square) that has common sides with the square the robot is currently in. | [{"input": "LLUUUR\r\n", "output": ["OK"]}, {"input": "RRUULLDD\r\n", "output": ["BUG"]}, {"input": "L\r\n", "output": ["OK"]}, {"input": "R\r\n", "output": ["OK"]}, {"input": "RR\r\n", "output": ["OK"]}, {"input": "DL\r\n", "output": ["OK"]}, {"input": "LD\r\n", "output": ["OK"]}, {"input": "RUL\r\n", "output": ["BUG"]}, {"input": "ULD\r\n", "output": ["BUG"]}, {"input": "DDR\r\n", "output": ["OK"]}, {"input": "RRDD\r\n", "output": ["OK"]}, {"input": "RRLR\r\n", "output": ["BUG"]}, {"input": "RRDL\r\n", "output": ["BUG"]}, {"input": "LRUD\r\n", "output": ["BUG"]}, {"input": "RDRLL\r\n", "output": ["BUG"]}, {"input": "DRDRD\r\n", "output": ["OK"]}, {"input": "ULURL\r\n", "output": ["BUG"]}, {"input": "LUUDU\r\n", "output": ["BUG"]}, {"input": "RDLUR\r\n", "output": ["BUG"]}, {"input": "DLDLDDRR\r\n", "output": ["OK"]}, {"input": "RDRDDD\r\n", "output": ["OK"]}, {"input": "UULLDLUR\r\n", "output": ["BUG"]}, {"input": "LULU\r\n", "output": ["OK"]}, {"input": "LLDDLDLLDDDLLLDLLLLLUU\r\n", "output": ["OK"]}, {"input": "URRRRRURRURUURRRRRDDDDLDDDRDDDDLLDLL\r\n", "output": ["OK"]}, {"input": "UL\r\n", "output": ["OK"]}, {"input": "UDR\r\n", "output": ["BUG"]}, {"input": "DDDR\r\n", "output": ["OK"]}, {"input": "UUUDU\r\n", "output": ["BUG"]}, {"input": "LULULL\r\n", "output": ["OK"]}, {"input": "DLURUUU\r\n", "output": ["BUG"]}, {"input": "UURUURRUUU\r\n", "output": ["OK"]}, {"input": "DDDDRDDLDDDDDDDRDDLD\r\n", "output": ["OK"]}, {"input": "URRRLULUURURLRLLLLULLRLRURLULRLULLULRRUU\r\n", "output": ["BUG"]}, {"input": "RURRRRLURRRURRUURRRRRRRRDDULULRRURRRDRRRRRRRRRRLDR\r\n", "output": ["BUG"]}, {"input": "RLRRRRRDRRDRRRRDLRRRRRRRDLRLDDLRRRRLDLDRDRRRRDRDRDRDLRRURRLRRRRDRRRRRRRRLDDRLRRDRRRRRRRDRDRLDRDDDRDR\r\n", "output": ["BUG"]}, {"input": "DDUL\r\n", "output": ["BUG"]}, {"input": "UUULLLLRDD\r\n", "output": ["BUG"]}, {"input": "LLLLLLLLRRRRDDDDDDDUUUUUU\r\n", "output": ["BUG"]}, {"input": "DDDDDDDDDDDDUUUUUUUUUUUURRRRRRRRRRRRRLLLLLLLLLLLLLLL\r\n", "output": ["BUG"]}, {"input": "DDDDDDDDDDDDDDDDDDDDDDDDDLLLLLLLLLLLLLLLLLLLLLLLLRRRRRRRRRRRRRRRRRRRRRRRRRRRUUUUUUUUUUUUUUUUUUUUUUUU\r\n", "output": ["BUG"]}, {"input": "DLUR\r\n", "output": ["BUG"]}, {"input": "UUUURDLLLL\r\n", "output": ["BUG"]}, {"input": "RRRRRRRRRRRURLLLLLLLLLLLL\r\n", "output": ["BUG"]}, {"input": "LLLLLLLLLLLLLLLLLLLLLLLLLLRUUUUUUUUUUUUUUUUUUUUUUUUU\r\n", "output": ["BUG"]}, {"input": "UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUURDRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\r\n", "output": ["BUG"]}, {"input": "DDLDRRR\r\n", "output": ["BUG"]}, {"input": "RRUULLD\r\n", "output": ["BUG"]}, {"input": "LUUUULLLLDDDDRRRD\r\n", "output": ["BUG"]}, {"input": "DDDDLLLDDDRRRUURRRR\r\n", "output": ["BUG"]}, {"input": "DDDDDDDLLDDRRURRRRRRR\r\n", "output": ["BUG"]}, {"input": "DDDDDDDDDDLLLLLLLLLLLDDDDDDDDDDDRRRRRRRRRRRUUUUUUUUUURRRRRRRRRR\r\n", "output": ["BUG"]}, {"input": "DDDLLLLLLLDDDDDDDRRRRRRRUUUUUURRR\r\n", "output": ["BUG"]}, {"input": "RRRUUULLLDD\r\n", "output": ["BUG"]}, {"input": "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDLLLLDDDDRRRRUUURRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\r\n", "output": ["BUG"]}, {"input": "RRRRRRRRRRRDDDDDDDDDDDDDDDDDDDRRRRRRRRRRRRRRRRRRRUUUUUUUUUUUUUUUUUUULLLLLLLLLLLLLLLLLLUUUUUUUUUUU\r\n", "output": ["BUG"]}] | 100 | 100 | 100 | [{'input': 'RURRRRLURRRURRUURRRRRRRRDDULULRRURRRDRRRRRRRRRRLDR\r\n', 'output': ['BUG']}, {'input': 'LULU\r\n', 'output': ['OK']}, {'input': 'DDLDRRR\r\n', 'output': ['BUG']}, {'input': 'LLLLLLLLLLLLLLLLLLLLLLLLLLRUUUUUUUUUUUUUUUUUUUUUUUUU\r\n', 'output': ['BUG']}, {'input': 'RRLR\r\n', 'output': ['BUG']}] | [{'input': 'RDRLL\r\n', 'output': ['BUG']}, {'input': 'LLLLLLLLLLLLLLLLLLLLLLLLLLRUUUUUUUUUUUUUUUUUUUUUUUUU\r\n', 'output': ['BUG']}, {'input': 'LUUUULLLLDDDDRRRD\r\n', 'output': ['BUG']}, {'input': 'UUUURDLLLL\r\n', 'output': ['BUG']}, {'input': 'DDR\r\n', 'output': ['OK']}] | [{'input': 'RRDD\r\n', 'output': ['OK']}, {'input': 'RRRRRRRRRRRDDDDDDDDDDDDDDDDDDDRRRRRRRRRRRRRRRRRRRUUUUUUUUUUUUUUUUUUULLLLLLLLLLLLLLLLLLUUUUUUUUUUU\r\n', 'output': ['BUG']}, {'input': 'DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDLLLLDDDDRRRRUUURRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\r\n', 'output': ['BUG']}, {'input': 'LULULL\r\n', 'output': ['OK']}, {'input': 'DDUL\r\n', 'output': ['BUG']}] | [{'input': 'DDR\r\n', 'output': ['OK']}, {'input': 'DDDDDDDLLDDRRURRRRRRR\r\n', 'output': ['BUG']}, {'input': 'DLURUUU\r\n', 'output': ['BUG']}, {'input': 'RDRDDD\r\n', 'output': ['OK']}, {'input': 'DDDDDDDDDDDDDDDDDDDDDDDDDLLLLLLLLLLLLLLLLLLLLLLLLRRRRRRRRRRRRRRRRRRRRRRRRRRRUUUUUUUUUUUUUUUUUUUUUUUU\r\n', 'output': ['BUG']}] | [{'input': 'LD\r\n', 'output': ['OK']}, {'input': 'LLUUUR\r\n', 'output': ['OK']}, {'input': 'RR\r\n', 'output': ['OK']}, {'input': 'DLURUUU\r\n', 'output': ['BUG']}, {'input': 'RDRDDD\r\n', 'output': ['OK']}] | 100 | 100 | 100 | 100 | 100 | 88.24 | 88.24 | 82.35 | 82.35 | 76.47 | 92.31 | 92.31 | 88.46 | 88.46 | 84.62 | 92 | 100 | 83.53 | 89.232 |
["2 4", "3 3"] | In a single line you are given two integers M and N β board sizes in squares (1ββ€βMββ€βNββ€β16). | e840e7bfe83764bee6186fcf92a1b5cd | #include<stdio.h>
#include<math.h>
int main ()
{
int M,N,X;
scanf("%d %d", &M, &N);
X=((M*N)/2);
printf("%d\n", X);
return 0;
}
/* 1490302257089 */
| ["4", "4"] | C | null | Output one number β the maximal number of dominoes, which can be placed. | You are given a rectangular board of MβΓβN squares. Also you are given an unlimited number of standard domino pieces of 2βΓβ1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions:1. Each domino completely covers two squares.2. No two dominoes overlap.3. Each domino lies entirely inside the board. It is allowed to touch the edges of the board.Find the maximum number of dominoes, which can be placed under these restrictions. | [{"input": "2 4\r\n", "output": ["4"]}, {"input": "3 3\r\n", "output": ["4"]}, {"input": "1 5\r\n", "output": ["2"]}, {"input": "1 6\r\n", "output": ["3"]}, {"input": "1 15\r\n", "output": ["7"]}, {"input": "1 16\r\n", "output": ["8"]}, {"input": "2 5\r\n", "output": ["5"]}, {"input": "2 6\r\n", "output": ["6"]}, {"input": "2 7\r\n", "output": ["7"]}, {"input": "2 14\r\n", "output": ["14"]}, {"input": "2 15\r\n", "output": ["15"]}, {"input": "1 4\r\n", "output": ["2"]}, {"input": "2 16\r\n", "output": ["16"]}, {"input": "3 5\r\n", "output": ["7"]}, {"input": "3 6\r\n", "output": ["9"]}, {"input": "3 10\r\n", "output": ["15"]}, {"input": "3 14\r\n", "output": ["21"]}, {"input": "3 15\r\n", "output": ["22"]}, {"input": "3 16\r\n", "output": ["24"]}, {"input": "5 7\r\n", "output": ["17"]}, {"input": "16 16\r\n", "output": ["128"]}, {"input": "15 16\r\n", "output": ["120"]}, {"input": "2 3\r\n", "output": ["3"]}, {"input": "15 15\r\n", "output": ["112"]}, {"input": "14 16\r\n", "output": ["112"]}, {"input": "11 13\r\n", "output": ["71"]}, {"input": "5 16\r\n", "output": ["40"]}, {"input": "8 15\r\n", "output": ["60"]}, {"input": "2 2\r\n", "output": ["2"]}, {"input": "3 4\r\n", "output": ["6"]}, {"input": "4 4\r\n", "output": ["8"]}, {"input": "1 1\r\n", "output": ["0"]}, {"input": "1 2\r\n", "output": ["1"]}, {"input": "1 3\r\n", "output": ["1"]}, {"input": "14 15\r\n", "output": ["105"]}] | 100 | 100 | 100 | [{'input': '2 4\r\n', 'output': ['4']}, {'input': '3 10\r\n', 'output': ['15']}, {'input': '14 15\r\n', 'output': ['105']}, {'input': '2 5\r\n', 'output': ['5']}, {'input': '2 7\r\n', 'output': ['7']}] | [{'input': '2 5\r\n', 'output': ['5']}, {'input': '1 6\r\n', 'output': ['3']}, {'input': '3 5\r\n', 'output': ['7']}, {'input': '8 15\r\n', 'output': ['60']}, {'input': '3 6\r\n', 'output': ['9']}] | [{'input': '1 16\r\n', 'output': ['8']}, {'input': '15 15\r\n', 'output': ['112']}, {'input': '3 5\r\n', 'output': ['7']}, {'input': '1 15\r\n', 'output': ['7']}, {'input': '3 14\r\n', 'output': ['21']}] | [{'input': '11 13\r\n', 'output': ['71']}, {'input': '4 4\r\n', 'output': ['8']}, {'input': '2 5\r\n', 'output': ['5']}, {'input': '2 14\r\n', 'output': ['14']}, {'input': '5 7\r\n', 'output': ['17']}] | [{'input': '15 16\r\n', 'output': ['120']}, {'input': '2 2\r\n', 'output': ['2']}, {'input': '16 16\r\n', 'output': ['128']}, {'input': '1 2\r\n', 'output': ['1']}, {'input': '5 16\r\n', 'output': ['40']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 93 | 100 | 100 | 100 |
["5 7 1 3 2 2", "5 5 2 3 1 1"] | The first line of the input contains six integers n,βm,βi,βj,βa,βb (1ββ€βn,βmββ€β106;Β 1ββ€βiββ€βn;Β 1ββ€βjββ€βm;Β 1ββ€βa,βbββ€β106). You can assume that the chessboard rows are numbered from 1 to n from top to bottom and the columns are numbered from 1 to m from left to right. Position (i,βj) in the statement is a chessboard cell on the intersection of the i-th row and the j-th column. You can consider that the corners are: (1,βm), (n,β1), (n,βm), (1,β1). | 51155e9bfa90e0ff29d049cedc3e1862 | #include<stdio.h>
long long int n,m,i,j,a,b;
int ab(int a)
{
if(a<0)
return -a;
return a;
}
int max(int a,int b)
{
if(a<b)
return b;
return a;
}
int min(int a,int b)
{
if(a>b)
return b;
return a;
}
int func(int u,int v)
{
if(i==u&&j==v)
return 0;
if(i+a>n&&i-a<=0)
return -1;
if(j+b>m&&j-b<=0)
return -1;
int x=ab(u-i),y=ab(v-j);
if(x%a!=0||y%b!=0)
return -1;
x=x/a;y=y/b;
if(x%2!=y%2)
return -1;
int t=max(x,y);
return t;
}
int main()
{
scanf("%lld%lld%lld%lld%lld%lld",&n,&m,&i,&j,&a,&b);
int ans=100000000;
int a=func(1,m);
if(a!=-1)
{
ans=min(ans,a);
}
a=func(n,1);
if(a!=-1)
{
ans=min(ans,a);
}
a=func(1,1);
if(a!=-1)
{
ans=min(ans,a);
}
a=func(n,m);
if(a!=-1)
{
ans=min(ans,a);
}
if(ans<100000000)
printf("%d",ans);
else
printf("Poor Inna and pony!");
return 0;
} | ["2", "Poor Inna and pony!"] | C | NoteNote to sample 1:Inna and the pony can move the candy to position (1β+β2,β3β+β2)β=β(3,β5), from there they can move it to positions (3β-β2,β5β+β2)β=β(1,β7) and (3β+β2,β5β+β2)β=β(5,β7). These positions correspond to the corner squares of the chess board. Thus, the answer to the test sample equals two. | In a single line print a single integer β the minimum number of moves needed to get the candy. If Inna and the pony cannot get the candy playing by Dima's rules, print on a single line "Poor Inna and pony!" without the quotes. | Dima and Inna are doing so great! At the moment, Inna is sitting on the magic lawn playing with a pink pony. Dima wanted to play too. He brought an nβΓβm chessboard, a very tasty candy and two numbers a and b.Dima put the chessboard in front of Inna and placed the candy in position (i,βj) on the board. The boy said he would give the candy if it reaches one of the corner cells of the board. He's got one more condition. There can only be actions of the following types: move the candy from position (x,βy) on the board to position (xβ-βa,βyβ-βb); move the candy from position (x,βy) on the board to position (xβ+βa,βyβ-βb); move the candy from position (x,βy) on the board to position (xβ-βa,βyβ+βb); move the candy from position (x,βy) on the board to position (xβ+βa,βyβ+βb). Naturally, Dima doesn't allow to move the candy beyond the chessboard borders.Inna and the pony started shifting the candy around the board. They wonder what is the minimum number of allowed actions that they need to perform to move the candy from the initial position (i,βj) to one of the chessboard corners. Help them cope with the task! | [{"input": "5 7 1 3 2 2\r\n", "output": ["2"]}, {"input": "5 5 2 3 1 1\r\n", "output": ["Poor Inna and pony!"]}, {"input": "1 1 1 1 1 1\r\n", "output": ["0"]}, {"input": "23000 15500 100 333 9 1\r\n", "output": ["15167"]}, {"input": "33999 99333 33000 99000 3 9\r\n", "output": ["333"]}, {"input": "5 7 1 3 1 2\r\n", "output": ["2"]}, {"input": "1 100 1 50 1 50\r\n", "output": ["Poor Inna and pony!"]}, {"input": "1000 1 1 1 1 500\r\n", "output": ["0"]}, {"input": "304 400 12 20 4 4\r\n", "output": ["95"]}, {"input": "1000000 1000000 1000000 1000000 1000000 1000000\r\n", "output": ["0"]}, {"input": "1000000 99999 12345 23456 23 54\r\n", "output": ["Poor Inna and pony!"]}, {"input": "50000 100000 500 1000 500 1000\r\n", "output": ["99"]}, {"input": "50000 100000 500 1000 500 2000\r\n", "output": ["Poor Inna and pony!"]}, {"input": "50000 100000 500 1000 500 500\r\n", "output": ["Poor Inna and pony!"]}, {"input": "99999 99999 1 2 1 1\r\n", "output": ["Poor Inna and pony!"]}, {"input": "5 4 2 3 2 2\r\n", "output": ["Poor Inna and pony!"]}, {"input": "5 4 2 3 1 1\r\n", "output": ["1"]}, {"input": "5 5 1 3 1 2\r\n", "output": ["Poor Inna and pony!"]}, {"input": "2347 2348 234 48 238 198\r\n", "output": ["Poor Inna and pony!"]}, {"input": "1000000 2 2 2 2 1\r\n", "output": ["499999"]}, {"input": "100 100 50 50 500 500\r\n", "output": ["Poor Inna and pony!"]}, {"input": "1000 2000 100 200 90 90\r\n", "output": ["20"]}, {"input": "1000 1000 10 15 10 5\r\n", "output": ["197"]}, {"input": "23000 15500 100 333 9 1\r\n", "output": ["15167"]}, {"input": "5 5 4 3 1 2\r\n", "output": ["1"]}, {"input": "5 5 4 4 1 1\r\n", "output": ["1"]}, {"input": "5 5 4 2 1 1\r\n", "output": ["1"]}, {"input": "3 3 2 2 2 2\r\n", "output": ["Poor Inna and pony!"]}, {"input": "5 8 4 1 2 1\r\n", "output": ["Poor Inna and pony!"]}, {"input": "5 8 4 2 1 2\r\n", "output": ["3"]}, {"input": "2 8 1 2 1 3\r\n", "output": ["2"]}, {"input": "1000000 1000000 500000 500000 1 1\r\n", "output": ["499999"]}, {"input": "500000 100000 400 80000 2 2\r\n", "output": ["249800"]}, {"input": "1004 999004 4 4 5 5\r\n", "output": ["199800"]}, {"input": "11 11 3 3 4 4\r\n", "output": ["2"]}, {"input": "100 100 70 5 1 1\r\n", "output": ["30"]}, {"input": "1 5 1 3 1 1\r\n", "output": ["Poor Inna and pony!"]}, {"input": "1 5 1 3 10 1\r\n", "output": ["Poor Inna and pony!"]}, {"input": "6 1 5 1 2 2\r\n", "output": ["Poor Inna and pony!"]}, {"input": "2 10 1 5 2 2\r\n", "output": ["Poor Inna and pony!"]}, {"input": "5 1 3 1 1 1\r\n", "output": ["Poor Inna and pony!"]}, {"input": "1000 1000 1 3 10000 1\r\n", "output": ["Poor Inna and pony!"]}, {"input": "2 6 1 2 2 2\r\n", "output": ["Poor Inna and pony!"]}, {"input": "2 6 1 2 6 2\r\n", "output": ["Poor Inna and pony!"]}, {"input": "7 1 5 1 2 2\r\n", "output": ["Poor Inna and pony!"]}, {"input": "2 20 2 5 2 2\r\n", "output": ["Poor Inna and pony!"]}, {"input": "4 4 3 4 1 5\r\n", "output": ["Poor Inna and pony!"]}] | 100 | 100 | 100 | [{'input': '4 4 3 4 1 5\r\n', 'output': ['Poor Inna and pony!']}, {'input': '23000 15500 100 333 9 1\r\n', 'output': ['15167']}, {'input': '304 400 12 20 4 4\r\n', 'output': ['95']}, {'input': '1000000 99999 12345 23456 23 54\r\n', 'output': ['Poor Inna and pony!']}, {'input': '1000000 1000000 500000 500000 1 1\r\n', 'output': ['499999']}] | [{'input': '5 5 4 4 1 1\r\n', 'output': ['1']}, {'input': '100 100 50 50 500 500\r\n', 'output': ['Poor Inna and pony!']}, {'input': '1000 1 1 1 1 500\r\n', 'output': ['0']}, {'input': '2 8 1 2 1 3\r\n', 'output': ['2']}, {'input': '5 5 4 3 1 2\r\n', 'output': ['1']}] | [{'input': '1000000 99999 12345 23456 23 54\r\n', 'output': ['Poor Inna and pony!']}, {'input': '1004 999004 4 4 5 5\r\n', 'output': ['199800']}, {'input': '2 8 1 2 1 3\r\n', 'output': ['2']}, {'input': '11 11 3 3 4 4\r\n', 'output': ['2']}, {'input': '3 3 2 2 2 2\r\n', 'output': ['Poor Inna and pony!']}] | [{'input': '11 11 3 3 4 4\r\n', 'output': ['2']}, {'input': '50000 100000 500 1000 500 500\r\n', 'output': ['Poor Inna and pony!']}, {'input': '7 1 5 1 2 2\r\n', 'output': ['Poor Inna and pony!']}, {'input': '1 100 1 50 1 50\r\n', 'output': ['Poor Inna and pony!']}, {'input': '500000 100000 400 80000 2 2\r\n', 'output': ['249800']}] | [{'input': '5 7 1 3 1 2\r\n', 'output': ['2']}, {'input': '1000000 1000000 1000000 1000000 1000000 1000000\r\n', 'output': ['0']}, {'input': '5 5 4 2 1 1\r\n', 'output': ['1']}, {'input': '23000 15500 100 333 9 1\r\n', 'output': ['15167']}, {'input': '3 3 2 2 2 2\r\n', 'output': ['Poor Inna and pony!']}] | 100 | 100 | 100 | 100 | 100 | 93.48 | 100 | 89.13 | 86.96 | 97.83 | 76.47 | 91.18 | 76.47 | 76.47 | 85.29 | 94 | 100 | 93.48 | 81.176 |
["42", "5"] | The only line contains an integer n (1ββ€βnββ€β10000). | 5d4f38ffd1849862623325fdbe06cd00 | #include<stdio.h>
int main()
{
int n,feet,tmp,inch;
scanf("%d",&n);
inch=n/3;
if(n%3==2)
{
inch++;
}
feet=inch/12;
inch=inch%12;
printf("%d %d\n",feet,inch);
return 0;
} | ["1 2", "0 2"] | C | null | Print two non-negative space-separated integers a and b, where a is the numbers of feet and b is the number of inches. | Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches.You are given a length equal to n centimeters. Your task is to convert it to feet and inches so that the number of feet was maximum. The result should be an integer rounded to the closest value containing an integral number of inches.Note that when you round up, 1 cm rounds up to 0 inches and 2 cm round up to 1 inch. | [{"input": "42\r\n", "output": ["1 2"]}, {"input": "5\r\n", "output": ["0 2"]}, {"input": "24\r\n", "output": ["0 8"]}, {"input": "1\r\n", "output": ["0 0"]}, {"input": "2\r\n", "output": ["0 1"]}, {"input": "3\r\n", "output": ["0 1"]}, {"input": "4\r\n", "output": ["0 1"]}, {"input": "8\r\n", "output": ["0 3"]}, {"input": "10\r\n", "output": ["0 3"]}, {"input": "12\r\n", "output": ["0 4"]}, {"input": "13\r\n", "output": ["0 4"]}, {"input": "100\r\n", "output": ["2 9"]}, {"input": "120\r\n", "output": ["3 4"]}, {"input": "199\r\n", "output": ["5 6"]}, {"input": "501\r\n", "output": ["13 11"]}, {"input": "1000\r\n", "output": ["27 9"]}, {"input": "1233\r\n", "output": ["34 3"]}, {"input": "9876\r\n", "output": ["274 4"]}, {"input": "9999\r\n", "output": ["277 9"]}, {"input": "10000\r\n", "output": ["277 9"]}, {"input": "35\r\n", "output": ["1 0"]}, {"input": "71\r\n", "output": ["2 0"]}] | 100 | 100 | 100 | [{'input': '100\r\n', 'output': ['2 9']}, {'input': '8\r\n', 'output': ['0 3']}, {'input': '1233\r\n', 'output': ['34 3']}, {'input': '1000\r\n', 'output': ['27 9']}, {'input': '10000\r\n', 'output': ['277 9']}] | [{'input': '501\r\n', 'output': ['13 11']}, {'input': '1000\r\n', 'output': ['27 9']}, {'input': '10\r\n', 'output': ['0 3']}, {'input': '3\r\n', 'output': ['0 1']}, {'input': '24\r\n', 'output': ['0 8']}] | [{'input': '199\r\n', 'output': ['5 6']}, {'input': '100\r\n', 'output': ['2 9']}, {'input': '1\r\n', 'output': ['0 0']}, {'input': '4\r\n', 'output': ['0 1']}, {'input': '8\r\n', 'output': ['0 3']}] | [{'input': '120\r\n', 'output': ['3 4']}, {'input': '9999\r\n', 'output': ['277 9']}, {'input': '4\r\n', 'output': ['0 1']}, {'input': '71\r\n', 'output': ['2 0']}, {'input': '9876\r\n', 'output': ['274 4']}] | [{'input': '9999\r\n', 'output': ['277 9']}, {'input': '120\r\n', 'output': ['3 4']}, {'input': '10000\r\n', 'output': ['277 9']}, {'input': '10\r\n', 'output': ['0 3']}, {'input': '4\r\n', 'output': ['0 1']}] | 100 | 100 | 100 | 100 | 100 | 100 | 88.89 | 100 | 100 | 88.89 | 100 | 50 | 100 | 100 | 50 | 95 | 100 | 95.556 | 80 |
["0 0 0 0 9\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n7 0 0 0 0", "0 43 21 18 2\n3 0 21 11 65\n5 2 0 1 4\n54 62 12 0 99\n87 64 81 33 0"] | The input consists of five lines, each line contains five space-separated integers: the j-th number in the i-th line shows gij (0ββ€βgijββ€β105). It is guaranteed that giiβ=β0 for all i. Assume that the students are numbered from 1 to 5. | be6d4df20e9a48d183dd8f34531df246 | #include<stdio.h>
int main()
{
int x[6][6];
int i,j,k,l,m;
for(i=0;i<5;++i)
{
for(j=0;j<5;++j)
scanf("%d",&x[i][j]);
}
int max=0;
for(i=0;i<5;++i)
{
for(j=0;j<5;++j)
{
if(i==j)
continue;
for(k=0;k<5;++k)
{
if(k==j || k==i)
continue;
for(l=0;l<5;++l)
{
if(l==k || l==j || l==i)
continue;
for(m=0;m<5;++m)
{
int temp=0;
if(m==l || m==k || m==j || m==i)
continue;
temp=x[i][j]+x[j][i]+x[k][l]+x[l][k]+x[j][k]+x[k][j]+x[l][m]+x[m][l]+x[k][l]+x[l][k]+x[l][m]+x[m][l];
//printf("%d\n",temp);
if(max<temp)
max=temp;
}
}
}
}
}
printf("%d",max);
return 0;
}
| ["32", "620"] | C | NoteIn the first sample, the optimal arrangement of the line is 23154. In this case, the total happiness equals:(g23β+βg32β+βg15β+βg51)β+β(g13β+βg31β+βg54β+βg45)β+β(g15β+βg51)β+β(g54β+βg45)β=β32. | Print a single integer β the maximum possible total happiness of the students. | Many students live in a dormitory. A dormitory is a whole new world of funny amusements and possibilities but it does have its drawbacks. There is only one shower and there are multiple students who wish to have a shower in the morning. That's why every morning there is a line of five people in front of the dormitory shower door. As soon as the shower opens, the first person from the line enters the shower. After a while the first person leaves the shower and the next person enters the shower. The process continues until everybody in the line has a shower.Having a shower takes some time, so the students in the line talk as they wait. At each moment of time the students talk in pairs: the (2iβ-β1)-th man in the line (for the current moment) talks with the (2i)-th one. Let's look at this process in more detail. Let's number the people from 1 to 5. Let's assume that the line initially looks as 23154 (person number 2 stands at the beginning of the line). Then, before the shower opens, 2 talks with 3, 1 talks with 5, 4 doesn't talk with anyone. Then 2 enters the shower. While 2 has a shower, 3 and 1 talk, 5 and 4 talk too. Then, 3 enters the shower. While 3 has a shower, 1 and 5 talk, 4 doesn't talk to anyone. Then 1 enters the shower and while he is there, 5 and 4 talk. Then 5 enters the shower, and then 4 enters the shower.We know that if students i and j talk, then the i-th student's happiness increases by gij and the j-th student's happiness increases by gji. Your task is to find such initial order of students in the line that the total happiness of all students will be maximum in the end. Please note that some pair of students may have a talk several times. In the example above students 1 and 5 talk while they wait for the shower to open and while 3 has a shower. | [{"input": "0 0 0 0 9\r\n0 0 0 0 0\r\n0 0 0 0 0\r\n0 0 0 0 0\r\n7 0 0 0 0\r\n", "output": ["32"]}, {"input": "0 43 21 18 2\r\n3 0 21 11 65\r\n5 2 0 1 4\r\n54 62 12 0 99\r\n87 64 81 33 0\r\n", "output": ["620"]}, {"input": "0 4 2 4 9\r\n6 0 2 5 0\r\n2 5 0 6 3\r\n6 3 3 0 10\r\n0 3 1 3 0\r\n", "output": ["63"]}, {"input": "0 65 90 2 32\r\n69 0 9 97 67\r\n77 97 0 16 84\r\n18 50 94 0 63\r\n69 12 82 16 0\r\n", "output": ["947"]}, {"input": "0 70 10 0 0\r\n70 0 50 90 0\r\n10 50 0 80 0\r\n0 90 80 0 100\r\n0 0 0 100 0\r\n", "output": ["960"]}, {"input": "0 711 647 743 841\r\n29 0 109 38 682\r\n329 393 0 212 512\r\n108 56 133 0 579\r\n247 92 933 164 0\r\n", "output": ["6265"]}, {"input": "0 9699 6962 6645 7790\r\n9280 0 6215 8661 6241\r\n2295 7817 0 7373 9681\r\n693 6298 1381 0 4633\r\n7626 3761 694 4073 0\r\n", "output": ["93667"]}, {"input": "0 90479 71577 33797 88848\r\n45771 0 96799 78707 72708\r\n5660 26421 0 10991 22757\r\n78919 24804 90645 0 48665\r\n92787 43671 38727 17302 0\r\n", "output": ["860626"]}, {"input": "0 61256 85109 94834 32902\r\n55269 0 67023 1310 85444\r\n23497 84998 0 55618 80701\r\n30324 1713 62127 0 55041\r\n47799 52448 40072 28971 0\r\n", "output": ["822729"]}, {"input": "0 7686 20401 55871 74372\r\n29526 0 15486 2152 84700\r\n27854 30093 0 62418 14297\r\n43903 76036 36194 0 50522\r\n29743 9945 38831 75882 0\r\n", "output": ["605229"]}, {"input": "0 5271 65319 64976 13673\r\n80352 0 41169 66004 47397\r\n33603 44407 0 55079 36122\r\n4277 9834 92810 0 80276\r\n1391 1145 92132 51595 0\r\n", "output": ["744065"]}, {"input": "0 75763 33154 32389 12897\r\n5095 0 6375 61517 46063\r\n35354 82789 0 24814 310\r\n37373 45993 61355 0 76865\r\n24383 84258 71887 71430 0\r\n", "output": ["714904"]}, {"input": "0 89296 32018 98206 22395\r\n15733 0 69391 74253 50419\r\n80450 89589 0 20583 51716\r\n38629 93129 67730 0 69703\r\n44054 83018 21382 64478 0\r\n", "output": ["874574"]}, {"input": "0 14675 94714 27735 99544\r\n45584 0 43621 94734 66110\r\n72838 45781 0 47389 99394\r\n75870 95368 33311 0 63379\r\n21974 70489 53797 23747 0\r\n", "output": ["974145"]}, {"input": "0 9994 14841 63916 37926\r\n80090 0 90258 96988 18217\r\n674 69024 0 17641 54436\r\n35046 21380 14213 0 67188\r\n49360 19086 68337 70856 0\r\n", "output": ["801116"]}, {"input": "0 28287 52158 19163 10096\r\n93438 0 19260 88892 12429\r\n22525 60034 0 78163 18126\r\n11594 8506 56066 0 17732\r\n59561 82486 23419 57406 0\r\n", "output": ["654636"]}, {"input": "0 35310 30842 63415 91022\r\n30553 0 25001 38944 92355\r\n48906 33736 0 96880 80893\r\n80507 79652 45299 0 38212\r\n72488 77736 19203 56436 0\r\n", "output": ["953303"]}, {"input": "0 42865 18485 37168 43099\r\n41476 0 58754 73410 51163\r\n76093 44493 0 51611 93773\r\n87223 80979 58422 0 63327\r\n51215 63346 84797 52809 0\r\n", "output": ["864938"]}, {"input": "0 63580 51022 25392 84354\r\n39316 0 17516 63801 92440\r\n5447 2074 0 11758 4772\r\n26329 55642 62442 0 75330\r\n6164 83831 10741 15214 0\r\n", "output": ["738415"]}, {"input": "0 0 0 0 0\r\n0 0 0 0 0\r\n0 0 0 0 0\r\n0 0 0 0 0\r\n0 0 0 0 0\r\n", "output": ["0"]}, {"input": "0 1 1 1 0\r\n1 0 0 1 0\r\n0 1 0 0 1\r\n1 1 0 0 0\r\n1 0 0 1 0\r\n", "output": ["10"]}, {"input": "0 3 6 9 8\r\n2 0 8 7 7\r\n4 6 0 6 1\r\n9 0 3 0 6\r\n6 5 0 2 0\r\n", "output": ["90"]}, {"input": "0 97 67 53 6\r\n96 0 100 57 17\r\n27 79 0 66 16\r\n89 46 71 0 28\r\n27 26 27 12 0\r\n", "output": ["926"]}, {"input": "0 670 904 349 56\r\n446 0 941 590 993\r\n654 888 0 423 752\r\n16 424 837 0 433\r\n418 655 459 897 0\r\n", "output": ["9752"]}, {"input": "0 4109 129 1340 7124\r\n7815 0 8991 2828 909\r\n5634 799 0 5691 9604\r\n3261 7013 8062 0 5160\r\n2433 4742 694 4786 0\r\n", "output": ["69867"]}, {"input": "0 14299 32984 96001 30445\r\n77723 0 75669 14101 55389\r\n30897 9956 0 52675 29987\r\n36518 90812 92955 0 64020\r\n91242 50085 86272 62454 0\r\n", "output": ["783459"]}, {"input": "0 46183 30304 63049 13191\r\n37244 0 23076 12594 43885\r\n98470 1788 0 37335 7775\r\n33822 50804 27921 0 56734\r\n38313 67579 77714 46687 0\r\n", "output": ["666175"]}, {"input": "0 39037 87960 13497 38526\r\n5528 0 44220 23338 92550\r\n87887 86544 0 30269 82845\r\n24590 60325 90979 0 20186\r\n64959 69875 93564 68355 0\r\n", "output": ["950600"]}, {"input": "0 27677 88187 87515 82582\r\n98177 0 22852 28214 99977\r\n52662 14066 0 79760 68188\r\n56883 30561 91843 0 79777\r\n12461 14821 29284 54372 0\r\n", "output": ["878207"]}, {"input": "0 37330 91942 67667 42061\r\n1978 0 84218 17 10834\r\n11303 6279 0 48597 26591\r\n82688 5437 34983 0 92556\r\n79574 32231 23167 16637 0\r\n", "output": ["718057"]}, {"input": "0 3 0 0 0\r\n3 0 2 0 0\r\n0 2 0 1 0\r\n0 0 1 0 1\r\n0 0 0 1 0\r\n", "output": ["24"]}] | 100 | 100 | 100 | [{'input': '0 27677 88187 87515 82582\r\n98177 0 22852 28214 99977\r\n52662 14066 0 79760 68188\r\n56883 30561 91843 0 79777\r\n12461 14821 29284 54372 0\r\n', 'output': ['878207']}, {'input': '0 5271 65319 64976 13673\r\n80352 0 41169 66004 47397\r\n33603 44407 0 55079 36122\r\n4277 9834 92810 0 80276\r\n1391 1145 92132 51595 0\r\n', 'output': ['744065']}, {'input': '0 28287 52158 19163 10096\r\n93438 0 19260 88892 12429\r\n22525 60034 0 78163 18126\r\n11594 8506 56066 0 17732\r\n59561 82486 23419 57406 0\r\n', 'output': ['654636']}, {'input': '0 14675 94714 27735 99544\r\n45584 0 43621 94734 66110\r\n72838 45781 0 47389 99394\r\n75870 95368 33311 0 63379\r\n21974 70489 53797 23747 0\r\n', 'output': ['974145']}, {'input': '0 63580 51022 25392 84354\r\n39316 0 17516 63801 92440\r\n5447 2074 0 11758 4772\r\n26329 55642 62442 0 75330\r\n6164 83831 10741 15214 0\r\n', 'output': ['738415']}] | [{'input': '0 28287 52158 19163 10096\r\n93438 0 19260 88892 12429\r\n22525 60034 0 78163 18126\r\n11594 8506 56066 0 17732\r\n59561 82486 23419 57406 0\r\n', 'output': ['654636']}, {'input': '0 1 1 1 0\r\n1 0 0 1 0\r\n0 1 0 0 1\r\n1 1 0 0 0\r\n1 0 0 1 0\r\n', 'output': ['10']}, {'input': '0 90479 71577 33797 88848\r\n45771 0 96799 78707 72708\r\n5660 26421 0 10991 22757\r\n78919 24804 90645 0 48665\r\n92787 43671 38727 17302 0\r\n', 'output': ['860626']}, {'input': '0 70 10 0 0\r\n70 0 50 90 0\r\n10 50 0 80 0\r\n0 90 80 0 100\r\n0 0 0 100 0\r\n', 'output': ['960']}, {'input': '0 9699 6962 6645 7790\r\n9280 0 6215 8661 6241\r\n2295 7817 0 7373 9681\r\n693 6298 1381 0 4633\r\n7626 3761 694 4073 0\r\n', 'output': ['93667']}] | [{'input': '0 0 0 0 0\r\n0 0 0 0 0\r\n0 0 0 0 0\r\n0 0 0 0 0\r\n0 0 0 0 0\r\n', 'output': ['0']}, {'input': '0 46183 30304 63049 13191\r\n37244 0 23076 12594 43885\r\n98470 1788 0 37335 7775\r\n33822 50804 27921 0 56734\r\n38313 67579 77714 46687 0\r\n', 'output': ['666175']}, {'input': '0 28287 52158 19163 10096\r\n93438 0 19260 88892 12429\r\n22525 60034 0 78163 18126\r\n11594 8506 56066 0 17732\r\n59561 82486 23419 57406 0\r\n', 'output': ['654636']}, {'input': '0 4109 129 1340 7124\r\n7815 0 8991 2828 909\r\n5634 799 0 5691 9604\r\n3261 7013 8062 0 5160\r\n2433 4742 694 4786 0\r\n', 'output': ['69867']}, {'input': '0 14299 32984 96001 30445\r\n77723 0 75669 14101 55389\r\n30897 9956 0 52675 29987\r\n36518 90812 92955 0 64020\r\n91242 50085 86272 62454 0\r\n', 'output': ['783459']}] | [{'input': '0 1 1 1 0\r\n1 0 0 1 0\r\n0 1 0 0 1\r\n1 1 0 0 0\r\n1 0 0 1 0\r\n', 'output': ['10']}, {'input': '0 39037 87960 13497 38526\r\n5528 0 44220 23338 92550\r\n87887 86544 0 30269 82845\r\n24590 60325 90979 0 20186\r\n64959 69875 93564 68355 0\r\n', 'output': ['950600']}, {'input': '0 97 67 53 6\r\n96 0 100 57 17\r\n27 79 0 66 16\r\n89 46 71 0 28\r\n27 26 27 12 0\r\n', 'output': ['926']}, {'input': '0 4109 129 1340 7124\r\n7815 0 8991 2828 909\r\n5634 799 0 5691 9604\r\n3261 7013 8062 0 5160\r\n2433 4742 694 4786 0\r\n', 'output': ['69867']}, {'input': '0 670 904 349 56\r\n446 0 941 590 993\r\n654 888 0 423 752\r\n16 424 837 0 433\r\n418 655 459 897 0\r\n', 'output': ['9752']}] | [{'input': '0 4109 129 1340 7124\r\n7815 0 8991 2828 909\r\n5634 799 0 5691 9604\r\n3261 7013 8062 0 5160\r\n2433 4742 694 4786 0\r\n', 'output': ['69867']}, {'input': '0 670 904 349 56\r\n446 0 941 590 993\r\n654 888 0 423 752\r\n16 424 837 0 433\r\n418 655 459 897 0\r\n', 'output': ['9752']}, {'input': '0 65 90 2 32\r\n69 0 9 97 67\r\n77 97 0 16 84\r\n18 50 94 0 63\r\n69 12 82 16 0\r\n', 'output': ['947']}, {'input': '0 70 10 0 0\r\n70 0 50 90 0\r\n10 50 0 80 0\r\n0 90 80 0 100\r\n0 0 0 100 0\r\n', 'output': ['960']}, {'input': '0 5271 65319 64976 13673\r\n80352 0 41169 66004 47397\r\n33603 44407 0 55079 36122\r\n4277 9834 92810 0 80276\r\n1391 1145 92132 51595 0\r\n', 'output': ['744065']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 96 | 100 | 100 | 100 |
["1 2", "0 5", "2 2"] | The input file consists of a single line containing two space-separated numbers n and m (0ββ€βn,βmββ€β105) β the number of the grown-ups and the number of the children in the bus, correspondingly. | 1e865eda33afe09302bda9077d613763 | #include<stdio.h>
int main() {
int M,N,min,max;
scanf("%d%d",&N,&M);
if(M==0 && N==0)
printf("0 0\n");
else if(N==0)
printf("Impossible\n");
else {
if(M==0) {
min=N;
max=N;
}
else {
if(N>=M) {
min=N;
max=N+M-1;
}
else {
min=M;
max=N+M-1;
}
}
printf("%d %d\n",min,max);
}
return 0;
}
| ["2 2", "Impossible", "2 3"] | C | NoteIn the first sample a grown-up rides with two children and pays two rubles.In the second sample there are only children in the bus, so the situation is impossible. In the third sample there are two cases: Each of the two grown-ups rides with one children and pays one ruble for the tickets. In this case the passengers pay two rubles in total. One of the grown-ups ride with two children's and pays two rubles, the another one rides alone and pays one ruble for himself. So, they pay three rubles in total. | If n grown-ups and m children could have ridden in the bus, then print on a single line two space-separated integers β the minimum and the maximum possible total bus fare, correspondingly. Otherwise, print "Impossible" (without the quotes). | One day Vasya heard a story: "In the city of High Bertown a bus number 62 left from the bus station. It had n grown-ups and m kids..."The latter events happen to be of no importance to us. Vasya is an accountant and he loves counting money. So he wondered what maximum and minimum sum of money these passengers could have paid for the ride.The bus fare equals one berland ruble in High Bertown. However, not everything is that easy β no more than one child can ride for free with each grown-up passenger. That means that a grown-up passenger who rides with his k (kβ>β0) children, pays overall k rubles: a ticket for himself and (kβ-β1) tickets for his children. Also, a grown-up can ride without children, in this case he only pays one ruble.We know that in High Bertown children can't ride in a bus unaccompanied by grown-ups.Help Vasya count the minimum and the maximum sum in Berland rubles, that all passengers of this bus could have paid in total. | [{"input": "1 2\r\n", "output": ["2 2"]}, {"input": "0 5\r\n", "output": ["Impossible"]}, {"input": "2 2\r\n", "output": ["2 3"]}, {"input": "2 7\r\n", "output": ["7 8"]}, {"input": "4 10\r\n", "output": ["10 13"]}, {"input": "6 0\r\n", "output": ["6 6"]}, {"input": "7 1\r\n", "output": ["7 7"]}, {"input": "0 0\r\n", "output": ["0 0"]}, {"input": "71 24\r\n", "output": ["71 94"]}, {"input": "16 70\r\n", "output": ["70 85"]}, {"input": "0 1\r\n", "output": ["Impossible"]}, {"input": "1 0\r\n", "output": ["1 1"]}, {"input": "1 1\r\n", "output": ["1 1"]}, {"input": "63 82\r\n", "output": ["82 144"]}, {"input": "8 26\r\n", "output": ["26 33"]}, {"input": "21 27\r\n", "output": ["27 47"]}, {"input": "0 38\r\n", "output": ["Impossible"]}, {"input": "46 84\r\n", "output": ["84 129"]}, {"input": "59 96\r\n", "output": ["96 154"]}, {"input": "63028 0\r\n", "output": ["63028 63028"]}, {"input": "9458 0\r\n", "output": ["9458 9458"]}, {"input": "80236 0\r\n", "output": ["80236 80236"]}, {"input": "26666 0\r\n", "output": ["26666 26666"]}, {"input": "59617 0\r\n", "output": ["59617 59617"]}, {"input": "0 6048\r\n", "output": ["Impossible"]}, {"input": "63028 28217\r\n", "output": ["63028 91244"]}, {"input": "9458 39163\r\n", "output": ["39163 48620"]}, {"input": "80236 14868\r\n", "output": ["80236 95103"]}, {"input": "26666 52747\r\n", "output": ["52747 79412"]}, {"input": "59617 28452\r\n", "output": ["59617 88068"]}, {"input": "6048 4158\r\n", "output": ["6048 10205"]}, {"input": "76826 4210\r\n", "output": ["76826 81035"]}, {"input": "23256 15156\r\n", "output": ["23256 38411"]}, {"input": "56207 53035\r\n", "output": ["56207 109241"]}, {"input": "2637 28740\r\n", "output": ["28740 31376"]}, {"input": "73415 4445\r\n", "output": ["73415 77859"]}, {"input": "82019 4498\r\n", "output": ["82019 86516"]}, {"input": "28449 80204\r\n", "output": ["80204 108652"]}, {"input": "99227 53323\r\n", "output": ["99227 152549"]}, {"input": "45657 29028\r\n", "output": ["45657 74684"]}, {"input": "78608 4733\r\n", "output": ["78608 83340"]}, {"input": "25038 4786\r\n", "output": ["25038 29823"]}, {"input": "95816 80492\r\n", "output": ["95816 176307"]}, {"input": "42246 94024\r\n", "output": ["94024 136269"]}, {"input": "0 100000\r\n", "output": ["Impossible"]}, {"input": "100000 0\r\n", "output": ["100000 100000"]}, {"input": "1 100000\r\n", "output": ["100000 100000"]}, {"input": "100000 1\r\n", "output": ["100000 100000"]}, {"input": "63028 63028\r\n", "output": ["63028 126055"]}, {"input": "9458 9458\r\n", "output": ["9458 18915"]}, {"input": "80236 80236\r\n", "output": ["80236 160471"]}, {"input": "26666 26666\r\n", "output": ["26666 53331"]}, {"input": "59617 59617\r\n", "output": ["59617 119233"]}, {"input": "100000 100000\r\n", "output": ["100000 199999"]}] | 100 | 100 | 100 | [{'input': '99227 53323\r\n', 'output': ['99227 152549']}, {'input': '1 100000\r\n', 'output': ['100000 100000']}, {'input': '63028 63028\r\n', 'output': ['63028 126055']}, {'input': '0 100000\r\n', 'output': ['Impossible']}, {'input': '71 24\r\n', 'output': ['71 94']}] | [{'input': '26666 52747\r\n', 'output': ['52747 79412']}, {'input': '1 0\r\n', 'output': ['1 1']}, {'input': '73415 4445\r\n', 'output': ['73415 77859']}, {'input': '63 82\r\n', 'output': ['82 144']}, {'input': '1 100000\r\n', 'output': ['100000 100000']}] | [{'input': '21 27\r\n', 'output': ['27 47']}, {'input': '45657 29028\r\n', 'output': ['45657 74684']}, {'input': '63 82\r\n', 'output': ['82 144']}, {'input': '100000 1\r\n', 'output': ['100000 100000']}, {'input': '63028 63028\r\n', 'output': ['63028 126055']}] | [{'input': '4 10\r\n', 'output': ['10 13']}, {'input': '42246 94024\r\n', 'output': ['94024 136269']}, {'input': '1 2\r\n', 'output': ['2 2']}, {'input': '59617 59617\r\n', 'output': ['59617 119233']}, {'input': '25038 4786\r\n', 'output': ['25038 29823']}] | [{'input': '23256 15156\r\n', 'output': ['23256 38411']}, {'input': '100000 1\r\n', 'output': ['100000 100000']}, {'input': '80236 14868\r\n', 'output': ['80236 95103']}, {'input': '80236 0\r\n', 'output': ['80236 80236']}, {'input': '63028 63028\r\n', 'output': ['63028 126055']}] | 100 | 100 | 100 | 100 | 100 | 81.25 | 87.5 | 75 | 75 | 75 | 60 | 80 | 50 | 50 | 70 | 97 | 100 | 78.75 | 62 |
["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 <stdio.h>
const long long int base = 1000000007;
long long int sq(int x, int y) {
long long int i, a;
a = 1;
for (i = 0; i < y; i++) {
a = (a * x) % base;
}
return a;
}
int main() {
int n, m, k;
scanf("%d%d%d", &n, &m, &k);
if (k == 1 || k > n) printf("%I64d", sq(m, n));
else if (k == n) printf("%I64d", sq(m, (n+1)/2));
else if (k%2 == 1) printf("%I64d", sq(m, 2));
else printf("%d", 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': '7 4 20\r\n', 'output': ['16384']}, {'input': '1 1 1\r\n', 'output': ['1']}, {'input': '8 13 9\r\n', 'output': ['815730721']}, {'input': '10 5 1\r\n', 'output': ['9765625']}, {'input': '10 10 10\r\n', 'output': ['100000']}] | [{'input': '1321 95 2\r\n', 'output': ['95']}, {'input': '1451 239 1451\r\n', 'output': ['968856942']}, {'input': '1 1 1\r\n', 'output': ['1']}, {'input': '1000 2 1001\r\n', 'output': ['688423210']}, {'input': '2000 2 10\r\n', 'output': ['2']}] | [{'input': '3 1000 3\r\n', 'output': ['1000000']}, {'input': '1000 1000 1\r\n', 'output': ['524700271']}, {'input': '1230 987 1\r\n', 'output': ['890209975']}, {'input': '1678 1999 1234\r\n', 'output': ['1999']}, {'input': '10 10 10\r\n', 'output': ['100000']}] | [{'input': '4 4 4\r\n', 'output': ['16']}, {'input': '1501 893 1501\r\n', 'output': ['889854713']}, {'input': '15 1 15\r\n', 'output': ['1']}, {'input': '2000 1000 3\r\n', 'output': ['1000000']}, {'input': '4 256 1\r\n', 'output': ['294967268']}] | [{'input': '777 1 777\r\n', 'output': ['1']}, {'input': '5 2 4\r\n', 'output': ['2']}, {'input': '1 1 1\r\n', 'output': ['1']}, {'input': '200 200 200\r\n', 'output': ['104842676']}, {'input': '239 123 239\r\n', 'output': ['221051222']}] | 100 | 100 | 100 | 100 | 100 | 83.33 | 100 | 100 | 91.67 | 100 | 70 | 90 | 80 | 80 | 80 | 98 | 100 | 95 | 80 |
["4"] | The only line contains an integer n (2ββ€βnββ€β1012), the number of vertices in the graph. | a98f0d924ea52cafe0048f213f075891 | #include<stdio.h>
int main()
{
long long int i=0,n,count=0,temp,mod,M=1;
scanf("%lld",&n);
while(1)
{
// printf("%lld\n", i);
M=M*2;
mod=n%M;
temp=n/M;
// printf("%lld %lld %lld\n",temp , mod,M);
if(mod>M/2)
count+=(M/2)*(temp+1);
else{
count+=(M/2)*(temp);
}
if(temp<=0)
break;
i++;
}
printf("%lld\n", count);
return 0;
}
| ["4"] | C | NoteIn the first sample: The weight of the minimum spanning tree is 1+2+1=4. | The only line contains an integer x, the weight of the graph's minimum spanning tree. | Ehab is interested in the bitwise-xor operation and the special graphs. Mahmoud gave him a problem that combines both. He has a complete graph consisting of n vertices numbered from 0 to nβ-β1. For all 0ββ€βuβ<βvβ<βn, vertex u and vertex v are connected with an undirected edge that has weight (where is the bitwise-xor operation). Can you find the weight of the minimum spanning tree of that graph?You can read about complete graphs in https://en.wikipedia.org/wiki/Complete_graphYou can read about the minimum spanning tree in https://en.wikipedia.org/wiki/Minimum_spanning_treeThe weight of the minimum spanning tree is the sum of the weights on the edges included in it. | [{"input": "4\r\n", "output": ["4"]}, {"input": "10\r\n", "output": ["21"]}, {"input": "2\r\n", "output": ["1"]}, {"input": "1000000000000\r\n", "output": ["20140978692096"]}, {"input": "999999999999\r\n", "output": ["20140978692095"]}, {"input": "23131234\r\n", "output": ["293058929"]}, {"input": "100000\r\n", "output": ["877968"]}, {"input": "1024\r\n", "output": ["5120"]}, {"input": "536870912\r\n", "output": ["7784628224"]}, {"input": "536870911\r\n", "output": ["7784628223"]}, {"input": "536870913\r\n", "output": ["8321499136"]}, {"input": "123456789\r\n", "output": ["1680249144"]}, {"input": "200\r\n", "output": ["844"]}, {"input": "3\r\n", "output": ["3"]}, {"input": "5\r\n", "output": ["8"]}, {"input": "6\r\n", "output": ["9"]}, {"input": "7\r\n", "output": ["11"]}, {"input": "1000\r\n", "output": ["5052"]}, {"input": "12000\r\n", "output": ["84624"]}, {"input": "65536\r\n", "output": ["524288"]}, {"input": "1048576\r\n", "output": ["10485760"]}, {"input": "8\r\n", "output": ["12"]}, {"input": "549755813888\r\n", "output": ["10720238370816"]}, {"input": "549755813887\r\n", "output": ["10720238370815"]}, {"input": "549755813889\r\n", "output": ["11269994184704"]}] | 100 | 100 | 100 | [{'input': '65536\r\n', 'output': ['524288']}, {'input': '999999999999\r\n', 'output': ['20140978692095']}, {'input': '123456789\r\n', 'output': ['1680249144']}, {'input': '200\r\n', 'output': ['844']}, {'input': '549755813889\r\n', 'output': ['11269994184704']}] | [{'input': '23131234\r\n', 'output': ['293058929']}, {'input': '2\r\n', 'output': ['1']}, {'input': '7\r\n', 'output': ['11']}, {'input': '8\r\n', 'output': ['12']}, {'input': '536870912\r\n', 'output': ['7784628224']}] | [{'input': '5\r\n', 'output': ['8']}, {'input': '1048576\r\n', 'output': ['10485760']}, {'input': '200\r\n', 'output': ['844']}, {'input': '12000\r\n', 'output': ['84624']}, {'input': '1000\r\n', 'output': ['5052']}] | [{'input': '1048576\r\n', 'output': ['10485760']}, {'input': '1000000000000\r\n', 'output': ['20140978692096']}, {'input': '5\r\n', 'output': ['8']}, {'input': '123456789\r\n', 'output': ['1680249144']}, {'input': '2\r\n', 'output': ['1']}] | [{'input': '999999999999\r\n', 'output': ['20140978692095']}, {'input': '123456789\r\n', 'output': ['1680249144']}, {'input': '2\r\n', 'output': ['1']}, {'input': '10\r\n', 'output': ['21']}, {'input': '6\r\n', 'output': ['9']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 99 | 100 | 100 | 100 |
["5 1", "2 2", "3 2", "11 5", "37 63"] | The first line contains two space-separated integers n and C, 1ββ€βnββ€β500000, 1ββ€βCββ€β200000. | e63c70a9c96a94bce99618f2e695f83a | #include <stdio.h>
int mod_inv(int a, int p){
int y = p-2;
int res = 1;
while(y!=0){
if(y&1){
res = ((long long)res * a)%p;
}
a = ((long long)a*a)%p;
y = y>>1;
}
return res;
}
int main(void) {
// your code goes here
int n,c,i;
scanf("%d %d",&n,&c);
int res = c;
int prev = c;
int p = 1000003;
for(i=2; i<=n ;i++){
prev = ((((long long)(c+i-1)*prev)%p)*mod_inv(i,p))%p;
res = (res + prev)%p;
}
printf("%d\n",res);
return 0;
} | ["5", "5", "9", "4367", "230574"] | C | NoteThe number 106β+β3 is prime.In the second sample case, the five walls are: B BB., .B, BB, B., and .BIn the third sample case, the nine walls are the five as in the second sample case and in addition the following four: B BB B B BB., .B, BB, and BB | Print the number of different walls that Heidi could build, modulo 106β+β3. | Heidi the Cow is aghast: cracks in the northern Wall? Zombies gathering outside, forming groups, preparing their assault? This must not happen! Quickly, she fetches her HC2 (Handbook of Crazy Constructions) and looks for the right chapter:How to build a wall: Take a set of bricks. Select one of the possible wall designs. Computing the number of possible designs is left as an exercise to the reader. Place bricks on top of each other, according to the chosen design. This seems easy enough. But Heidi is a Coding Cow, not a Constructing Cow. Her mind keeps coming back to point 2b. Despite the imminent danger of a zombie onslaught, she wonders just how many possible walls she could build with up to n bricks.A wall is a set of wall segments as defined in the easy version. How many different walls can be constructed such that the wall consists of at least 1 and at most n bricks? Two walls are different if there exist a column c and a row r such that one wall has a brick in this spot, and the other does not.Along with n, you will be given C, the width of the wall (as defined in the easy version). Return the number of different walls modulo 106β+β3. | [{"input": "5 1\r\n", "output": ["5"]}, {"input": "2 2\r\n", "output": ["5"]}, {"input": "3 2\r\n", "output": ["9"]}, {"input": "11 5\r\n", "output": ["4367"]}, {"input": "37 63\r\n", "output": ["230574"]}, {"input": "1 1\r\n", "output": ["1"]}, {"input": "350000 140000\r\n", "output": ["453366"]}, {"input": "350000 160000\r\n", "output": ["155549"]}, {"input": "350000 180000\r\n", "output": ["708073"]}, {"input": "350000 200000\r\n", "output": ["504934"]}, {"input": "400000 140000\r\n", "output": ["956370"]}, {"input": "400000 160000\r\n", "output": ["480365"]}, {"input": "400000 180000\r\n", "output": ["376155"]}, {"input": "400000 200000\r\n", "output": ["388234"]}, {"input": "450000 140000\r\n", "output": ["175993"]}, {"input": "450000 160000\r\n", "output": ["926957"]}, {"input": "450000 180000\r\n", "output": ["135727"]}, {"input": "450000 200000\r\n", "output": ["997315"]}, {"input": "500000 140000\r\n", "output": ["775486"]}, {"input": "500000 160000\r\n", "output": ["298591"]}, {"input": "500000 180000\r\n", "output": ["901135"]}, {"input": "500000 200000\r\n", "output": ["781209"]}] | 100 | 100 | 100 | [{'input': '400000 200000\r\n', 'output': ['388234']}, {'input': '350000 180000\r\n', 'output': ['708073']}, {'input': '500000 140000\r\n', 'output': ['775486']}, {'input': '2 2\r\n', 'output': ['5']}, {'input': '350000 160000\r\n', 'output': ['155549']}] | [{'input': '450000 180000\r\n', 'output': ['135727']}, {'input': '3 2\r\n', 'output': ['9']}, {'input': '350000 180000\r\n', 'output': ['708073']}, {'input': '500000 160000\r\n', 'output': ['298591']}, {'input': '37 63\r\n', 'output': ['230574']}] | [{'input': '5 1\r\n', 'output': ['5']}, {'input': '2 2\r\n', 'output': ['5']}, {'input': '450000 160000\r\n', 'output': ['926957']}, {'input': '450000 200000\r\n', 'output': ['997315']}, {'input': '500000 180000\r\n', 'output': ['901135']}] | [{'input': '500000 160000\r\n', 'output': ['298591']}, {'input': '3 2\r\n', 'output': ['9']}, {'input': '5 1\r\n', 'output': ['5']}, {'input': '2 2\r\n', 'output': ['5']}, {'input': '11 5\r\n', 'output': ['4367']}] | [{'input': '450000 160000\r\n', 'output': ['926957']}, {'input': '350000 180000\r\n', 'output': ['708073']}, {'input': '450000 180000\r\n', 'output': ['135727']}, {'input': '350000 140000\r\n', 'output': ['453366']}, {'input': '11 5\r\n', 'output': ['4367']}] | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |