prob_desc_description stringlengths 63 3.8k | prob_desc_output_spec stringlengths 17 1.47k ⌀ | lang_cluster stringclasses 2 values | src_uid stringlengths 32 32 | code_uid stringlengths 32 32 | lang stringclasses 7 values | prob_desc_output_to stringclasses 3 values | prob_desc_memory_limit stringclasses 19 values | file_name stringclasses 111 values | tags listlengths 0 11 | prob_desc_created_at stringlengths 10 10 | prob_desc_sample_inputs stringlengths 2 802 | prob_desc_notes stringlengths 4 3k ⌀ | exec_outcome stringclasses 1 value | difficulty int64 -1 3.5k ⌀ | prob_desc_input_from stringclasses 3 values | prob_desc_time_limit stringclasses 27 values | prob_desc_input_spec stringlengths 28 2.42k ⌀ | prob_desc_sample_outputs stringlengths 2 796 | source_code stringlengths 42 65.5k | hidden_unit_tests stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
The heat during the last few days has been really intense. Scientists from all over the Berland study how the temperatures and weather change, and they claim that this summer is abnormally hot. But any scientific claim sounds a lot more reasonable if there are some numbers involved, so they have decided to actually calculate some value which would represent how high the temperatures are.Mathematicians of Berland State University came up with a special heat intensity value. This value is calculated as follows:Suppose we want to analyze the segment of $$$n$$$ consecutive days. We have measured the temperatures during these $$$n$$$ days; the temperature during $$$i$$$-th day equals $$$a_i$$$.We denote the average temperature of a segment of some consecutive days as the arithmetic mean of the temperature measures during this segment of days. So, if we want to analyze the average temperature from day $$$x$$$ to day $$$y$$$, we calculate it as $$$\frac{\sum \limits_{i = x}^{y} a_i}{y - x + 1}$$$ (note that division is performed without any rounding). The heat intensity value is the maximum of average temperatures over all segments of not less than $$$k$$$ consecutive days. For example, if analyzing the measures $$$[3, 4, 1, 2]$$$ and $$$k = 3$$$, we are interested in segments $$$[3, 4, 1]$$$, $$$[4, 1, 2]$$$ and $$$[3, 4, 1, 2]$$$ (we want to find the maximum value of average temperature over these segments).You have been hired by Berland State University to write a program that would compute the heat intensity value of a given period of days. Are you up to this task? | Print one real number — the heat intensity value, i. e., the maximum of average temperatures over all segments of not less than $$$k$$$ consecutive days. Your answer will be considered correct if the following condition holds: $$$|res - res_0| < 10^{-6}$$$, where $$$res$$$ is your answer, and $$$res_0$$$ is the answer given by the jury's solution. | C | 7bdb68ab0752f8df94b4d5c7df759dfb | a932df316c5c29ff023463e0f543b7ed | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"math"
] | 1530628500 | ["4 3\n3 4 1 2"] | null | PASSED | 1,300 | standard input | 4 seconds | The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the number of days in the given period, and the minimum number of days in a segment we consider when calculating heat intensity value, respectively. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \le a_i \le 5000$$$) — the temperature measures during given $$$n$$$ days. | ["2.666666666666667"] | #include <stdio.h>
int main()
{
int n, k;
double m = 0.0, max = 0.0;
int a[5005];
while(scanf("%d%d", &n, &k) != EOF)
{
a[0] = 0.0;
for(int i = 1; i <= n; i++)
scanf("%d", &a[i]);
for(int i = 1; i <= n; i++)
a[i] = a[i] + a[i-1];
//for(int i = 0; i <= n; i++)
//printf("%d ", a[i]);
for(int i = n; i >= k; i--)
{
for(int j = 0; j <= i - k; j++)
{
m = (double)(a[i] - a[j]) / (i - j);
if(m > max)
max = m;
//printf("%f\n", max);
}
}
printf("%f\n", max);
}
return 0;
}
| |
The heat during the last few days has been really intense. Scientists from all over the Berland study how the temperatures and weather change, and they claim that this summer is abnormally hot. But any scientific claim sounds a lot more reasonable if there are some numbers involved, so they have decided to actually calculate some value which would represent how high the temperatures are.Mathematicians of Berland State University came up with a special heat intensity value. This value is calculated as follows:Suppose we want to analyze the segment of $$$n$$$ consecutive days. We have measured the temperatures during these $$$n$$$ days; the temperature during $$$i$$$-th day equals $$$a_i$$$.We denote the average temperature of a segment of some consecutive days as the arithmetic mean of the temperature measures during this segment of days. So, if we want to analyze the average temperature from day $$$x$$$ to day $$$y$$$, we calculate it as $$$\frac{\sum \limits_{i = x}^{y} a_i}{y - x + 1}$$$ (note that division is performed without any rounding). The heat intensity value is the maximum of average temperatures over all segments of not less than $$$k$$$ consecutive days. For example, if analyzing the measures $$$[3, 4, 1, 2]$$$ and $$$k = 3$$$, we are interested in segments $$$[3, 4, 1]$$$, $$$[4, 1, 2]$$$ and $$$[3, 4, 1, 2]$$$ (we want to find the maximum value of average temperature over these segments).You have been hired by Berland State University to write a program that would compute the heat intensity value of a given period of days. Are you up to this task? | Print one real number — the heat intensity value, i. e., the maximum of average temperatures over all segments of not less than $$$k$$$ consecutive days. Your answer will be considered correct if the following condition holds: $$$|res - res_0| < 10^{-6}$$$, where $$$res$$$ is your answer, and $$$res_0$$$ is the answer given by the jury's solution. | C | 7bdb68ab0752f8df94b4d5c7df759dfb | 1b10d68d39c95158dd3f43e9ac440d2a | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"math"
] | 1530628500 | ["4 3\n3 4 1 2"] | null | PASSED | 1,300 | standard input | 4 seconds | The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the number of days in the given period, and the minimum number of days in a segment we consider when calculating heat intensity value, respectively. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \le a_i \le 5000$$$) — the temperature measures during given $$$n$$$ days. | ["2.666666666666667"] | #include<stdio.h>
int main()
{
int n,k;
scanf("%d",&n);
scanf("%d",&k);
int a[n];
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
for(int i=1;i<n;i++)
a[i]+=a[i-1];
float max=0,sum;
while(k<=n){
for(int i=0;i+k-1<n;i++)
{
if(i==0){
sum=(float)(a[i+k-1])/k;
}
else
{
sum=(float)(a[i+k-1]-a[i-1])/k;
}
// printf("%f %d\n",sum,k);
if(sum>max)
max=sum;
}
k++;
}
printf("%f",max);
}
| |
The heat during the last few days has been really intense. Scientists from all over the Berland study how the temperatures and weather change, and they claim that this summer is abnormally hot. But any scientific claim sounds a lot more reasonable if there are some numbers involved, so they have decided to actually calculate some value which would represent how high the temperatures are.Mathematicians of Berland State University came up with a special heat intensity value. This value is calculated as follows:Suppose we want to analyze the segment of $$$n$$$ consecutive days. We have measured the temperatures during these $$$n$$$ days; the temperature during $$$i$$$-th day equals $$$a_i$$$.We denote the average temperature of a segment of some consecutive days as the arithmetic mean of the temperature measures during this segment of days. So, if we want to analyze the average temperature from day $$$x$$$ to day $$$y$$$, we calculate it as $$$\frac{\sum \limits_{i = x}^{y} a_i}{y - x + 1}$$$ (note that division is performed without any rounding). The heat intensity value is the maximum of average temperatures over all segments of not less than $$$k$$$ consecutive days. For example, if analyzing the measures $$$[3, 4, 1, 2]$$$ and $$$k = 3$$$, we are interested in segments $$$[3, 4, 1]$$$, $$$[4, 1, 2]$$$ and $$$[3, 4, 1, 2]$$$ (we want to find the maximum value of average temperature over these segments).You have been hired by Berland State University to write a program that would compute the heat intensity value of a given period of days. Are you up to this task? | Print one real number — the heat intensity value, i. e., the maximum of average temperatures over all segments of not less than $$$k$$$ consecutive days. Your answer will be considered correct if the following condition holds: $$$|res - res_0| < 10^{-6}$$$, where $$$res$$$ is your answer, and $$$res_0$$$ is the answer given by the jury's solution. | C | 7bdb68ab0752f8df94b4d5c7df759dfb | 2d01f0dc8bd5c84000f84f1c771e8340 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"math"
] | 1530628500 | ["4 3\n3 4 1 2"] | null | PASSED | 1,300 | standard input | 4 seconds | The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the number of days in the given period, and the minimum number of days in a segment we consider when calculating heat intensity value, respectively. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \le a_i \le 5000$$$) — the temperature measures during given $$$n$$$ days. | ["2.666666666666667"] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAX 5002
int main()
{
int n, k, i, j, x;
double a[MAX];
scanf("%d%d", &n, &k);
a[0] = 0;
for (i = 1; i <= n; i++)
{
scanf("%d", &x);
a[i] = a[i - 1] + x;
}
double sum, max = 0;
for (i = 1; i <= n-k+1; i++)
{
for (j = k + i - 1; j <= n; j++)
{
sum = ((a[j] - a[i - 1]) / (j - i + 1));
if (sum > max)
max = sum;
}
}
printf("%.8lf", max);
return 0;
} | |
The heat during the last few days has been really intense. Scientists from all over the Berland study how the temperatures and weather change, and they claim that this summer is abnormally hot. But any scientific claim sounds a lot more reasonable if there are some numbers involved, so they have decided to actually calculate some value which would represent how high the temperatures are.Mathematicians of Berland State University came up with a special heat intensity value. This value is calculated as follows:Suppose we want to analyze the segment of $$$n$$$ consecutive days. We have measured the temperatures during these $$$n$$$ days; the temperature during $$$i$$$-th day equals $$$a_i$$$.We denote the average temperature of a segment of some consecutive days as the arithmetic mean of the temperature measures during this segment of days. So, if we want to analyze the average temperature from day $$$x$$$ to day $$$y$$$, we calculate it as $$$\frac{\sum \limits_{i = x}^{y} a_i}{y - x + 1}$$$ (note that division is performed without any rounding). The heat intensity value is the maximum of average temperatures over all segments of not less than $$$k$$$ consecutive days. For example, if analyzing the measures $$$[3, 4, 1, 2]$$$ and $$$k = 3$$$, we are interested in segments $$$[3, 4, 1]$$$, $$$[4, 1, 2]$$$ and $$$[3, 4, 1, 2]$$$ (we want to find the maximum value of average temperature over these segments).You have been hired by Berland State University to write a program that would compute the heat intensity value of a given period of days. Are you up to this task? | Print one real number — the heat intensity value, i. e., the maximum of average temperatures over all segments of not less than $$$k$$$ consecutive days. Your answer will be considered correct if the following condition holds: $$$|res - res_0| < 10^{-6}$$$, where $$$res$$$ is your answer, and $$$res_0$$$ is the answer given by the jury's solution. | C | 7bdb68ab0752f8df94b4d5c7df759dfb | 826086d166f22b63691221803b942f20 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"math"
] | 1530628500 | ["4 3\n3 4 1 2"] | null | PASSED | 1,300 | standard input | 4 seconds | The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the number of days in the given period, and the minimum number of days in a segment we consider when calculating heat intensity value, respectively. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \le a_i \le 5000$$$) — the temperature measures during given $$$n$$$ days. | ["2.666666666666667"] | #include<stdio.h>
double max(double a,double b){
double t;
t=a;
if(b>t){
t=b;
}
return t;
}
int main(){
int n,k,i,j;
scanf("%d%d",&n,&k);
int a[n];a[0]=0;double ans=0;
for(i=1;i<=n;i++){
scanf("%d",&a[i]);
a[i]=a[i]+a[i-1];
}
for(i=0;i<=n;i++){
for(j=i+k;j<=n;j++){
ans=max(ans,1.0*(a[j]-a[i])/(j-i));
}
}
printf("%lf",ans);
} | |
The heat during the last few days has been really intense. Scientists from all over the Berland study how the temperatures and weather change, and they claim that this summer is abnormally hot. But any scientific claim sounds a lot more reasonable if there are some numbers involved, so they have decided to actually calculate some value which would represent how high the temperatures are.Mathematicians of Berland State University came up with a special heat intensity value. This value is calculated as follows:Suppose we want to analyze the segment of $$$n$$$ consecutive days. We have measured the temperatures during these $$$n$$$ days; the temperature during $$$i$$$-th day equals $$$a_i$$$.We denote the average temperature of a segment of some consecutive days as the arithmetic mean of the temperature measures during this segment of days. So, if we want to analyze the average temperature from day $$$x$$$ to day $$$y$$$, we calculate it as $$$\frac{\sum \limits_{i = x}^{y} a_i}{y - x + 1}$$$ (note that division is performed without any rounding). The heat intensity value is the maximum of average temperatures over all segments of not less than $$$k$$$ consecutive days. For example, if analyzing the measures $$$[3, 4, 1, 2]$$$ and $$$k = 3$$$, we are interested in segments $$$[3, 4, 1]$$$, $$$[4, 1, 2]$$$ and $$$[3, 4, 1, 2]$$$ (we want to find the maximum value of average temperature over these segments).You have been hired by Berland State University to write a program that would compute the heat intensity value of a given period of days. Are you up to this task? | Print one real number — the heat intensity value, i. e., the maximum of average temperatures over all segments of not less than $$$k$$$ consecutive days. Your answer will be considered correct if the following condition holds: $$$|res - res_0| < 10^{-6}$$$, where $$$res$$$ is your answer, and $$$res_0$$$ is the answer given by the jury's solution. | C | 7bdb68ab0752f8df94b4d5c7df759dfb | 19098ab5c873cf9443cfbcb65ddc8caf | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"math"
] | 1530628500 | ["4 3\n3 4 1 2"] | null | PASSED | 1,300 | standard input | 4 seconds | The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the number of days in the given period, and the minimum number of days in a segment we consider when calculating heat intensity value, respectively. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \le a_i \le 5000$$$) — the temperature measures during given $$$n$$$ days. | ["2.666666666666667"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int cmp(const void *a , const void *b)
{
return *(int *)a - *(int *)b;
}
double max(double a,double b)
{
if(a<b)
return b;
return a;
}
int min(int a,int b)
{
if(a>b)
return b;
return a;
}
int mod(int a)
{
if(a<0)
return -a;
return a;
}
int main()
{
int i,j;int n,k;
scanf("%d%d",&n,&k);
double a[10005],sum[10004]={0};
for(i=1;i<=n;i++)
{
scanf("%lf",&a[i]);
sum[i]=sum[i-1]+a[i];
}
double ans=0,temp;
for(i=k;i<=n;i++)
{
for(j=i-k;j>=0;j--)
{
temp=sum[i]-sum[j];
ans=max(ans,temp/(i-j));
}
}
printf("%.8lf\n",ans );
return 0;
}
| |
The heat during the last few days has been really intense. Scientists from all over the Berland study how the temperatures and weather change, and they claim that this summer is abnormally hot. But any scientific claim sounds a lot more reasonable if there are some numbers involved, so they have decided to actually calculate some value which would represent how high the temperatures are.Mathematicians of Berland State University came up with a special heat intensity value. This value is calculated as follows:Suppose we want to analyze the segment of $$$n$$$ consecutive days. We have measured the temperatures during these $$$n$$$ days; the temperature during $$$i$$$-th day equals $$$a_i$$$.We denote the average temperature of a segment of some consecutive days as the arithmetic mean of the temperature measures during this segment of days. So, if we want to analyze the average temperature from day $$$x$$$ to day $$$y$$$, we calculate it as $$$\frac{\sum \limits_{i = x}^{y} a_i}{y - x + 1}$$$ (note that division is performed without any rounding). The heat intensity value is the maximum of average temperatures over all segments of not less than $$$k$$$ consecutive days. For example, if analyzing the measures $$$[3, 4, 1, 2]$$$ and $$$k = 3$$$, we are interested in segments $$$[3, 4, 1]$$$, $$$[4, 1, 2]$$$ and $$$[3, 4, 1, 2]$$$ (we want to find the maximum value of average temperature over these segments).You have been hired by Berland State University to write a program that would compute the heat intensity value of a given period of days. Are you up to this task? | Print one real number — the heat intensity value, i. e., the maximum of average temperatures over all segments of not less than $$$k$$$ consecutive days. Your answer will be considered correct if the following condition holds: $$$|res - res_0| < 10^{-6}$$$, where $$$res$$$ is your answer, and $$$res_0$$$ is the answer given by the jury's solution. | C | 7bdb68ab0752f8df94b4d5c7df759dfb | 6347bb18e75f32846c5b5aefc0d0d19d | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"math"
] | 1530628500 | ["4 3\n3 4 1 2"] | null | PASSED | 1,300 | standard input | 4 seconds | The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the number of days in the given period, and the minimum number of days in a segment we consider when calculating heat intensity value, respectively. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \le a_i \le 5000$$$) — the temperature measures during given $$$n$$$ days. | ["2.666666666666667"] | #include<stdio.h>
int main()
{
int i,n,k;
double max=0;
int a[5005];
scanf("%d%d",&n,&k);
for(i=0;i<n;i++)
scanf("%d",a+i);
for(i=1;i<n;i++)
a[i]+=a[i-1];
while(k<=n)
{
if(max<a[k-1]*1.0/k)
max=a[k-1]*1.0/k;
for(i=k;i<n;i++)
if(max<(a[i]-a[i-k])*1.0/k)
max=(a[i]-a[i-k])*1.0/k;
k++;
}
printf("%.15lf",max);
return 0;
}
| |
The heat during the last few days has been really intense. Scientists from all over the Berland study how the temperatures and weather change, and they claim that this summer is abnormally hot. But any scientific claim sounds a lot more reasonable if there are some numbers involved, so they have decided to actually calculate some value which would represent how high the temperatures are.Mathematicians of Berland State University came up with a special heat intensity value. This value is calculated as follows:Suppose we want to analyze the segment of $$$n$$$ consecutive days. We have measured the temperatures during these $$$n$$$ days; the temperature during $$$i$$$-th day equals $$$a_i$$$.We denote the average temperature of a segment of some consecutive days as the arithmetic mean of the temperature measures during this segment of days. So, if we want to analyze the average temperature from day $$$x$$$ to day $$$y$$$, we calculate it as $$$\frac{\sum \limits_{i = x}^{y} a_i}{y - x + 1}$$$ (note that division is performed without any rounding). The heat intensity value is the maximum of average temperatures over all segments of not less than $$$k$$$ consecutive days. For example, if analyzing the measures $$$[3, 4, 1, 2]$$$ and $$$k = 3$$$, we are interested in segments $$$[3, 4, 1]$$$, $$$[4, 1, 2]$$$ and $$$[3, 4, 1, 2]$$$ (we want to find the maximum value of average temperature over these segments).You have been hired by Berland State University to write a program that would compute the heat intensity value of a given period of days. Are you up to this task? | Print one real number — the heat intensity value, i. e., the maximum of average temperatures over all segments of not less than $$$k$$$ consecutive days. Your answer will be considered correct if the following condition holds: $$$|res - res_0| < 10^{-6}$$$, where $$$res$$$ is your answer, and $$$res_0$$$ is the answer given by the jury's solution. | C | 7bdb68ab0752f8df94b4d5c7df759dfb | 77a83aec5804ddd38d9c04b667a550d7 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"math"
] | 1530628500 | ["4 3\n3 4 1 2"] | null | PASSED | 1,300 | standard input | 4 seconds | The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the number of days in the given period, and the minimum number of days in a segment we consider when calculating heat intensity value, respectively. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \le a_i \le 5000$$$) — the temperature measures during given $$$n$$$ days. | ["2.666666666666667"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
int *a;
int k;
int sum_k = 0;
float result = 0;
scanf("%d %d", &n, &k);
a = (int *)(malloc(sizeof(int) * n));
for (int i = 0; i < n; i++)
{
scanf("%d", &a[i]);
if (i < k)
{
sum_k += a[i];
}
}
//printf("%d\n", sum_k);
int max = sum_k;
//int number = k;
int tmp;
float tmp_result = 0;
while (k <= n)
{
tmp = sum_k;
max = tmp;
// printf("%d: ", tmp);
for (int i = 1; i <= n - k; i++)
{
tmp -= a[i-1];
tmp += a[i + k -1];
if (tmp > max)
{
max = tmp;
}
// printf("%d %d %d\n", i, tmp, max);
}
// printf("%d %d %d\n", max, k, sum_k);
if((tmp_result = (float)max / (float)k) > result){
result = tmp_result;
}
sum_k += a[k++];
}
//printf("%d %d", max, number);
printf("%f", result);
} | |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | 440c4ad43d405ca1331103d6ef07415d | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include<stdio.h>
int main(){
int m,n,ans1=0,ans2=0,count=0;
scanf("%d %d",&m,&n);
int b[m][n],a[m][n],i,j,k,test[m][n];
for(i=0;i<m;i++){
for(j=0;j<n;j++){
scanf("%d",&b[i][j]);
a[i][j]=1;
}
}
for(i=0;i<m;i++){
for(j=0;j<n;j++){
if(b[i][j]==0){
for(k=0;k<n;k++) a[i][k]=0;
for(k=0;k<m;k++) a[k][j]=0;
}
}
}
for(i=0;i<m;i++){
for(k=0;k<n-1;k++) ans1=(ans1 || a[i][k]) || a[i][k+1];
for(j=0;j<n;j++){
for(k=0;k<m-1;k++) ans2=(ans2 || a[k][j]) || a[k+1][j];
test[i][j]=ans1 || ans2;
ans2=0;
}
ans1=0;
}
for(i=0;i<m;i++){
for(j=0;j<n;j++){
if(test[i][j]==b[i][j]) count++;
}
}
if(count!=(m*n) && (m*n)>1) printf("NO\n");
else{
printf("YES\n");
for(i=0;i<m;i++){
for(j=0;j<n;j++){
printf("%d ",a[i][j]);
}
printf("\n");
}
}
return 0;
}
| |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | 51465716f288e8947b9c4a0513044dd3 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | # include <stdio.h>
int main(){
int n,m,i,j,k,y,flag=0;
scanf("%d%d",&n,&m);
int a[n][m],b[n][m];
for(i=0;i<n;i++){
for(j=0;j<m;j++){
scanf("%d",&a[i][j]);
}
}
for(i=0;i<n;i++){
for(j=0;j<m;j++){
y=1;
for(k=0;k<m;k++){
y=y&a[i][k];
}
for(k=0;k<n;k++){
y=y&a[k][j];
}
if(y==1)b[i][j]=1;
else b[i][j]=0;
}
}
for(i=0;i<n;i++){
for(j=0;j<m;j++){
y=0;
for(k=0;k<m;k++){
y=y|b[i][k];
}
for(k=0;k<n;k++){
y=y|b[k][j];
}
if(a[i][j]!=y)flag=1;
}
}
if(flag==1){
printf("NO\n");
}
else{
printf("YES\n");
for(i=0;i<n;i++){
for(j=0;j<m;j++)
printf("%d ",b[i][j]);
printf("\n");
}
}
return 0;
} | |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | c72d524ac9f66fd1c8ca7035ffe03cd3 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include<stdio.h>
#include<math.h>
int n,m,a[200][200],b[200][200];
void setit(int x,int y){
int i;
for (i = 0; i < n; i++) {
a[i][y]=0;
}
for (i = 0; i < m; i++) {
a[x][i]=0;
}
}
int checkit(int x,int y){
int i;
for (i = 0; i < n; i++) {
if (a[i][y]==1)return 1;
}
for (i = 0; i < m; i++) {
if(a[x][i]==1)return 1;
}
return 0;
}
int main()
{
int i,j,k,l;
scanf("%d%d",&n,&m);
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
a[i][j]=1;
}
}
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
scanf("%d",&k);
b[i][j]=k;
if (k==0) {
setit(i,j);
}
}
}
for (i = 0; i < n; i++) {
for (j=0; j<m; j++) {
if (b[i][j]==1) {
if (!checkit(i,j))
{
printf("NO");
i=n;
break;
}
}
}
}
if (i!=n+1) {
printf("YES\n");
for (i = 0; i < n; i++) {
for (j=0; j< m-1; j++) {
printf("%d ",a[i][j]);
}
printf("%d\n",a[i][j]);
}
}
getchar();
getchar();
return 0;
}
| |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | 09ab12e1a19f833be4accb5d6bb7fe3c | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include <stdio.h>
int main(void) {
int i, j, k;
int m, n;
int a[100][100], b[100][100];
scanf("%d %d", &m, &n);
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
scanf("%d", b[i] + j);
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
a[i][j] = 1;
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
if (!b[i][j]) {
for (k = 0; k < n; k++)
a[i][k] = 0;
for (k = 0; k < m; k++)
a[k][j] = 0;
}
for (i = 0; i < m; i++)
for (j = 0; j < n; j++) {
int or;
or = 0;
for (k = 0; k < n; k++)
or |= a[i][k];
for (k = 0; k < m; k++)
or |= a[k][j];
if (or != b[i][j]) {
puts("NO");
return 0;
}
}
puts("YES");
for (i = 0; i < m; i++) {
for (j = 0; j < n; j++)
printf("%d ", a[i][j]);
putchar('\n');
}
return 0;
}
| |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | 3f826eb88e6ee9ed6221af5dfeaea7a1 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include<stdio.h>
int row,col;
int arr[101][101];
int ans[101][101];
int real[101][101];
void printM(int arr[][101])
{
int i,j;
for(i=1;i!=row+1;i++)
{
for(j=1;j!=col+1;j++)
{
printf("%d ",arr[i][j]);
}
printf("\n");
}
return ;
}
void insert(int arr[][101],int k)
{
int i,j;
for(i=1;i!=row+1;i++)
{
for(j=1;j!=col+1;j++)
{
arr[i][j] = k;
}
}
return ;
}
int main()
{
int i,j,k;
scanf("%d %d",&row,&col);
for(i=1;i!=row+1;i++)
{
for(j=1;j!=col+1;j++)
{
scanf("%d",&arr[i][j]);
}
}
int flag = 0;
insert(ans,1);
for(i=1;i!=row+1;i++)
{
for(j=1;j!=col+1;j++)
{
if(arr[i][j] == 0)
{
for(k=1;k!=col+1;k++)
{
ans[i][k] = 0;
}
for(k=1;k!=row+1;k++)
{
ans[k][j] = 0;
}
}
}
}
for(i=1;i!=row+1;i++)
{
for(j=1;j!=col+1;j++)
{
if(ans[i][j] == 1)
{
for(k=1;k!=col+1;k++)
{
real[i][k] = 1;
}
k = 1;
while(k!=row+1)
{
real[k][j] = 1;
k = k + 1;
}
}
}
}
for(i=1;i!=row+1;i++)
{
for(j=1;j!=col+1;j++)
{
if(arr[i][j]!=real[i][j])
{
flag = 1;
break;
}
}
if(flag == 1)
{
break;
}
}
if(flag == 1)
{
printf("NO\n");
}
else
{
printf("YES\n");
printM(ans);
}
return 0;
}
| |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | a516b4e578a0ff92db4ae1ecfe92d7c1 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include <stdio.h>
int main(void)
{
int m, n;
scanf("%d", &m);
scanf("%d", &n);
int a[m][n], b[m][n];
int i, j, i2, j2;
for (i = 0; i < m; i++)
for (j = 0; j < n; j++) {
a[i][j] = 3;
scanf("%d", &b[i][j]);
}
for (i = 0; i < m; i++)
for (j = 0; j < n; j++) {
if (b[i][j] == 0) {
for (i2 = 0; i2 < m; i2++)
a[i2][j] = 0;
for (j2 = 0; j2 < n; j2++)
a[i][j2] = 0;
}
}
/*
printf("\n");
for (i = 0; i < m; i++) {
for (j = 0; j < n; j++)
printf("%d ", a[i][j]);
printf("\n");
}
printf("\n");
for (i = 0; i < m; i++) {
for (j = 0; j < n; j++)
printf("%d ", b[i][j]);
printf("\n");
}
printf("\n");
*/
int ok = 1;
for (i = 0; i < m; i++)
for (j = 0; j < n; j++) {
int freedom = 0;
for (i2 = 0; i2 < m; i2++) {
if (b[i][j] == 0 && a[i2][j] == 1)
ok = 0;
if (a[i2][j] != 0)
++freedom;
}
for (j2 = 0; j2 < n; j2++) {
if (b[i][j] == 0 && a[i][j2] == 1)
ok = 0;
if (a[i][j2] != 0)
++freedom;
}
if (b[i][j] == 1 && freedom == 0)
ok = 0;
;
//printf("(%d, %d)", freedom, ok);
}
if (ok) {
printf("YES\n");
for (i = 0; i < m; i++) {
for (j = 0; j < n; j++)
printf("%d ", a[i][j] != 0 ? 1 : 0);
printf("\n");
}
} else
printf("NO\n");
//printf("%d", ++ones);
/*
for (i = 0; i < m; i++) {
for (j = 0; j < n; j++)
printf("%d ", a[i][j]);
printf("\n");
*/
return 0;
}
| |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | 92b427f80b8509072d67bb3b509901cc | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include<stdio.h>
int main()
{
int m,n,a[110][110],b[110][110];
int i,j,k,k1,k2,t=1;
scanf("%d%d",&m,&n);
for(i=0;i<m;i++)
for(j=0;j<n;j++)
b[i][j]=1;
for(i=0;i<m;i++)
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
if(!a[i][j])
{
for(k=0;k<m;k++)
b[k][j]=0;
for(k=0;k<n;k++)
b[i][k]=0;
}
}
for(i=0;i<m;i++)
for(j=0;j<n;j++)
if(a[i][j]==1)
{
for(k1=0;k1<m;k1++)
if(b[k1][j]==1)
break;
for(k2=0;k2<n;k2++)
if(b[i][k2]==1)
break;
if(k1==m&&k2==n)
{
t=0;
break;
}
}
if(t)
{
printf("YES\n");
for(i=0;i<m;i++,printf("\n"))
for(j=0;j<n;j++)
if(!j)
printf("%d",b[i][j]);
else
printf(" %d",b[i][j]);
}
else
printf("NO\n");
return 0;
}
| |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | e60c0dc5b51989c72b6bf7b8a2499017 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include<stdio.h>
int main()
{
int n,m,b[105][105],a[105][105],i,j,k,check=0;
scanf("%d %d",&m,&n);
for(i=0;i<m;i++)
for(j=0;j<n;j++)
a[i][j]=500;
for(i=0;i<m;i++)
for(j=0;j<n;j++)
{
scanf("%d",&b[i][j]);
if(b[i][j]==1)
{
check=1;
}
else
{
for(k=0;k<m;k++)
a[k][j]=0;
for(k=0;k<n;k++)
a[i][k]=0;
}
}
for(i=0;i<m;i++)
for(j=0;j<n;j++)
if(a[i][j]==500)
a[i][j]=1;
int beck=0;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(a[i][j]==1)
{
beck=1;break;
}
}
}
int kick=0;
if(beck==0 && check ==1)
{
printf("NO\n");kick=500;
}
else
{
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
int k,l=0;
for(k=0;k<m;k++)
l=a[k][j]|l;
for(k=0;k<n;k++)
l=a[i][k]|l;
if(l!=b[i][j])
{
printf("NO\n");
kick=1;
break;
}
}
if(kick==1)
break;
}
}
if (kick==0)
{
printf("YES\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
printf("%d ",a[i][j]);
printf("\n");
}
}
return 0;
}
| |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | 73d77f7bed48856430adf11d43549776 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include <stdio.h>
int main()
{
int i, j, m, n, a[101][101], ans[101][101];
scanf("%d %d", &m, &n);
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
scanf("%d", &a[i][j]);
ans[i][j]=1;
}
}
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
if(a[i][j]==0)
{
for(int x=0; x<m; x++)
ans[x][j]=0;
for(int x=0; x<n; x++)
ans[i][x]=0;
}
}
}
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
int flag=0;
if(a[i][j]==1)
{
for(int x=0; x<m; x++)
if(ans[x][j]==1)
flag=1;
for(int x=0; x<n; x++)
if(ans[i][x]==1)
flag=1;
if(flag==0)
{
printf("NO\n");
return 0;
}
}
}
}
printf("YES\n");
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
printf("%d ", ans[i][j]);
printf("\n");
}
return 0;
} | |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | 12faa9ff6e1a1d2aa7f7f7931c0d7cfc | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include<stdio.h>
int main()
{
int k,flag=0,a[100][100], b[100][100], m,n,i,j,c[100][100];
scanf("%d %d", &m, &n);
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
scanf("%d", &b[i][j]);
a[i][j] = 1;
c[i][j]=0;
}
}
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
if(b[i][j] == 0)
{
for(k=0; k<n; k++)
{
a[i][k] = 0;
}
for(k=0; k<m; k++)
{
a[k][j] = 0;
}
}
}
}
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
if(a[i][j] == 1)
{
for(k=0; k<n; k++)
{
c[i][k] = 1;
}
for(k=0; k<m; k++)
{
c[k][j] = 1;
}
}
}
}
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
if(b[i][j] != c[i][j])
{
flag=1;
break;
}
}
}
if(flag == 1)
{
printf("NO\n");
}
else
{
printf("YES\n");
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
printf("%d ", a[i][j]);
}
printf("\n");
}
}
}
| |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | c6055c601a2da36a3145bf6696ce5a3e | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int m,n,i,j,allZeros=1,allZeros1=1;
scanf("%d %d",&m,&n);
int B[m][n],A[m][n];
int rowArray[m],colArray[n];
for(i=0;i<m;i++)
{
rowArray[i] = 0;
}
for(i=0;i<n;i++)
{
colArray[i] = 0;
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&B[i][j]);
A[i][j] = B[i][j];
if(B[i][j] == 0)
{
rowArray[i] = 1;
colArray[j] = 1;
}
else
{
allZeros = 0;
}
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(rowArray[i] == 1 || colArray[j] == 1)
{
A[i][j] = 0;
}
if(B[i][j] != 0)
{
allZeros1 = 0;
}
}
}
for(i=0;i<m;i++)
{
rowArray[i] = 0;
}
for(i=0;i<n;i++)
{
colArray[i] = 0;
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(A[i][j] == 1)
{
rowArray[i] = 1;
colArray[j] = 1;
}
}
}
allZeros = 1;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(B[i][j] == 1 && rowArray[i] == 0 && colArray[j] == 0 )
{
//error condition
allZeros = 0;
break;
}
}
}
if(allZeros == 0)
{
printf("NO\n");
return 0;
}
printf("YES\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d ",A[i][j]);
}
printf("\n");
}
return 0;
}
| |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | 5f4ede69a7462a9286fea8d033d626f3 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | /*OR in Matrix*/
#include<stdio.h>
int main()
{
int A[100][100], B[100][100], C[100][100];
int found, i, j, k, m, n;
scanf("%d %d", &m, &n);
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
scanf("%d", &B[i][j]);
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
A[i][j] = 1;
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
if (B[i][j] == 0)
{
for (k = 0; k < n; k++)
A[i][k] = 0;
for (k = 0; k < m; k++)
A[k][j] = 0;
}
}
}
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
C[i][j] = 0;
for (k = 0; k < n; k++)
C[i][j] |= A[i][k];
for (k = 0; k < m; k++)
C[i][j] |= A[k][j];
}
}
found = 0;
for (i = 0; (!found) && (i < m); i++)
for (j = 0; (!found) && (j < n); j++)
if (B[i][j] != C[i][j])
found = 1;
puts(found ? "NO" : "YES");
if (!found)
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
printf("%d%c", A[i][j], ((j == n - 1) ? '\n' : ' '));
return 0;
} | |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | 878ae77e74c9c5acde94693398e177aa | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include<stdio.h>
int main()
{
int a[100][100],b[100][100];
int i,j,k,m,n;
int z,z1,tmp,t,y;
int f,g;
scanf("%d %d", &m,&n);
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
scanf("%d", &a[i][j]);
}
}
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
b[i][j] = 1;
}
}
z=0;
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
if(a[i][j] == 0){
z++;
break;
}
}
}
z1=0;
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
if(a[i][j]==0){
z1++;
}
}
}
//t=0;
tmp=0;
//tmp2=0;
for(i=0,y=0; i<m ; i++)
{
if(a[i][y] == 0){
tmp++;
y++;
i=-1;
//tmp2++;
//break;
}
if(i==(m-1)){
// i=-1;
//t = 0;
if(tmp==0)
break;
}
if(y == n)
break;
}
//printf(" tmp: %d\n", tmp);
if((z==m || tmp==n) && z1!=(m*n)){
printf("NO");
return 0;
}
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
if(a[i][j] == 0){
for(k=0; k<m; k++)
b[k][j]=0;
for(k=0; k<n; k++)
b[i][k]=0;
}
}
}
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
if(a[i][j] == 1){
for(k=0; k<m; k++){
if(a[k][j]==0){
f=1; break;
}
else f=0;
}
for(k=0; k<n; k++){
if(a[i][k]==0)
{
g=1; break;
}
else g=0;
}
}
if(f==1 && g==1)
break;
}
if(f==1 && g==1)
break;
}
if(f==1 && g==1)
{
printf("NO");
return 0;
}
/*
zero=0;
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
if(b[i][j] == 0)
zero++;
}
}
if(zero==(m*n-1)){
printf("NO");
return 0;
}
*/
printf("YES\n");
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
printf("%d ", b[i][j]);
}
printf("\n");
}
}
| |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | 9a82e9a80e31ff09bb94dd158e1d3517 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include<stdio.h>
int main()
{
int m,n,a[100][100],b[100][100],h,k,l,i,j;
while(scanf("%d%d",&m,&n)!=EOF)
{
l=0;
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
a[i][j]=1;
}
}
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
scanf("%d",&b[i][j]);
}
}
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
if(b[i][j]==0)
{
for(h=0; h<m; h++)
{
a[h][j]=0;
}
for(k=0; k<n; k++)
{
a[i][k]=0;
}
}
}
}
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
if(b[i][j]==1)
{
for(h=0; h<m; h++)
{
if(a[h][j]==1) break;
}
for(k=0; k<n; k++)
{
if(a[i][k]==1) break;
}
if(k==n&&h==m)
{
printf("NO\n");
l=1;
break;
}
}
if(l==1) break;
}
if(l==1) break;
}
if(l==0)
{
printf("YES\n");
for(i=0; i<m; i++)
{
printf("%d",a[i][0]);
for(j=1; j<n; j++)
{
printf(" %d",a[i][j]);
}
printf("\n");
}
}
}
return 0;
} | |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | e8c142ea6af93d01d0c47aca0b86754d | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include<stdio.h>
int D[500][500];
int main()
{
int i,h,j,k,a,b,c,m,n;
int D[500][500],A[500][500],C[500][500];
scanf("%d%d",&m,&n);
for(i=0;i<m;i++){
for(j=0;j<n;j++){
C[i][j]=1;
}
}
//printf("A Matrix\n");
for(i=0;i<m;i++){
for(j=0;j<n;j++){
scanf("%d",&A[i][j]);
//printf("%d ",A[i][j]);
if(A[i][j]==0){
for(k=0;k<n;k++){
C[i][k]=0;
}
for(k=0;k<m;k++){
C[k][j]=0;
}
}
}
//printf("\n");
}
//printf("C Matrix\n");
for(i=0;i<m;i++){
for(j=0;j<n;j++){
if(C[i][j]!=0){
C[i][j]=1;
}
// printf("%d ",C[i][j]);
}
// printf("\n");
}
for(i=0;i<m;i++){
for(j=0;j<n;j++){
for(k=0;k<n;k++)
D[i][j]=D[i][j]|C[i][k];
for(k=0;k<m;k++){
D[i][j]=D[i][j]|C[k][j];
}
}
}
for(i=0;i<m;i++){
for(j=0;j<n;j++){
if(A[i][j]!=D[i][j]){
printf("NO\n");
return 0;
}
}
}
printf("YES\n");
for(i=0;i<m;i++){
for(j=0;j<n;j++){
printf("%d ",C[i][j]);
}
printf("\n");
}
return 0;
}
| |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | f45cd8fdd93e40d71e1da558a7039b1d | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include <stdio.h>
int main(void){
int n=0,m=0,i=0,j=0,k=0,l=0,arr[100][100],arr1[100][100],arr2[100][100];
scanf("%d %d",&m,&n);
for(i=0;i<m;i++)
for(j=0;j<n;j++){
arr1[i][j]=1;
arr2[i][j]=0;
}
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&arr[i][j]);
for(i=0;i<m;i++)
for(j=0;j<n;j++)
if(arr[i][j]==0){
for(l=0;l<n;l++)
arr1[i][l]=0;
for(k=0;k<m;k++)
arr1[k][j]=0;
}
for(i=0;i<m;i++)
for(j=0;j<n;j++)
if(arr1[i][j]==1){
for(l=0;l<n;l++)
arr2[i][l]=1;
for(k=0;k<m;k++)
arr2[k][j]=1;
}
l=0;
for(i=0;i<m;i++)
for(j=0;j<n;j++)
if(arr2[i][j]!=arr[i][j]){
l=1;
break;
}
if(l==0){
printf("YES\n");
for(i=0;i<m;i++){
for(j=0;j<n;j++){
printf("%d\t",arr1[i][j]);
}
printf("\n");
}
}
else
printf("NO");
return 0;
} | |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | fd0aa872dc2218d59edaf57d954e1501 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include<stdio.h>
int main(){
int n,m,i,j,k,flag=0;
scanf("%d%d",&m,&n);
int arr[m][n], ans[m][n];
for(i=0;i<m;i++){
for(j=0;j<n;j++){
scanf("%d",&arr[i][j]);
ans[i][j] = 0;
}
}
for(i=0;i<m;i++){
for(j=0;j<n;j++){
if(arr[i][j]){
for(k=0;k<m;k++){
if(!arr[k][j])break;
}
if(k==m){
for(k=0;k<n;k++){
if(!arr[i][k])break;
}
if(k==n)ans[i][j] = 1;
}
}
}
}
for(i=0;!flag && i<m;i++){
for(j=0;j<n;j++){
if(arr[i][j]){
for(k=0;k<m;k++){
if(ans[k][j])break;
}
if(k==m){
for(k=0;k<n;k++){
if(ans[i][k])break;
}
if(k==n){
flag=1;
break;
}
}
}
}
}
if(flag)printf("NO\n");
else{
printf("YES\n");
for(i=0;i<m;i++){
for(j=0;j<n;j++)printf("%d ",ans[i][j]);
printf("\n");
}
}
return 0;
} | |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | 5b81de8b8e6589c733284f535a5422ba | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include <stdio.h>
#define SIZE 100
int B[100][100],MARK[100][100] = {0};
int main(void){
int m,n,i,j,state=1,substate = 0,sum =0;
scanf("%d%d",&m,&n);
for(i=0;i<m;i++){
for(j=0;j<n;j++)
scanf("%d",&B[i][j]);
}
for(i=0;i<m;i++){
for(j=0;j<n;j++){
if(B[i][j] == 1 && MARK[i][j] == 0){
if(! judge(i,j,m,n)){
state = 0;
goto here;
}
}
}
}
here:;
for(i=0;i<m;i++){
for(j=0;j<n;j++){
sum += MARK[i][j];
if(MARK[i][j] == 2){
substate = 1;
break;
}
}
}
if(! state || (substate == 0 && sum != 0))
printf("NO\n");
else{
printf("YES\n");
for(i=0;i<m;i++){
for(j=0;j<n;j++){
if(MARK[i][j] == 2)
printf("1 ");
else
printf("0 ");
}
printf("\n");
}
}
//system("pause");
return 0;
}
int judge(a,b,m,n){
int i,statey = 1,statex = 1;
for(i=0;i<m;i++){
if (B[i][b] == 0){
statey = 0;
break;
}
}
if(statey){
for(i=0;i<m;i++)
MARK[i][b]++;
}
for(i=0;i<n;i++){
if (B[a][i] == 0){
statex = 0;
break;
}
}
if(statex){
for(i=0;i<n;i++)
MARK[a][i]++;
}
MARK[a][b] = statex + statey;
return statex || statey;
}
| |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | 10054e728b9aa72bd8b9b8f9003f1bc2 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include<stdio.h>
int main()
{
int A[100][100], B[100][100], temp[100][100];
int row, col;
int i , j, k, flag = 1;
scanf("%d %d", &row, &col);
for(i = 0; i < row; i++)
{
for(j = 0; j < col; j++)
{
scanf("%d", &B[i][j]);
A[i][j] = 1;
temp[i][j] = 0;
}
}
for(i = 0; i < row; i++)
{
for(j = 0; j < col; j++)
{
if(B[i][j] == 0)
{
for(k = 0; k < col; k++)
{
A[i][k] = 0;
A[k][j] = 0;
}
}
}
}
for(i = 0; i < row; i++)
{
for(j = 0; j < col; j++)
{
if(A[i][j] == 1)
{
for(k = 0; k < col; k++)
{
temp[i][k] = 1;
temp[k][j] = 1;
}
}
}
}
for(i = 0; i < row; i++)
{
for(j = 0; j < col; j++)
{
if(temp[i][j] != B[i][j])
{
flag = 0;
break;
}
}
}
if(!flag)
{
printf("NO");
}
else
{
printf("YES\n");
for(i = 0; i < row; i++)
{
for(j = 0; j < col; j++)
{
printf("%d ", A[i][j]);
}
printf("\n");
}
}
return 0;
}
| |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | 7ce353c4e37d25cfd47d695cc6713663 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include<stdio.h>
#include<stdlib.h>
int main(){
int a[105][105],m,n,i,j,k,b[105][105],count=0,flag=0,c[105][105];
scanf("%d%d",&m,&n);
for(i=1;i<=m;i++)
for(j=1;j<=n;j++)
scanf("%d",&a[i][j]);
for(i=1;i<=m;i++)
for(j=1;j<=n;j++){
b[i][j]=-2;
c[i][j]=-2;
}
//for(i=1;i<=m;i++)
// for(j=1;j<=n;j++)
// printf("%d",b[i][j]);
for(i=1;i<=m;i++){
for(j=1;j<=n;j++){
if(a[i][j]==0){
for(k=1;k<=m;k++){
b[k][j]=0;
c[k][j]=0;
}
for(k=1;k<=n;k++){
b[i][k]=0;
c[i][k]=0;
}
}
}
}
for(i=1;i<=m;i++){
for(j=1;j<=n;j++){
count=0;
if(a[i][j]==1){
for(k=1;k<=m;k++){
if(b[k][j]==-2)
break;
else
count++;
}
for(k=1;k<=n;k++){
if(b[i][k]==-2)
break;
else
count++;
}
if(count==m+n){
printf("NO\n");
return 0;
}
}
}
}
printf("YES\n");
for(i=1;i<=m;i++){
for(j=1;j<=n;j++){
if(i==m&&j==n){
if(c[i][j]!=0)
printf("1");
else
printf("0");
break;
}
if(c[i][j]!=0)
printf("1 ");
else
printf("0 ");
}
printf("\n");
}
return 0;
} | |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | 122540ec51c185a8a8dcecd68df182a3 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include<stdio.h>
int main()
{
int m,n,i,j,x,state=0;
scanf("%d%d",&m,&n);
int a[m][n],b[m][n];
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&b[i][j]);
for(i=0;i<m;i++)
for(j=0;j<n;j++)
a[i][j]=1;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(b[i][j]==0)
{
for(x=0;x<m;x++)
a[x][j]=0;
for(x=0;x<n;x++)
a[i][x]=0;
}
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
state=0;
if(b[i][j]==1)
{
for(x=0;x<n;x++)
if(a[i][x]==1)
state=1;
for(x=0;x<m;x++)
if(a[x][j]==1)
state=1;
// printf("%daaa\n", state);
if(state==0)
{
printf("NO\n");
return 0;
}
}
}
}
printf("YES\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d ",a[i][j]);
}
printf("\n");
}
return 0;
}
| |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | 4831cf6dc3286a6edc507fd655000c1a | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include <stdio.h>
int main(void)
{
int i,j,m,n,check=3,checkagain=3,checkin=3;
scanf("%d %d",&m,&n);
int in[m][n],out[m][n];
for (i=0;i<m;i++)
for (j=0;j<n;j++)
scanf("%d",&in[i][j]);
for (i=0;i<m;i++)
for (j=0;j<n;j++)
out[i][j]=1;
for (i=0;i<m;i++)
{
for (j=0;j<n;j++)
{
if (in[i][j]==1)
{
int a,b,check1=0,check2=0;
for (b=0;b<n;b++)
if (in[i][b]==0)
{
check1=1;
break;
}
for (a=0;a<m;a++)
if (in[a][j]==0)
{
check2=1;
break;
}
if (check1+check2==2)
{
check=0;
break;
}
}
}
}
for (i=0;i<m;i++)
{
for (j=0;j<n;j++)
{
if (in[i][j]==0)
{
int a,b;
for (b=0;b<n;b++)
out[i][b]=0;
for (a=0;a<m;a++)
out[a][j]=0;
}
}
}
for (i=0;i<m;i++)
{
for (j=0;j<n;j++)
{
if (in[i][j]==1)
{
checkin=1;
break;
}
}
}
for (i=0;i<m;i++)
{
for (j=0;j<n;j++)
{
if (out[i][j]==1)
{
checkagain=1;
break;
}
}
}
if (check==0||checkagain!=1&&checkin==1)
printf("NO\n");
else
{
printf("YES\n");
for (i=0;i<m;i++)
{
for (j=0;j<n-1;j++)
{
printf("%d ",out[i][j]);
}
printf("%d",out[i][n-1]);
printf("\n");
}
}
return 0;
}
| |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | ee1610d261f5f1e95d9b14c9be364f1a | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include <stdio.h>
#include <stdlib.h>
int main() {
int i, j, k, good, n, m, **b, **a;
scanf("%d%d", &m, &n);
a = malloc(m * sizeof(*a));
b = malloc(m * sizeof(*b));
for (i = 0; i < m; i++) {
a[i] = malloc(n * sizeof(*a[i]));
b[i] = malloc(n * sizeof(*b[i]));
}
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
scanf("%d", &b[i][j]);
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
a[i][j] = 1;
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
if (!b[i][j]) {
for (k = 0; k < m; k++)
a[k][j] = 0;
for (k = 0; k < n; k++)
a[i][k] = 0;
}
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
if (b[i][j]) {
good = 0;
for (k = 0; k < m; k++)
if (a[k][j]) {
good = 1;
break;
}
for (k = 0; k < n; k++)
if (a[i][k]) {
good = 1;
break;
}
if (!good) {
printf("NO\n");
return 0;
}
}
printf("YES\n");
for (i = 0; i < m; i++) {
for (j = 0; j < n; j++)
printf("%d ", a[i][j]);
printf("\n");
}
return 0;
}
| |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | 1a3e77ef05b4d213060dc1f0b1c8e9a5 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int m,n,i,i1,j1,f,j,k,l,p,q,a[1001][1001],b[1001][1001],b1[1001][1001];
scanf("%d%d",&m,&n);f=0;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf("%d",&b[i][j]);
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
a[i][j]=1;
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(b[i][j]==0) {
for(i1=0;i1<m;i1++)
a[i1][j]=0;for(j1=0;j1<n;j1++) a[i][j1]=0;
}}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(a[i][j]==1){
for(i1=0;i1<m;i1++)
b1[i1][j]=1;for(j1=0;j1<n;j1++) b1[i][j1]=1;
}}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{if(b1[i][j]!=b[i][j]) {f=1;break;}}
if(f==1) break;
}
if(f==1) printf("NO\n");
else {
printf("YES\n"); for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d ",a[i][j]);}
printf("\n");
}
}
return 0;
}
| |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | 5d104f5c64f770672288dd158bd63034 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include <stdio.h>
int main(void)
{
int m,n,arr[104][104],i,j,num[104][104],number[104][104],k,d;
scanf("%d %d",&m,&n);
if(m>=n)
{
d=m;
}
else
{
d=n;
}
//printf("%d ",d);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&arr[i][j]);
// printf("aa ");
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
num[i][j]=1;
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
number[i][j]=0;
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(arr[i][j]==0)
{
for(k=0;k<d;k++)
{
num[k][j]=0;
num[i][k]=0;
}
}
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(num[i][j]==1)
{
for(k=0;k<d;k++)
{
number[k][j]=1;
number[i][k]=1;
}
}
}
}
int flag=0;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(number[i][j]!=arr[i][j])
{
flag=1;
}
}
}
if(flag==0)
{
printf("YES\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d ",num[i][j]);
}
printf("\n");
}
}
else
{
printf("NO\n");
}
return 0;
} | |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | a150367c95444ed120dba7762b9dfd06 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | int a[100][100],b[100][100];
main()
{
int m,n,i,j,k;
scanf("%d%d",&m,&n);
for(i=0;i<m;i++)
for(j=0;j<n;j++) {scanf("%d",&a[i][j]);b[i][j]=-1;}
for(i=0;i<m;i++)
for(j=0;j<n;j++)
{
if(a[i][j]==0)
{
for(k=0;k<n;k++)
b[i][k]=0;
for(k=0;k<m;k++)
b[k][j]=0;
}
}
for(i=0;i<m;i++)
for(j=0;j<n;j++)
if(b[i][j]!=0) b[i][j]=1;
for(i=0;i<m;i++)
for(j=0;j<n;j++)
{
int s=0;
for(k=0;k<n;k++)
s=s||b[i][k];
for(k=0;k<m;k++)
s=s||b[k][j];
if(s!=a[i][j]) {printf("NO\n");return 0;}
}
puts("YES");
for(i=0;i<m;i++,puts(""))
for(j=0;j<n;j++)
printf("%d ",b[i][j]);
return 0;
}
| |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | f9c5c6cf945a543d9e2e448321c651f0 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include<stdio.h>
int main()
{
int m,n,a[100][100],b[100][100],flag,i,j,x;
for(i=0;i<100;i++)
{
for(j=0;j<100;j++)
{
a[i][j]=1;
}
}
scanf("%d %d",&m,&n);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&b[i][j]);
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{ if(b[i][j]==0)
{
for(x=0;x<m;x++)
a[x][j]=0;
for(x=0;x<n;x++)
a[i][x]=0;
}
}
}
// flag=0;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
flag=0;
if(b[i][j]==1)
{
for(x=0;x<m;x++)
if(a[x][j]==1)
flag=1;
for(x=0;x<n;x++)
if(a[i][x]==1)
flag=1;
if(flag==0)
{
printf("NO");
return 0;
}
}
}
}
printf("YES\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d ",a[i][j]);
}
printf("\n");
}
return 0;
}
| |
Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner: where is equal to 1 if some ai = 1, otherwise it is equal to 0.Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:.(Bij is OR of all elements in row i and column j of matrix A)Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large. | In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one. | C | bacd613dc8a91cee8bef87b787e878ca | 9ab1e6ba54deb59a10a5979c051c5524 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"greedy"
] | 1415718000 | ["2 2\n1 0\n0 0", "2 3\n1 1 1\n1 1 1", "2 3\n0 1 0\n1 1 1"] | null | PASSED | 1,300 | standard input | 1 second | The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively. The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1). | ["NO", "YES\n1 1 1\n1 1 1", "YES\n0 0 0\n0 1 0"] | #include<stdio.h>
int main()
{
int n,m,i,j,a[105][105];
int f=0,b[105][105],c[105][105],k;
scanf("%d%d",&m,&n);
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++){
a[i][j]=1;
c[i][j]=0;
}
}
for(i=1;i<=m;i++)
{
//printf("yes\n");
for(j=1;j<=n;j++){
scanf("%d",&b[i][j]);
if(b[i][j]==0)
{
for(k=1;k<=n;k++)
a[i][k]=0;
for(k=1;k<=m;k++)
a[k][j]=0;
}
// printf("%d ",b[i][j]);
}
//printf("\n");
}
// printf("after 1\n");
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
// if(a[i][j]==1){
if(a[i][j]==1){
for(k=1;k<=m;k++)
c[k][j]=1;
for(k=1;k<=n;k++)
c[i][k]=1;
}
}
}
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
if(b[i][j]!=c[i][j]){
f=1;
printf("NO\n");
return 0;
}
//printf("%d ",c[i][j]);
}
//printf("\n");
}
if(f!=1){
printf("YES\n");
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
printf("%d ",a[i][j]);
}
printf("\n");
}
}
return 0;
}
| |
In a strategic computer game "Settlers II" one has to build defense structures to expand and protect the territory. Let's take one of these buildings. At the moment the defense structure accommodates exactly n soldiers. Within this task we can assume that the number of soldiers in the defense structure won't either increase or decrease.Every soldier has a rank — some natural number from 1 to k. 1 stands for a private and k stands for a general. The higher the rank of the soldier is, the better he fights. Therefore, the player profits from having the soldiers of the highest possible rank.To increase the ranks of soldiers they need to train. But the soldiers won't train for free, and each training session requires one golden coin. On each training session all the n soldiers are present.At the end of each training session the soldiers' ranks increase as follows. First all the soldiers are divided into groups with the same rank, so that the least possible number of groups is formed. Then, within each of the groups where the soldiers below the rank k are present, exactly one soldier increases his rank by one.You know the ranks of all n soldiers at the moment. Determine the number of golden coins that are needed to increase the ranks of all the soldiers to the rank k. | Print a single integer — the number of golden coins needed to raise all the soldiers to the maximal rank. | C | 3d6411d67c85f6293f1999ccff2cd8ba | 9bf9b11f8d9fcc7624b8b1f5d134d9da | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1298908800 | ["4 4\n1 2 2 3", "4 3\n1 1 1 1"] | NoteIn the first example the ranks will be raised in the following manner:1 2 2 3 → 2 2 3 4 → 2 3 4 4 → 3 4 4 4 → 4 4 4 4Thus totals to 4 training sessions that require 4 golden coins. | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n and k (1 ≤ n, k ≤ 100). They represent the number of soldiers and the number of different ranks correspondingly. The second line contains n numbers in the non-decreasing order. The i-th of them, ai, represents the rank of the i-th soldier in the defense building (1 ≤ i ≤ n, 1 ≤ ai ≤ k). | ["4", "5"] | #include <stdio.h>
int Cnt[101];
int main()
{
int n, k, a, ans = 0;
scanf("%d %d", &n, &k);
for(int i = 0; i < n; ++i) {
scanf("%d", &a);
++Cnt[a];
}
while(1) {
char update = 0;
for(int i = k - 1; i >= 1; --i) {
if(Cnt[i]) {
--Cnt[i];
++Cnt[i + 1];
update = 1;
}
}
if(!update) {
break;
}
ans += update;
}
printf("%d\n", ans);
return 0;
}
| |
In a strategic computer game "Settlers II" one has to build defense structures to expand and protect the territory. Let's take one of these buildings. At the moment the defense structure accommodates exactly n soldiers. Within this task we can assume that the number of soldiers in the defense structure won't either increase or decrease.Every soldier has a rank — some natural number from 1 to k. 1 stands for a private and k stands for a general. The higher the rank of the soldier is, the better he fights. Therefore, the player profits from having the soldiers of the highest possible rank.To increase the ranks of soldiers they need to train. But the soldiers won't train for free, and each training session requires one golden coin. On each training session all the n soldiers are present.At the end of each training session the soldiers' ranks increase as follows. First all the soldiers are divided into groups with the same rank, so that the least possible number of groups is formed. Then, within each of the groups where the soldiers below the rank k are present, exactly one soldier increases his rank by one.You know the ranks of all n soldiers at the moment. Determine the number of golden coins that are needed to increase the ranks of all the soldiers to the rank k. | Print a single integer — the number of golden coins needed to raise all the soldiers to the maximal rank. | C | 3d6411d67c85f6293f1999ccff2cd8ba | 1b2dcafaafd00ea70eba5e0ecb0ebf13 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1298908800 | ["4 4\n1 2 2 3", "4 3\n1 1 1 1"] | NoteIn the first example the ranks will be raised in the following manner:1 2 2 3 → 2 2 3 4 → 2 3 4 4 → 3 4 4 4 → 4 4 4 4Thus totals to 4 training sessions that require 4 golden coins. | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n and k (1 ≤ n, k ≤ 100). They represent the number of soldiers and the number of different ranks correspondingly. The second line contains n numbers in the non-decreasing order. The i-th of them, ai, represents the rank of the i-th soldier in the defense building (1 ≤ i ≤ n, 1 ≤ ai ≤ k). | ["4", "5"] | #include<stdio.h>
int comp(const void *a,const void *b)
{
return (*(int *)a-*(int *)b);
}
int main()
{
int n,k,i,j,ara[1000],x=0;
scanf("%d%d",&n,&k);
for(i=0;i<n;i++){
scanf("%d",&ara[i]);
}
while(1){
qsort(ara,n,sizeof(int),comp);
if(ara[0]==k){
break;
}
for(i=0;i<n;i++){
if(ara[i]==k){
break;
}
j=i+1;
while(ara[j]==ara[i]){
j++;
}
ara[i]++;
i=j-1;
}
x++;
}
printf("%d",x);
return 0;
} | |
In a strategic computer game "Settlers II" one has to build defense structures to expand and protect the territory. Let's take one of these buildings. At the moment the defense structure accommodates exactly n soldiers. Within this task we can assume that the number of soldiers in the defense structure won't either increase or decrease.Every soldier has a rank — some natural number from 1 to k. 1 stands for a private and k stands for a general. The higher the rank of the soldier is, the better he fights. Therefore, the player profits from having the soldiers of the highest possible rank.To increase the ranks of soldiers they need to train. But the soldiers won't train for free, and each training session requires one golden coin. On each training session all the n soldiers are present.At the end of each training session the soldiers' ranks increase as follows. First all the soldiers are divided into groups with the same rank, so that the least possible number of groups is formed. Then, within each of the groups where the soldiers below the rank k are present, exactly one soldier increases his rank by one.You know the ranks of all n soldiers at the moment. Determine the number of golden coins that are needed to increase the ranks of all the soldiers to the rank k. | Print a single integer — the number of golden coins needed to raise all the soldiers to the maximal rank. | C | 3d6411d67c85f6293f1999ccff2cd8ba | d3e9ccbe7f48ffb164734cca52afb15d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1298908800 | ["4 4\n1 2 2 3", "4 3\n1 1 1 1"] | NoteIn the first example the ranks will be raised in the following manner:1 2 2 3 → 2 2 3 4 → 2 3 4 4 → 3 4 4 4 → 4 4 4 4Thus totals to 4 training sessions that require 4 golden coins. | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n and k (1 ≤ n, k ≤ 100). They represent the number of soldiers and the number of different ranks correspondingly. The second line contains n numbers in the non-decreasing order. The i-th of them, ai, represents the rank of the i-th soldier in the defense building (1 ≤ i ≤ n, 1 ≤ ai ≤ k). | ["4", "5"] | #include<stdio.h>
int comp(const void *a,const void *b)
{
return (*(int *)a-*(int *)b);
}
int main()
{
int n,k,i,j,ara[1000],x=0;
scanf("%d%d",&n,&k);
for(i=0;i<n;i++){
scanf("%d",&ara[i]);
}
while(1){
qsort(ara,n,sizeof(int),comp);
if(ara[0]==k){
break;
}
for(i=0;i<n;i++){
if(ara[i]==k){
break;
}
j=i+1;
while(ara[j]==ara[i]){
j++;
}
ara[i]++;
i=j-1;
}
x++;
}
printf("%d",x);
return 0;
}
| |
In a strategic computer game "Settlers II" one has to build defense structures to expand and protect the territory. Let's take one of these buildings. At the moment the defense structure accommodates exactly n soldiers. Within this task we can assume that the number of soldiers in the defense structure won't either increase or decrease.Every soldier has a rank — some natural number from 1 to k. 1 stands for a private and k stands for a general. The higher the rank of the soldier is, the better he fights. Therefore, the player profits from having the soldiers of the highest possible rank.To increase the ranks of soldiers they need to train. But the soldiers won't train for free, and each training session requires one golden coin. On each training session all the n soldiers are present.At the end of each training session the soldiers' ranks increase as follows. First all the soldiers are divided into groups with the same rank, so that the least possible number of groups is formed. Then, within each of the groups where the soldiers below the rank k are present, exactly one soldier increases his rank by one.You know the ranks of all n soldiers at the moment. Determine the number of golden coins that are needed to increase the ranks of all the soldiers to the rank k. | Print a single integer — the number of golden coins needed to raise all the soldiers to the maximal rank. | C | 3d6411d67c85f6293f1999ccff2cd8ba | 4d8b3e8db39644eeae23779bb54f767a | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1298908800 | ["4 4\n1 2 2 3", "4 3\n1 1 1 1"] | NoteIn the first example the ranks will be raised in the following manner:1 2 2 3 → 2 2 3 4 → 2 3 4 4 → 3 4 4 4 → 4 4 4 4Thus totals to 4 training sessions that require 4 golden coins. | PASSED | 1,200 | standard input | 2 seconds | The first line contains two integers n and k (1 ≤ n, k ≤ 100). They represent the number of soldiers and the number of different ranks correspondingly. The second line contains n numbers in the non-decreasing order. The i-th of them, ai, represents the rank of the i-th soldier in the defense building (1 ≤ i ≤ n, 1 ≤ ai ≤ k). | ["4", "5"] | #include <stdio.h>
#include <stdlib.h>
int n,k,i,j,a[101],nr,x;
int main()
{
scanf("%d",&n);
scanf("%d",&k);
for(i=1;i<=n;i++)
{
scanf("%d",&x);
a[x]++;
}
i=1;
while(a[i]==0)
i++;
while(i<k)
{
for(j=i;j<k;j++)
{
if(a[j]!=0)
{
a[j]--;
a[j+1]++;
}
}
nr++;
if(a[i]==0)
i++;
}
printf("%d",nr);
return 0;
}
| |
Jon Snow is on the lookout for some orbs required to defeat the white walkers. There are k different types of orbs and he needs at least one of each. One orb spawns daily at the base of a Weirwood tree north of the wall. The probability of this orb being of any kind is equal. As the north of wall is full of dangers, he wants to know the minimum number of days he should wait before sending a ranger to collect the orbs such that the probability of him getting at least one of each kind of orb is at least , where ε < 10 - 7.To better prepare himself, he wants to know the answer for q different values of pi. Since he is busy designing the battle strategy with Sam, he asks you for your help. | Output q lines. On i-th of them output single integer — answer for i-th query. | C | a2b71d66ea1fdc3249e37be3ab0e67ef | 1614ddf9c209964ef6812e91359bbe43 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"probabilities",
"math"
] | 1487606700 | ["1 1\n1", "2 2\n1\n2"] | null | PASSED | 2,200 | standard input | 2 seconds | First line consists of two space separated integers k, q (1 ≤ k, q ≤ 1000) — number of different kinds of orbs and number of queries respectively. Each of the next q lines contain a single integer pi (1 ≤ pi ≤ 1000) — i-th query. | ["1", "2\n2"] | /* practice with Dukkha */
#include <stdio.h>
#include <stdlib.h>
#define K 1000
int main() {
static double dp[K + 1];
double *pp;
int n, k, d, q, h;
scanf("%d%d", &k, &q);
dp[0] = 1;
n = k, d = 0;
pp = malloc(n * sizeof *pp);
pp[d++] = 0;
while (dp[k] < 0.5) {
for (h = k; h > 0; h--)
dp[h] = (dp[h] * h + dp[h - 1] * (k - h + 1)) / k;
dp[0] = 0;
if (d == n)
pp = realloc(pp, (n *= 2) * sizeof *pp);
pp[d++] = dp[k];
}
while (q--) {
double p;
int lower, upper, d_;
scanf("%lf", &p), p /= 2000;
lower = 0, upper = d;
while (upper - lower > 1) {
d_ = (lower + upper) / 2;
if (pp[d_] >= p)
upper = d_;
else
lower = d_;
}
printf("%d\n", upper);
}
return 0;
}
| |
Jon Snow is on the lookout for some orbs required to defeat the white walkers. There are k different types of orbs and he needs at least one of each. One orb spawns daily at the base of a Weirwood tree north of the wall. The probability of this orb being of any kind is equal. As the north of wall is full of dangers, he wants to know the minimum number of days he should wait before sending a ranger to collect the orbs such that the probability of him getting at least one of each kind of orb is at least , where ε < 10 - 7.To better prepare himself, he wants to know the answer for q different values of pi. Since he is busy designing the battle strategy with Sam, he asks you for your help. | Output q lines. On i-th of them output single integer — answer for i-th query. | C | a2b71d66ea1fdc3249e37be3ab0e67ef | ef4a2f6e2178bd74fd03db99ac15b961 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"probabilities",
"math"
] | 1487606700 | ["1 1\n1", "2 2\n1\n2"] | null | PASSED | 2,200 | standard input | 2 seconds | First line consists of two space separated integers k, q (1 ≤ k, q ≤ 1000) — number of different kinds of orbs and number of queries respectively. Each of the next q lines contain a single integer pi (1 ≤ pi ≤ 1000) — i-th query. | ["1", "2\n2"] | #include <stdio.h>
#include <string.h>
int const MX1=10100;
double memo[10100][1010];
double EPS=1e-7;
int k;
void dp()
{
int i,j;
memo[0][0]=1;
for(i=1;i<MX1;i++)
{
for(j=0;j<1010;j++)
{
if(i>0 && j>0)memo[i][j]=memo[i-1][j-1]*((double)(k+1-j)/k);
else memo[i][j]=0;
if(i>j && i>0)memo[i][j]+=memo[i-1][j]*((double)(j)/k);
}
}
}
int main()
{
int q;
double p,x;
memset(memo,0,sizeof(memo));
scanf("%d %d",&k,&q);
dp();
int top, bot,mid;
while(q--)
{
scanf("%lf",&p);
x=(p+EPS)/2000;
bot=k; top=MX1;
while(top>bot)
{
mid=(top+bot)/2;
if(memo[mid-1][k]>x)top=mid;
else bot=mid+1;
}
printf("%d\n", bot-1);
}
return 0;
} | |
Jon Snow is on the lookout for some orbs required to defeat the white walkers. There are k different types of orbs and he needs at least one of each. One orb spawns daily at the base of a Weirwood tree north of the wall. The probability of this orb being of any kind is equal. As the north of wall is full of dangers, he wants to know the minimum number of days he should wait before sending a ranger to collect the orbs such that the probability of him getting at least one of each kind of orb is at least , where ε < 10 - 7.To better prepare himself, he wants to know the answer for q different values of pi. Since he is busy designing the battle strategy with Sam, he asks you for your help. | Output q lines. On i-th of them output single integer — answer for i-th query. | C | a2b71d66ea1fdc3249e37be3ab0e67ef | 79a8774f0ca8c13624897babf6b5e5be | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"probabilities",
"math"
] | 1487606700 | ["1 1\n1", "2 2\n1\n2"] | null | PASSED | 2,200 | standard input | 2 seconds | First line consists of two space separated integers k, q (1 ≤ k, q ≤ 1000) — number of different kinds of orbs and number of queries respectively. Each of the next q lines contain a single integer pi (1 ≤ pi ≤ 1000) — i-th query. | ["1", "2\n2"] | #include <stdio.h>
#include <string.h>
#define N 1001
int n, k, q, p, i,j;
int respuesta[N];
double aux[10*N][N];
int main(){
scanf("%d",&n);
scanf("%d",&q);
aux[0][0] = 1;
for(i = 1; i < 10*N; ++i){aux[i][0] = 0;
for(j=1; j <= n; ++j){aux[i][j] = (aux[i-1][j-1]*(n-j+1)+aux[i-1][j]*j)/n;
//printf("%f\n",dp[i][j]);
}
}
for(i=1; i<=1000;++i){while(aux[k][n]*2000<i)k++;respuesta[i]=k;}
while(q--){scanf("%d",&p);printf("%d\n",respuesta[p]);}
return 0;
}
| |
Jon Snow is on the lookout for some orbs required to defeat the white walkers. There are k different types of orbs and he needs at least one of each. One orb spawns daily at the base of a Weirwood tree north of the wall. The probability of this orb being of any kind is equal. As the north of wall is full of dangers, he wants to know the minimum number of days he should wait before sending a ranger to collect the orbs such that the probability of him getting at least one of each kind of orb is at least , where ε < 10 - 7.To better prepare himself, he wants to know the answer for q different values of pi. Since he is busy designing the battle strategy with Sam, he asks you for your help. | Output q lines. On i-th of them output single integer — answer for i-th query. | C | a2b71d66ea1fdc3249e37be3ab0e67ef | f6a078b87b3b721d28dc6178526c585f | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"probabilities",
"math"
] | 1487606700 | ["1 1\n1", "2 2\n1\n2"] | null | PASSED | 2,200 | standard input | 2 seconds | First line consists of two space separated integers k, q (1 ≤ k, q ≤ 1000) — number of different kinds of orbs and number of queries respectively. Each of the next q lines contain a single integer pi (1 ≤ pi ≤ 1000) — i-th query. | ["1", "2\n2"] | #include <stdio.h>
#include <string.h>
#define N 1001
int n, k, q, p;
int ans[N];
double dp[10*N][N];
int main(){
scanf("%d%d", &n, &q);
dp[0][0] = 1;
for(int i = 1; i < 10*N; ++i){
dp[i][0] = 0;
for(int j=1; j <= n; ++j)
dp[i][j] = (dp[i-1][j-1]*(n-j+1)+dp[i-1][j]*j)/n;
}
for(int i =1; i<=1000;++i){
while(dp[k][n]*2000<i)
k++;
ans[i]=k;
}
while(q--){
scanf("%d",&p);
printf("%d\n",ans[p]);
}
return 0;
} | |
Jon Snow is on the lookout for some orbs required to defeat the white walkers. There are k different types of orbs and he needs at least one of each. One orb spawns daily at the base of a Weirwood tree north of the wall. The probability of this orb being of any kind is equal. As the north of wall is full of dangers, he wants to know the minimum number of days he should wait before sending a ranger to collect the orbs such that the probability of him getting at least one of each kind of orb is at least , where ε < 10 - 7.To better prepare himself, he wants to know the answer for q different values of pi. Since he is busy designing the battle strategy with Sam, he asks you for your help. | Output q lines. On i-th of them output single integer — answer for i-th query. | C | a2b71d66ea1fdc3249e37be3ab0e67ef | 82e8d2876d74671a744d53fe5b4fe613 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"probabilities",
"math"
] | 1487606700 | ["1 1\n1", "2 2\n1\n2"] | null | PASSED | 2,200 | standard input | 2 seconds | First line consists of two space separated integers k, q (1 ≤ k, q ≤ 1000) — number of different kinds of orbs and number of queries respectively. Each of the next q lines contain a single integer pi (1 ≤ pi ≤ 1000) — i-th query. | ["1", "2\n2"] | #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define eps 0.0000001
typedef unsigned u;
typedef double d;
d S[7275][1001];
int main()
{
S[1][0]=S[1][1]=1.0;
u i,j,q,p,lo,hi,mi;
for(i=1;++i<7275;)for(S[i][j=0]=1.0;++j<=i;)
{
if(j>1000)break;
S[i][j]=S[i-1][j]+pow(((d)(j-1))/((d)j),i-1)*S[i-1][j-1];
}
for(scanf("%u%u",&j,&q);q--;)
{
scanf("%u",&p);
lo=j-1;hi=7275;
while((mi=(lo+hi)>>1)>lo)
{
if((((d)p)-eps)/2000.0<S[mi][j])hi=mi;
else lo=mi;
}
printf("%u\n",hi);
}
return 0;
}
| |
Jon Snow is on the lookout for some orbs required to defeat the white walkers. There are k different types of orbs and he needs at least one of each. One orb spawns daily at the base of a Weirwood tree north of the wall. The probability of this orb being of any kind is equal. As the north of wall is full of dangers, he wants to know the minimum number of days he should wait before sending a ranger to collect the orbs such that the probability of him getting at least one of each kind of orb is at least , where ε < 10 - 7.To better prepare himself, he wants to know the answer for q different values of pi. Since he is busy designing the battle strategy with Sam, he asks you for your help. | Output q lines. On i-th of them output single integer — answer for i-th query. | C | a2b71d66ea1fdc3249e37be3ab0e67ef | 8fad8373cb0809ca3861a1b71412fb7d | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"probabilities",
"math"
] | 1487606700 | ["1 1\n1", "2 2\n1\n2"] | null | PASSED | 2,200 | standard input | 2 seconds | First line consists of two space separated integers k, q (1 ≤ k, q ≤ 1000) — number of different kinds of orbs and number of queries respectively. Each of the next q lines contain a single integer pi (1 ≤ pi ≤ 1000) — i-th query. | ["1", "2\n2"] | #include<stdio.h>
#include<string.h>
int main(){
int k,q,p[1000],a[1000],b[1000],i,j,day;
long double d[1001];
scanf("%d%d",&k,&q);
for(i=0;i<q;i++){
a[i]=i;
scanf("%d",&p[i]);
j=i;
while(j>0 && p[j]<p[j-1]){
p[j-1]=p[j]+p[j-1];
p[j]=p[j-1]-p[j];
p[j-1]=p[j-1]-p[j];
a[j-1]=a[j]+a[j-1];
a[j]=a[j-1]-a[j];
a[j-1]=a[j-1]-a[j];
j--;
}
}
memset(d,0,sizeof(d));
d[0]=1;
day=0;
for(i=0;i<q;i++){
while((p[i]-1e-7)/2000>d[k]){
day++;
for(j=k;j>=1;j--) d[j]=d[j]*j/k+d[j-1]*(k-j+1)/k;
d[0]=0;
}
b[a[i]]=day;
}
for(i=0;i<q;i++) printf("%d\n",b[i]);
} | |
Polycarp has guessed three positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$.You have to guess three numbers $$$a$$$, $$$b$$$ and $$$c$$$ using given numbers. Print three guessed integers in any order.Pay attention that some given numbers $$$a$$$, $$$b$$$ and $$$c$$$ can be equal (it is also possible that $$$a=b=c$$$). | Print such positive integers $$$a$$$, $$$b$$$ and $$$c$$$ that four numbers written on a board are values $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$ written in some order. Print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. If there are several answers, you can print any. It is guaranteed that the answer exists. | C | cda949a8fb1f158f3c06109a2d33f084 | 1135ff87a8290f1c742f6a1325a28124 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1555425300 | ["3 6 5 4", "40 40 40 60", "201 101 101 200"] | null | PASSED | 800 | standard input | 1 second | The only line of the input contains four positive integers $$$x_1, x_2, x_3, x_4$$$ ($$$2 \le x_i \le 10^9$$$) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number $$$x_1, x_2, x_3, x_4$$$. | ["2 1 3", "20 20 20", "1 100 100"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int arr [4];
int i=0;
int n;
for( i=0;i<4;i++){
scanf("%d",&n);
arr[i]=n;
}
for(i=0;i<3;i++){
if(arr[i]>arr[i+1]){
int temp = arr[i];
arr[i]=arr[i+1];
arr[i+1]=temp;
}
}
printf("%d %d %d ",arr[3]-arr[2],arr[3]-arr[1],arr[3]-arr[0]);
} | |
Polycarp has guessed three positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$.You have to guess three numbers $$$a$$$, $$$b$$$ and $$$c$$$ using given numbers. Print three guessed integers in any order.Pay attention that some given numbers $$$a$$$, $$$b$$$ and $$$c$$$ can be equal (it is also possible that $$$a=b=c$$$). | Print such positive integers $$$a$$$, $$$b$$$ and $$$c$$$ that four numbers written on a board are values $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$ written in some order. Print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. If there are several answers, you can print any. It is guaranteed that the answer exists. | C | cda949a8fb1f158f3c06109a2d33f084 | e0ac8badccb9211960f01b9198b47884 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1555425300 | ["3 6 5 4", "40 40 40 60", "201 101 101 200"] | null | PASSED | 800 | standard input | 1 second | The only line of the input contains four positive integers $$$x_1, x_2, x_3, x_4$$$ ($$$2 \le x_i \le 10^9$$$) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number $$$x_1, x_2, x_3, x_4$$$. | ["2 1 3", "20 20 20", "1 100 100"] | #include <stdio.h>
int main()
{
int x1,x2,x3,x4,a,b,c;
scanf("%d %d %d %d",&x1,&x2,&x3,&x4);
if(x4==((x1+x2+x3)/2))
{
a=x4-x1;
b=x4-x2;
c=x4-x3;
}
else if(x3==((x1+x2+x4)/2))
{
a=x3-x1;
b=x3-x2;
c=x3-x4;
}
else if(x2==((x1+x3+x4)/2))
{
a=x2-x1;
b=x2-x3;
c=x2-x4;
}
else
{
a=x1-x2;
b=x1-x3;
c=x1-x4;
}
printf("%d %d %d\n",a,b,c);
return 0;
}
| |
Polycarp has guessed three positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$.You have to guess three numbers $$$a$$$, $$$b$$$ and $$$c$$$ using given numbers. Print three guessed integers in any order.Pay attention that some given numbers $$$a$$$, $$$b$$$ and $$$c$$$ can be equal (it is also possible that $$$a=b=c$$$). | Print such positive integers $$$a$$$, $$$b$$$ and $$$c$$$ that four numbers written on a board are values $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$ written in some order. Print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. If there are several answers, you can print any. It is guaranteed that the answer exists. | C | cda949a8fb1f158f3c06109a2d33f084 | e6d69c7d0b2c7ad277622a3671ee385a | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1555425300 | ["3 6 5 4", "40 40 40 60", "201 101 101 200"] | null | PASSED | 800 | standard input | 1 second | The only line of the input contains four positive integers $$$x_1, x_2, x_3, x_4$$$ ($$$2 \le x_i \le 10^9$$$) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number $$$x_1, x_2, x_3, x_4$$$. | ["2 1 3", "20 20 20", "1 100 100"] | #include <stdio.h>
int main(void){
int i;
int sum[4];
scanf ("%d %d %d %d",&sum[0],&sum[1],&sum[2],&sum[3]);
int biggest = sum[0];
for(i = 0; i < 4; i++){
if(sum[i] > biggest)
biggest = sum [i];
}
for(i = 0; i < 4; i++){
sum[i] = biggest - sum[i];
if(sum[i] != 0)
printf("%d ",sum[i]);
}
} | |
Polycarp has guessed three positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$.You have to guess three numbers $$$a$$$, $$$b$$$ and $$$c$$$ using given numbers. Print three guessed integers in any order.Pay attention that some given numbers $$$a$$$, $$$b$$$ and $$$c$$$ can be equal (it is also possible that $$$a=b=c$$$). | Print such positive integers $$$a$$$, $$$b$$$ and $$$c$$$ that four numbers written on a board are values $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$ written in some order. Print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. If there are several answers, you can print any. It is guaranteed that the answer exists. | C | cda949a8fb1f158f3c06109a2d33f084 | 1048273471c822cb6ebb7d703e319ace | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1555425300 | ["3 6 5 4", "40 40 40 60", "201 101 101 200"] | null | PASSED | 800 | standard input | 1 second | The only line of the input contains four positive integers $$$x_1, x_2, x_3, x_4$$$ ($$$2 \le x_i \le 10^9$$$) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number $$$x_1, x_2, x_3, x_4$$$. | ["2 1 3", "20 20 20", "1 100 100"] | #include<stdio.h>
int main()
{
long long int x,y,z,a,mx;
scanf("%lld%lld%lld%lld",&x,&y,&z,&a);
if(x>y && x>z && x>a)
{
mx=x;
}
else if(y>x && y>z && y>a)
{
mx=y;
}
else if(z>x && z>y && z>a){mx=z;}
else mx=a;
if(mx==x)
{
printf("%lld %lld %lld",x-y,x-z,x-a);
}
else if(mx==y)
{
printf("%lld %lld %lld",y-z,y-x,y-a);
}
else if(mx==z)
{
printf("%lld %lld %lld",z-y,z-x,z-a);
}
else printf("%lld %lld %lld",a-z,a-x,a-y);
return 0;
}
| |
Polycarp has guessed three positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$.You have to guess three numbers $$$a$$$, $$$b$$$ and $$$c$$$ using given numbers. Print three guessed integers in any order.Pay attention that some given numbers $$$a$$$, $$$b$$$ and $$$c$$$ can be equal (it is also possible that $$$a=b=c$$$). | Print such positive integers $$$a$$$, $$$b$$$ and $$$c$$$ that four numbers written on a board are values $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$ written in some order. Print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. If there are several answers, you can print any. It is guaranteed that the answer exists. | C | cda949a8fb1f158f3c06109a2d33f084 | 33fb34cb1f2f663a7e6132c20083e456 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1555425300 | ["3 6 5 4", "40 40 40 60", "201 101 101 200"] | null | PASSED | 800 | standard input | 1 second | The only line of the input contains four positive integers $$$x_1, x_2, x_3, x_4$$$ ($$$2 \le x_i \le 10^9$$$) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number $$$x_1, x_2, x_3, x_4$$$. | ["2 1 3", "20 20 20", "1 100 100"] | #include<stdio.h>
int main()
{
int a,b,c,d,mx;
scanf("%d%d%d%d",&a,&b,&c,&d);
if(a>b && a>c && a>d)
{
printf("%d %d %d\n",a-b,a-c,a-d);
}
else if(b>c && b>a && b>d)
{
printf("%d %d %d\n",b-a,b-c,b-d);
}
else if(c>b && c>a && c>d)
{
printf("%d %d %d\n",c-b,c-a,c-d);
}
else printf("%d %d %d\n",d-b,d-a,d-c);
return 0;
}
| |
Polycarp has guessed three positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$.You have to guess three numbers $$$a$$$, $$$b$$$ and $$$c$$$ using given numbers. Print three guessed integers in any order.Pay attention that some given numbers $$$a$$$, $$$b$$$ and $$$c$$$ can be equal (it is also possible that $$$a=b=c$$$). | Print such positive integers $$$a$$$, $$$b$$$ and $$$c$$$ that four numbers written on a board are values $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$ written in some order. Print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. If there are several answers, you can print any. It is guaranteed that the answer exists. | C | cda949a8fb1f158f3c06109a2d33f084 | 5b4a2068bda59ef67b5ae514d34d5458 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1555425300 | ["3 6 5 4", "40 40 40 60", "201 101 101 200"] | null | PASSED | 800 | standard input | 1 second | The only line of the input contains four positive integers $$$x_1, x_2, x_3, x_4$$$ ($$$2 \le x_i \le 10^9$$$) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number $$$x_1, x_2, x_3, x_4$$$. | ["2 1 3", "20 20 20", "1 100 100"] | #include<stdio.h>
int main()
{
long long a,b,c,x1,x2,x3,x4;
scanf("%lld%lld%lld%lld",&x1,&x2,&x3,&x4);
if(x1>x2 && x1>x3 && x1>x4)
{
a=(x2-x3+x4)/2;
b=(x2+x3-x4)/2;
c=(-x2+x3+x4)/2;
printf("%lld %lld %lld",a,b,c);
}
if(x2>x1 && x2>x3 && x2>x4)
{
a=(x1-x3+x4)/2;
b=(x1+x3-x4)/2;
c=(-x1+x3+x4)/2;
printf("%lld %lld %lld",a,b,c);
}
if(x3>x1 && x3>x2 && x3>x4)
{
a=(x1-x2+x4)/2;
b=(x1+x2-x4)/2;
c=(-x1+x2+x4)/2;
printf("%lld %lld %lld",a,b,c);
}
if(x4>x1 && x4>x2 && x4>x3)
{
a=(x1-x2+x3)/2;
b=(x1+x2-x3)/2;
c=(-x1+x2+x3)/2;
printf("%lld %lld %lld",a,b,c);
}
return 0;
}
| |
Polycarp has guessed three positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$.You have to guess three numbers $$$a$$$, $$$b$$$ and $$$c$$$ using given numbers. Print three guessed integers in any order.Pay attention that some given numbers $$$a$$$, $$$b$$$ and $$$c$$$ can be equal (it is also possible that $$$a=b=c$$$). | Print such positive integers $$$a$$$, $$$b$$$ and $$$c$$$ that four numbers written on a board are values $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$ written in some order. Print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. If there are several answers, you can print any. It is guaranteed that the answer exists. | C | cda949a8fb1f158f3c06109a2d33f084 | 09d4e35a20ed46c920e931e7809cc6ce | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1555425300 | ["3 6 5 4", "40 40 40 60", "201 101 101 200"] | null | PASSED | 800 | standard input | 1 second | The only line of the input contains four positive integers $$$x_1, x_2, x_3, x_4$$$ ($$$2 \le x_i \le 10^9$$$) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number $$$x_1, x_2, x_3, x_4$$$. | ["2 1 3", "20 20 20", "1 100 100"] | #include<stdio.h>
#include<math.h>
int main()
{
long long int input[4];
long long int output[4];
int i;
long long int max;
for(i=0; i<4; i++)
{
scanf("%I64d",&input[i]);
if(i==0)
max = input[i];
if(input[i]>max) max = input[i];
}
for(i=0; i<4; i++)
{
output[i] = max - input[i];
if (output[i]!=0)
printf("%d ",output[i]);
}
} | |
Polycarp has guessed three positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$.You have to guess three numbers $$$a$$$, $$$b$$$ and $$$c$$$ using given numbers. Print three guessed integers in any order.Pay attention that some given numbers $$$a$$$, $$$b$$$ and $$$c$$$ can be equal (it is also possible that $$$a=b=c$$$). | Print such positive integers $$$a$$$, $$$b$$$ and $$$c$$$ that four numbers written on a board are values $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$ written in some order. Print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. If there are several answers, you can print any. It is guaranteed that the answer exists. | C | cda949a8fb1f158f3c06109a2d33f084 | 29bb823c2c760441a0f2a2e444711750 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1555425300 | ["3 6 5 4", "40 40 40 60", "201 101 101 200"] | null | PASSED | 800 | standard input | 1 second | The only line of the input contains four positive integers $$$x_1, x_2, x_3, x_4$$$ ($$$2 \le x_i \le 10^9$$$) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number $$$x_1, x_2, x_3, x_4$$$. | ["2 1 3", "20 20 20", "1 100 100"] | #include<stdio.h>
#include<math.h>
int main()
{
long long int input[4];
long long int output[4];
int i;
long long int max;
for(i=0; i<4; i++)
{
scanf("%I64d",&input[i]);
if(i==0)
max = input[i];
if(input[i]>max) max = input[i];
}
for(i=0; i<4; i++)
{
output[i] = max - input[i];
if (output[i]!=0)
printf("%d ",output[i]);
}
} | |
Polycarp has guessed three positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$.You have to guess three numbers $$$a$$$, $$$b$$$ and $$$c$$$ using given numbers. Print three guessed integers in any order.Pay attention that some given numbers $$$a$$$, $$$b$$$ and $$$c$$$ can be equal (it is also possible that $$$a=b=c$$$). | Print such positive integers $$$a$$$, $$$b$$$ and $$$c$$$ that four numbers written on a board are values $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$ written in some order. Print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. If there are several answers, you can print any. It is guaranteed that the answer exists. | C | cda949a8fb1f158f3c06109a2d33f084 | 6e50b57080725f38bf44fade67b4e94d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1555425300 | ["3 6 5 4", "40 40 40 60", "201 101 101 200"] | null | PASSED | 800 | standard input | 1 second | The only line of the input contains four positive integers $$$x_1, x_2, x_3, x_4$$$ ($$$2 \le x_i \le 10^9$$$) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number $$$x_1, x_2, x_3, x_4$$$. | ["2 1 3", "20 20 20", "1 100 100"] | #include<stdio.h>
int main(){
int x1,x2,x3,x4,a,b,c;
scanf("%d%d%d%d%d",&x1,&x2,&x3,&x4);
if(x1>x2&&x1>x3&&x1>x4){
a=x1-x2;b=x1-x3;c=x1-x4;}
if(x2>x1&&x2>x3&&x2>x4){
a=x2-x1;b=x2-x3;c=x2-x4;}
if(x3>x1&&x3>x2&&x3>x4){
a=x3-x1;b=x3-x2;c=x3-x4;}
if(x4>x1&&x4>x2&&x4>x3){
a=x4-x1;b=x4-x2;c=x4-x3;}
printf("%d %d %d\n",a,b,c);
return 0;} | |
Polycarp has guessed three positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$.You have to guess three numbers $$$a$$$, $$$b$$$ and $$$c$$$ using given numbers. Print three guessed integers in any order.Pay attention that some given numbers $$$a$$$, $$$b$$$ and $$$c$$$ can be equal (it is also possible that $$$a=b=c$$$). | Print such positive integers $$$a$$$, $$$b$$$ and $$$c$$$ that four numbers written on a board are values $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$ written in some order. Print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. If there are several answers, you can print any. It is guaranteed that the answer exists. | C | cda949a8fb1f158f3c06109a2d33f084 | 461b9e14fb337e7a7ee49555ef5539d6 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1555425300 | ["3 6 5 4", "40 40 40 60", "201 101 101 200"] | null | PASSED | 800 | standard input | 1 second | The only line of the input contains four positive integers $$$x_1, x_2, x_3, x_4$$$ ($$$2 \le x_i \le 10^9$$$) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number $$$x_1, x_2, x_3, x_4$$$. | ["2 1 3", "20 20 20", "1 100 100"] | #include<stdio.h>
int main()
{
int arr[5], i, j;
for(i=0; i<4; i++)
scanf("%d",&arr[i]);
for(i=0; i<4; i++)
{
for(j=0; j<3; j++)
{
if(arr[j]<arr[j+1])
{
int temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
for(i=1; i<4; i++)
printf("%d ",arr[0]-arr[i]);
return 0;
} | |
Polycarp has guessed three positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$.You have to guess three numbers $$$a$$$, $$$b$$$ and $$$c$$$ using given numbers. Print three guessed integers in any order.Pay attention that some given numbers $$$a$$$, $$$b$$$ and $$$c$$$ can be equal (it is also possible that $$$a=b=c$$$). | Print such positive integers $$$a$$$, $$$b$$$ and $$$c$$$ that four numbers written on a board are values $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$ written in some order. Print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. If there are several answers, you can print any. It is guaranteed that the answer exists. | C | cda949a8fb1f158f3c06109a2d33f084 | c8e07e3151935e2fb712253e8c83ec32 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1555425300 | ["3 6 5 4", "40 40 40 60", "201 101 101 200"] | null | PASSED | 800 | standard input | 1 second | The only line of the input contains four positive integers $$$x_1, x_2, x_3, x_4$$$ ($$$2 \le x_i \le 10^9$$$) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number $$$x_1, x_2, x_3, x_4$$$. | ["2 1 3", "20 20 20", "1 100 100"] | #include<stdio.h>
int main()
{
int arr[5], i, j;
for(i=0; i<4; i++)
{
scanf("%d",&arr[i]);
}
for(i=0; i<4; i++)
{
for(j=i+1; j<4; j++)
{
if(arr[i]>arr[j])
{
int temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
for(i=0; i<3; i++)
{
printf("\n%d ",arr[3]-arr[i]);
}
}
| |
Polycarp has guessed three positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$.You have to guess three numbers $$$a$$$, $$$b$$$ and $$$c$$$ using given numbers. Print three guessed integers in any order.Pay attention that some given numbers $$$a$$$, $$$b$$$ and $$$c$$$ can be equal (it is also possible that $$$a=b=c$$$). | Print such positive integers $$$a$$$, $$$b$$$ and $$$c$$$ that four numbers written on a board are values $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$ written in some order. Print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. If there are several answers, you can print any. It is guaranteed that the answer exists. | C | cda949a8fb1f158f3c06109a2d33f084 | 74808556844f8f23e6467bad6e73bb38 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1555425300 | ["3 6 5 4", "40 40 40 60", "201 101 101 200"] | null | PASSED | 800 | standard input | 1 second | The only line of the input contains four positive integers $$$x_1, x_2, x_3, x_4$$$ ($$$2 \le x_i \le 10^9$$$) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number $$$x_1, x_2, x_3, x_4$$$. | ["2 1 3", "20 20 20", "1 100 100"] | #include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <windows.h>
int main()
{
int i,j,h,g=4,L=3,s;
int y[g];
int w[L];
int ww[L];
for (i=0;i<g;i++)
scanf("%d",&y[i]);
for (i=0;i<g;i++)
{
s=0;
h=0;
for (j=0;j<g;j++)
{
if (i!=j)
{
s+=y[j];
ww[h]=y[j];
h++;
}
}
if (2*y[i]==s)
{
for (h=0;h<L;h++)
{
w[h]=0;
for (j=0;j<L;j++)
{
if (h==L-j-1)
w[h]-=ww[j];
else
w[h]+=ww[j];
}
}
for (h=0;h<L;h++)
{
w[h]=w[h]/2;
printf("%d ",w[h]);
}
}
}
getchar();
}
| |
Polycarp has guessed three positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$.You have to guess three numbers $$$a$$$, $$$b$$$ and $$$c$$$ using given numbers. Print three guessed integers in any order.Pay attention that some given numbers $$$a$$$, $$$b$$$ and $$$c$$$ can be equal (it is also possible that $$$a=b=c$$$). | Print such positive integers $$$a$$$, $$$b$$$ and $$$c$$$ that four numbers written on a board are values $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$ written in some order. Print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. If there are several answers, you can print any. It is guaranteed that the answer exists. | C | cda949a8fb1f158f3c06109a2d33f084 | 76faed7976b443628d40b0d95717a868 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1555425300 | ["3 6 5 4", "40 40 40 60", "201 101 101 200"] | null | PASSED | 800 | standard input | 1 second | The only line of the input contains four positive integers $$$x_1, x_2, x_3, x_4$$$ ($$$2 \le x_i \le 10^9$$$) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number $$$x_1, x_2, x_3, x_4$$$. | ["2 1 3", "20 20 20", "1 100 100"] | #include <stdio.h>
int main()
{
int i;
long long int array[4];
for(i=0;i<4;i++)
scanf("%lld",&array[i]);
long long int sum=0;
for(i=0;i<4;i++)
sum+=array[i];
for(i=0;i<4;i++)
{
if(sum/3==array[i])
{
break;
}
}
switch(i)
{
case 0:
printf("%lld %lld %lld",array[0]-array[1],array[0]-array[2],array[0]-array[3]);
break;
case 1:
printf("%lld %lld %lld",array[1]-array[0],array[1]-array[2],array[1]-array[3]);
break;
case 2:
printf("%lld %lld %lld",array[2]-array[1],array[2]-array[0],array[2]-array[3]);
break;
case 3:
printf("%lld %lld %lld",array[3]-array[0],array[3]-array[1],array[3]-array[2]);
break;
}
return 0;
} | |
Polycarp has guessed three positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$.You have to guess three numbers $$$a$$$, $$$b$$$ and $$$c$$$ using given numbers. Print three guessed integers in any order.Pay attention that some given numbers $$$a$$$, $$$b$$$ and $$$c$$$ can be equal (it is also possible that $$$a=b=c$$$). | Print such positive integers $$$a$$$, $$$b$$$ and $$$c$$$ that four numbers written on a board are values $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$ written in some order. Print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. If there are several answers, you can print any. It is guaranteed that the answer exists. | C | cda949a8fb1f158f3c06109a2d33f084 | 63481ef08abb97ab8418c945094a8ca7 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1555425300 | ["3 6 5 4", "40 40 40 60", "201 101 101 200"] | null | PASSED | 800 | standard input | 1 second | The only line of the input contains four positive integers $$$x_1, x_2, x_3, x_4$$$ ($$$2 \le x_i \le 10^9$$$) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number $$$x_1, x_2, x_3, x_4$$$. | ["2 1 3", "20 20 20", "1 100 100"] | #include <stdio.h>
int main()
{
int i;
long long int array[4];
for(i=0;i<4;i++)
scanf("%lld",&array[i]);
long long int sum=0,temporary;
for(i=0;i<4;i++)
sum+=array[i];
for(i=0;i<4;i++)
{
if(sum/3==array[i])
{
break;
}
}
temporary=array[i];
array[i]=array[0];
array[0]=temporary;
printf("%lld %lld %lld",array[0]-array[1],array[0]-array[2],array[0]-array[3]);
return 0;
} | |
Polycarp has guessed three positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$.You have to guess three numbers $$$a$$$, $$$b$$$ and $$$c$$$ using given numbers. Print three guessed integers in any order.Pay attention that some given numbers $$$a$$$, $$$b$$$ and $$$c$$$ can be equal (it is also possible that $$$a=b=c$$$). | Print such positive integers $$$a$$$, $$$b$$$ and $$$c$$$ that four numbers written on a board are values $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$ written in some order. Print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. If there are several answers, you can print any. It is guaranteed that the answer exists. | C | cda949a8fb1f158f3c06109a2d33f084 | b042cca12e9ad6240e8cf7148cbb2cb2 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1555425300 | ["3 6 5 4", "40 40 40 60", "201 101 101 200"] | null | PASSED | 800 | standard input | 1 second | The only line of the input contains four positive integers $$$x_1, x_2, x_3, x_4$$$ ($$$2 \le x_i \le 10^9$$$) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number $$$x_1, x_2, x_3, x_4$$$. | ["2 1 3", "20 20 20", "1 100 100"] |
#include<stdio.h>
int main()
{
int a[4],temp;
for(int i=0;i<4;i++)
{
scanf("%d",&a[i]);
}
for(int i=0;i<4;i++)
{
for(int j=0;j<3;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
int a1=a[3]-a[0];
int b=a[3]-a[1];
int c=a[3]-a[2];
printf("%d %d %d",a1,b,c);
} | |
Polycarp has guessed three positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$.You have to guess three numbers $$$a$$$, $$$b$$$ and $$$c$$$ using given numbers. Print three guessed integers in any order.Pay attention that some given numbers $$$a$$$, $$$b$$$ and $$$c$$$ can be equal (it is also possible that $$$a=b=c$$$). | Print such positive integers $$$a$$$, $$$b$$$ and $$$c$$$ that four numbers written on a board are values $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$ written in some order. Print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. If there are several answers, you can print any. It is guaranteed that the answer exists. | C | cda949a8fb1f158f3c06109a2d33f084 | 4436421b218dbe7afe5a85a354509775 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1555425300 | ["3 6 5 4", "40 40 40 60", "201 101 101 200"] | null | PASSED | 800 | standard input | 1 second | The only line of the input contains four positive integers $$$x_1, x_2, x_3, x_4$$$ ($$$2 \le x_i \le 10^9$$$) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number $$$x_1, x_2, x_3, x_4$$$. | ["2 1 3", "20 20 20", "1 100 100"] |
#include <stdio.h>
int main(void)
{
int b[3],abc;
//scanf("%d %d %d %d",&ab,&ac,&bc,&abc);
int a[4],max=0,m;
for(int i=0;i<4;i++)
{
scanf("%d",&a[i]);
if(max<a[i])
{max=a[i];
m=i;}
}
int j=0;
for(int i=0;i<4;i++)
{
if(i==m)
{
abc=a[i];
}
else
{b[j]=a[i];
j++;}
}
printf("%d %d %d\n",abc-b[2],abc-b[1],abc-b[0]);
} | |
Polycarp has guessed three positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$.You have to guess three numbers $$$a$$$, $$$b$$$ and $$$c$$$ using given numbers. Print three guessed integers in any order.Pay attention that some given numbers $$$a$$$, $$$b$$$ and $$$c$$$ can be equal (it is also possible that $$$a=b=c$$$). | Print such positive integers $$$a$$$, $$$b$$$ and $$$c$$$ that four numbers written on a board are values $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$ written in some order. Print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. If there are several answers, you can print any. It is guaranteed that the answer exists. | C | cda949a8fb1f158f3c06109a2d33f084 | 3915280996ef09f70709faaa5b21e5fe | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1555425300 | ["3 6 5 4", "40 40 40 60", "201 101 101 200"] | null | PASSED | 800 | standard input | 1 second | The only line of the input contains four positive integers $$$x_1, x_2, x_3, x_4$$$ ($$$2 \le x_i \le 10^9$$$) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number $$$x_1, x_2, x_3, x_4$$$. | ["2 1 3", "20 20 20", "1 100 100"] | #include<stdio.h>
int main()
{
long sum[4];
int max=0,i;
for (i=0;i<4;i++)
{
scanf("%ld",&sum[i]);
if (sum[i]>max){
max=sum[i];
}
}
int j;
for(j=0;j<4;j++)
{
if ((max-sum[j])!=0) {printf("%ld ",max-sum[j]);}
}
return 0;
} | |
Polycarp has guessed three positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$.You have to guess three numbers $$$a$$$, $$$b$$$ and $$$c$$$ using given numbers. Print three guessed integers in any order.Pay attention that some given numbers $$$a$$$, $$$b$$$ and $$$c$$$ can be equal (it is also possible that $$$a=b=c$$$). | Print such positive integers $$$a$$$, $$$b$$$ and $$$c$$$ that four numbers written on a board are values $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$ written in some order. Print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. If there are several answers, you can print any. It is guaranteed that the answer exists. | C | cda949a8fb1f158f3c06109a2d33f084 | c5338e9693a17f95f4436b6e0e3aaae9 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1555425300 | ["3 6 5 4", "40 40 40 60", "201 101 101 200"] | null | PASSED | 800 | standard input | 1 second | The only line of the input contains four positive integers $$$x_1, x_2, x_3, x_4$$$ ($$$2 \le x_i \le 10^9$$$) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number $$$x_1, x_2, x_3, x_4$$$. | ["2 1 3", "20 20 20", "1 100 100"] | #include<stdio.h>
#include<stdlib.h>
void main()
{
unsigned long int a,b,c,d,x,y,z,sum,tmp,tmp2,tmp3,p;
scanf("%d %d %d %d", &a,&b,&c,&d);
if(a>b)
{
if(a>c)
{
if(a>d)
{
sum=a;
}
else
{
sum=d;
}
}
}
else if(b>c)
{
if(b>d)
{
sum=b;
}
else
{
sum=d;
}
}
else if(c>d)
{
sum=c;
}
else
{
sum=d;
}
if(sum==a)
{
tmp=-(a-b-c);
tmp2=-(a-c-d);
tmp3=-(a-d-b);
printf("%d %d %d",tmp,tmp2,tmp3);
exit(0);
}
if(sum==b)
{
tmp=-(b-a-c);
tmp2=-(b-c-d);
tmp3=-(b-d-a);
printf("%d %d %d",tmp,tmp2,tmp3);
exit(0);
}
if(sum==c)
{
tmp=-(c-b-a);
tmp2=-(c-a-d);
tmp3=-(c-d-b);
printf("%d %d %d",tmp,tmp2,tmp3);
exit(0);
}
if(sum==d)
{
tmp=-(d-b-c);
tmp2=-(d-c-a);
tmp3=-(d-a-b);
printf("%d %d %d",tmp,tmp2,tmp3);
exit(0);
}
}
| |
Polycarp has guessed three positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$.You have to guess three numbers $$$a$$$, $$$b$$$ and $$$c$$$ using given numbers. Print three guessed integers in any order.Pay attention that some given numbers $$$a$$$, $$$b$$$ and $$$c$$$ can be equal (it is also possible that $$$a=b=c$$$). | Print such positive integers $$$a$$$, $$$b$$$ and $$$c$$$ that four numbers written on a board are values $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$ written in some order. Print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. If there are several answers, you can print any. It is guaranteed that the answer exists. | C | cda949a8fb1f158f3c06109a2d33f084 | ed4d1126deb77ef157cbbbe38e8af24a | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1555425300 | ["3 6 5 4", "40 40 40 60", "201 101 101 200"] | null | PASSED | 800 | standard input | 1 second | The only line of the input contains four positive integers $$$x_1, x_2, x_3, x_4$$$ ($$$2 \le x_i \le 10^9$$$) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number $$$x_1, x_2, x_3, x_4$$$. | ["2 1 3", "20 20 20", "1 100 100"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
int main(){
int a, b, c, i;
int arr[4];
scanf("%d %d %d %d", &arr[0], &arr[1], &arr[2], &arr[3]);
int max = 0;
for(i = 1; i < 4; i++){
if(arr[i] > arr[max]){
max = i;
}
}
switch(max){
case 0:
a = arr[0] - arr[1];
b = arr[0] - arr[2];
c = arr[0] - arr[3];
break;
case 1:
a = arr[1] - arr[0];
b = arr[1] - arr[2];
c = arr[1] - arr[3];
break;
case 2:
a = arr[2] - arr[0];
b = arr[2] - arr[1];
c = arr[2] - arr[3];
break;
case 3:
a = arr[3] - arr[0];
b = arr[3] - arr[1];
c = arr[3] - arr[2];
break;
}
printf("%d %d %d", a, b, c);
} | |
Polycarp has guessed three positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order — their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$.You have to guess three numbers $$$a$$$, $$$b$$$ and $$$c$$$ using given numbers. Print three guessed integers in any order.Pay attention that some given numbers $$$a$$$, $$$b$$$ and $$$c$$$ can be equal (it is also possible that $$$a=b=c$$$). | Print such positive integers $$$a$$$, $$$b$$$ and $$$c$$$ that four numbers written on a board are values $$$a+b$$$, $$$a+c$$$, $$$b+c$$$ and $$$a+b+c$$$ written in some order. Print $$$a$$$, $$$b$$$ and $$$c$$$ in any order. If there are several answers, you can print any. It is guaranteed that the answer exists. | C | cda949a8fb1f158f3c06109a2d33f084 | 6a0d172995e0600a6024ddb28c56258d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"math"
] | 1555425300 | ["3 6 5 4", "40 40 40 60", "201 101 101 200"] | null | PASSED | 800 | standard input | 1 second | The only line of the input contains four positive integers $$$x_1, x_2, x_3, x_4$$$ ($$$2 \le x_i \le 10^9$$$) — numbers written on a board in random order. It is guaranteed that the answer exists for the given number $$$x_1, x_2, x_3, x_4$$$. | ["2 1 3", "20 20 20", "1 100 100"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int a,b,c,m,n,o,p,q,r,s,t;
scanf("%d %d %d %d",&m, &n, &o, &p);
if (m>n && m>o && m>p)
{
q=m;
r=n;
s=o;
t=p;
}else if (n>m && n>o && n>p)
{q=n;
r=m;
s=o;
t=p;
}else if (o>n && o>m && o>p){
q=o;
r=m;
s=n;
t=p;
}else if(p>n && p>o && p>n){
q=p;
r=m;
s=n;
t=o;
}
a=q-r;
b=q-s;
c=q-t;
printf("%d %d %d",a,b,c);
} | |
On a chessboard with a width of $$$10^9$$$ and a height of $$$10^9$$$, the rows are numbered from bottom to top from $$$1$$$ to $$$10^9$$$, and the columns are numbered from left to right from $$$1$$$ to $$$10^9$$$. Therefore, for each cell of the chessboard you can assign the coordinates $$$(x,y)$$$, where $$$x$$$ is the column number and $$$y$$$ is the row number.Every day there are fights between black and white pieces on this board. Today, the black ones won, but at what price? Only the rook survived, and it was driven into the lower left corner — a cell with coordinates $$$(1,1)$$$. But it is still happy, because the victory has been won and it's time to celebrate it! In order to do this, the rook needs to go home, namely — on the upper side of the field (that is, in any cell that is in the row with number $$$10^9$$$).Everything would have been fine, but the treacherous white figures put spells on some places of the field before the end of the game. There are two types of spells: Vertical. Each of these is defined by one number $$$x$$$. Such spells create an infinite blocking line between the columns $$$x$$$ and $$$x+1$$$. Horizontal. Each of these is defined by three numbers $$$x_1$$$, $$$x_2$$$, $$$y$$$. Such spells create a blocking segment that passes through the top side of the cells, which are in the row $$$y$$$ and in columns from $$$x_1$$$ to $$$x_2$$$ inclusive. The peculiarity of these spells is that it is impossible for a certain pair of such spells to have a common point. Note that horizontal spells can have common points with vertical spells. An example of a chessboard. Let's recall that the rook is a chess piece that in one move can move to any point that is in the same row or column with its initial position. In our task, the rook can move from the cell $$$(r_0,c_0)$$$ into the cell $$$(r_1,c_1)$$$ only under the condition that $$$r_1 = r_0$$$ or $$$c_1 = c_0$$$ and there is no blocking lines or blocking segments between these cells (For better understanding, look at the samples).Fortunately, the rook can remove spells, but for this it has to put tremendous efforts, therefore, it wants to remove the minimum possible number of spells in such way, that after this it can return home. Find this number! | In a single line print one integer — the minimum number of spells the rook needs to remove so it can get from the cell $$$(1,1)$$$ to at least one cell in the row with the number $$$10^9$$$ | C | 00eb4442eb86ccc7352b63dc23354abf | aad851e9c4f87bc9d2392aea45f19931 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"two pointers"
] | 1541355000 | ["2 3\n6\n8\n1 5 6\n1 9 4\n2 4 2", "1 3\n4\n1 5 3\n1 9 4\n4 6 6", "0 2\n1 1000000000 4\n1 1000000000 2", "0 0", "2 3\n4\n6\n1 4 3\n1 5 2\n1 6 5"] | NoteIn the first sample, in order for the rook return home, it is enough to remove the second horizontal spell. Illustration for the first sample. On the left it shows how the field looked at the beginning. On the right it shows how the field looked after the deletion of the second horizontal spell. It also shows the path, on which the rook would be going home. In the second sample, in order for the rook to return home, it is enough to remove the only vertical spell. If we tried to remove just one of the horizontal spells, it would not allow the rook to get home, because it would be blocked from above by one of the remaining horizontal spells (either first one or second one), and to the right it would be blocked by a vertical spell. Illustration for the second sample. On the left it shows how the field looked at the beginning. On the right it shows how it looked after the deletion of the vertical spell. It also shows the path, on which the rook would be going home. In the third sample, we have two horizontal spells that go through the whole field. These spells can not be bypassed, so we need to remove both of them. Illustration for the third sample. On the left it shows how the field looked at the beginning. On the right it shows how the field looked after the deletion of the horizontal spells. It also shows the path, on which the rook would be going home. In the fourth sample, we have no spells, which means that we do not need to remove anything.In the fifth example, we can remove the first vertical and third horizontal spells. Illustration for the fifth sample. On the left it shows how the field looked at the beginning. On the right it shows how it looked after the deletions. It also shows the path, on which the rook would be going home. | PASSED | 1,700 | standard input | 1 second | The first line contains two integers $$$n$$$ and $$$m$$$ ($$$0 \le n,m \le 10^5$$$) — the number of vertical and horizontal spells. Each of the following $$$n$$$ lines contains one integer $$$x$$$ ($$$1 \le x < 10^9$$$) — the description of the vertical spell. It will create a blocking line between the columns of $$$x$$$ and $$$x+1$$$. Each of the following $$$m$$$ lines contains three integers $$$x_1$$$, $$$x_2$$$ and $$$y$$$ ($$$1 \le x_{1} \le x_{2} \le 10^9$$$, $$$1 \le y < 10^9$$$) — the numbers that describe the horizontal spell. It will create a blocking segment that passes through the top sides of the cells that are in the row with the number $$$y$$$, in columns from $$$x_1$$$ to $$$x_2$$$ inclusive. It is guaranteed that all spells are different, as well as the fact that for each pair of horizontal spells it is true that the segments that describe them do not have common points. | ["1", "1", "2", "0", "2"] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define N_LIMIT 100001 // 1e5+1
#define INF 1000000000 // 1e9
typedef long long ll;
int x[N_LIMIT];
int x1[N_LIMIT], x2[N_LIMIT], y[N_LIMIT];
int removeCount[N_LIMIT];
int cmp(const void *lhs, const void *rhs)
{
return ((int*)lhs)[0] - ((int *)rhs)[0];
}
int binarySearch(int r, int lower, int upper)
{
int mid;
while (lower < upper)
{
mid = (lower + upper) / 2;
if (x[mid] <= r)
{
lower = mid+1;
}
else
{
upper = mid;
}
}
return lower;
}
int main(int argc, char *argv)
{
int n, m;
int i, j;
int min, runningCount;
scanf("%d %d", &n, &m);
for (i=0; i<n; i++)
{
scanf("%d", &x[i]);
removeCount[i] = 0;
}
removeCount[n] = 0;
qsort(x, n, sizeof(int), cmp);
for (i=0; i<m; i++)
{
scanf("%d %d %d", &x1[i], &x2[i], &y[i]);
if (x1[i] == 1)
{
if (x2[i] < x[0])
{
continue;
}
else
{
removeCount[0] ++;
if (x2[i] != INF)
{
//printf("%d %d\n", i, binarySearch(x2[i], 0, n));
removeCount[binarySearch(x2[i], 0, n)] --;
}
}
}
}
min = n+m;
runningCount = 0;
for (i=0; i<=n; i++)
{
runningCount += removeCount[i];
min = runningCount < min ? runningCount : min;
runningCount ++;
}
printf("%d\n", min);
return 0;
}
| |
Petya has noticed that when he types using a keyboard, he often presses extra buttons and adds extra letters to the words. Of course, the spell-checking system underlines the words for him and he has to click every word and choose the right variant. Petya got fed up with correcting his mistakes himself, that’s why he decided to invent the function that will correct the words itself. Petya started from analyzing the case that happens to him most of the time, when all one needs is to delete one letter for the word to match a word from the dictionary. Thus, Petya faces one mini-task: he has a printed word and a word from the dictionary, and he should delete one letter from the first word to get the second one. And now the very non-trivial question that Petya faces is: which letter should he delete? | In the first line output the number of positions of the symbols in the first string, after the deleting of which the first string becomes identical to the second one. In the second line output space-separated positions of these symbols in increasing order. The positions are numbered starting from 1. If it is impossible to make the first string identical to the second string by deleting one symbol, output one number 0. | C | 0df064fd0288c2ac4832efa227107a0e | 37ebf371c14894708c6ce2c5750459e3 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"strings"
] | 1287904200 | ["abdrakadabra\nabrakadabra", "aa\na", "competition\ncodeforces"] | null | PASSED | 1,500 | standard input | 2 seconds | The input data contains two strings, consisting of lower-case Latin letters. The length of each string is from 1 to 106 symbols inclusive, the first string contains exactly 1 symbol more than the second one. | ["1\n3", "2\n1 2", "0"] | #include <stdio.h>
#include <string.h>
int main()
{
char s1[1000001], s2[1000001];
int n, p = 0, q, i;
scanf("%s %s", s1, s2);
n = strlen(s2);
for (i = 0; i < n; i++) {
if (s1[i] != s1[p]) p = i;
if (s1[i] != s2[i]) break;
}
q = i;
if (i == n) {
if (s1[p] != s1[i]) p = i;
}
for (; i < n; i++) {
if (s1[i + 1] != s2[i]) break;
}
if (i < n) {
puts("0");
} else {
printf("%d\n", q - p + 1);
for (i = p; i <= q; i++) {
if (i > p) putchar(' ');
printf("%d", i + 1);
}
puts("");
}
return 0;
}
| |
Petya has noticed that when he types using a keyboard, he often presses extra buttons and adds extra letters to the words. Of course, the spell-checking system underlines the words for him and he has to click every word and choose the right variant. Petya got fed up with correcting his mistakes himself, that’s why he decided to invent the function that will correct the words itself. Petya started from analyzing the case that happens to him most of the time, when all one needs is to delete one letter for the word to match a word from the dictionary. Thus, Petya faces one mini-task: he has a printed word and a word from the dictionary, and he should delete one letter from the first word to get the second one. And now the very non-trivial question that Petya faces is: which letter should he delete? | In the first line output the number of positions of the symbols in the first string, after the deleting of which the first string becomes identical to the second one. In the second line output space-separated positions of these symbols in increasing order. The positions are numbered starting from 1. If it is impossible to make the first string identical to the second string by deleting one symbol, output one number 0. | C | 0df064fd0288c2ac4832efa227107a0e | d22c68e033b1eb9a1724e1fe1aea95fa | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"strings"
] | 1287904200 | ["abdrakadabra\nabrakadabra", "aa\na", "competition\ncodeforces"] | null | PASSED | 1,500 | standard input | 2 seconds | The input data contains two strings, consisting of lower-case Latin letters. The length of each string is from 1 to 106 symbols inclusive, the first string contains exactly 1 symbol more than the second one. | ["1\n3", "2\n1 2", "0"] | //Spelling Check - Codeforces
#include <stdio.h>
#include <string.h>
//#include <string>
char s1[1000001], s2[1000001];
int n, counta, cantidad, resp2[1000001];
int main(){
scanf("%s %s",s1+1,s2+1);
n=strlen(s1+1);
for(int i=n;i>=1;--i)
if (i==1||s1[i]!=s2[i - 1]){
counta = n - i;
break;
}
for(int i=1;i<=n;++i){
if(counta>=n-i){
resp2[++cantidad] = i;
}
if(i==n||s1[i]!=s2[i]){
break;
}
}
printf("%d\n", cantidad);
if(cantidad!=0){
for (int i=1;i<=cantidad;++i){
printf("%d ", resp2[i]);
}
}
return 0;
}
| |
Petya has noticed that when he types using a keyboard, he often presses extra buttons and adds extra letters to the words. Of course, the spell-checking system underlines the words for him and he has to click every word and choose the right variant. Petya got fed up with correcting his mistakes himself, that’s why he decided to invent the function that will correct the words itself. Petya started from analyzing the case that happens to him most of the time, when all one needs is to delete one letter for the word to match a word from the dictionary. Thus, Petya faces one mini-task: he has a printed word and a word from the dictionary, and he should delete one letter from the first word to get the second one. And now the very non-trivial question that Petya faces is: which letter should he delete? | In the first line output the number of positions of the symbols in the first string, after the deleting of which the first string becomes identical to the second one. In the second line output space-separated positions of these symbols in increasing order. The positions are numbered starting from 1. If it is impossible to make the first string identical to the second string by deleting one symbol, output one number 0. | C | 0df064fd0288c2ac4832efa227107a0e | 99c7cb39b408d312ca44dabc8db08831 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"hashing",
"strings"
] | 1287904200 | ["abdrakadabra\nabrakadabra", "aa\na", "competition\ncodeforces"] | null | PASSED | 1,500 | standard input | 2 seconds | The input data contains two strings, consisting of lower-case Latin letters. The length of each string is from 1 to 106 symbols inclusive, the first string contains exactly 1 symbol more than the second one. | ["1\n3", "2\n1 2", "0"] | #include<stdio.h>
#include<string.h>
int main()
{
int i, j, n, count = 0, c[1000010] = { 0 };
char a[1000010], b[1000010];
scanf(" %s", a);
scanf(" %s", b);
n = strlen(a);
for(i = 0; i < n-1; i++)
if(a[i]!=b[i])
break;
if(i!=n-1)
if(strcmp(a + i + 1, b + i) != 0)
{
printf("0");
return 0;
}
for(j = i; j>=0; j--)
{
if(a[j]!=a[i])
break;
c[j] = 1;
count++;
}
for(j = i + 1; j<n; j++)
{
if(a[j]!=a[i])
break;
c[j] = 1;
count++;
}
printf("%d\n", count);
for(i = 0; i<n; i++)
{
if(c[i] == 1)
printf("%d ", i+1);
}
return 0;
} | |
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, such as madam or racecar.Your task is to help Kolya and determine the minimum number of palindromes of equal lengths to cut s into, if it is allowed to rearrange letters in s before cuttings. | Print to the first line an integer k — minimum number of palindromes into which you can cut a given string. Print to the second line k strings — the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length. | C | d062ba289fd9c373a31ca5e099f9306c | 2117ba87cc26060ef9b8bd20e6de9a0a | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1508573100 | ["6\naabaac", "8\n0rTrT022", "2\naA"] | null | PASSED | 1,800 | standard input | 3 seconds | The first line contains an integer n (1 ≤ n ≤ 4·105) — the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits. | ["2\naba aca", "1\n02TrrT20", "2\na A"] | #include <stdio.h>
#include <string.h>
#include <ctype.h>
#define uLL unsigned long long
#define LL long long
void print(long *a,long size) {long i;for (i=1;i<size;i++) {printf("%ld ",a[i]);}printf("%ld\n",a[i]);}
char encode[10000];
long pan[2000000],temp[2000000],num[2000000],count[2000000];
long n,ans;
void ini()
{
long i;
for (i=1;i<=10;i++)
{
encode[i]='0'+i-1;
}
for (i=11;i<=36;i++)
{
encode[i]='a'+i-11;
}
for (i=37;i<=62;i++)
{
encode[i]='A'+i-37;
}
}
int legal(char ch)
{
long ans;
ans=0;
if (isalpha(ch)!=0)
{
if (islower(ch)!=0)
{
ans=ch-'a'+11;
}
else
{
ans=ch-'A'+37;
}
}
else
{
if (isdigit(ch)!=0)
{
ans=ch-'0'+1;
}
}
return ans;
}
char str[2000000];
int main()
{
// freopen("in.in","r",stdin);
long i,j,k,a,b,c,l,odd;
ini();
/* for (i=1;i<=62;i++)
{
printf("%c %ld\n",encode[i],legal(encode[i]));
}*/
scanf("%ld",&n);
while (1)
{
gets(str);
if (legal(*str)!=0) {break;}
}
for (i=1,j=0;i<=n;i++,j++)
{
num[i]=legal(str[j]);
if (num[i]<=0) {while (1){a+=1;}}
}
memset(count,0,sizeof(*count)*(100));
for (i=1;i<=n;i++)
{
count[num[i]]+=1;
}
// print(count,62);
odd=0;
for (i=1;i<=100;i++)
{
odd+=count[i]&1;
}
for (i=n;i>1;i--)
{
if (n%i==0)
{
k=n/i;
if (i&1)
{
if (odd<=k) {goto SUCC;} else {goto FAIL;}
}
else
{
if (odd==0) {goto SUCC;} else {goto FAIL;}
}
FAIL:
continue;
}
}
SUCC:
ans=i;k=n/i;
memset(pan,0,sizeof(*pan)*(k+1));
if (ans&1)
{
for (i=1,j=0;i<=100;i++)
{
if (count[i]&1)
{
count[i]-=1;
pan[++j]=i;
}
}
for (j+=1,i=1;j+1<=k;j+=2)
{
while (count[i]<=0) {i+=1;}
pan[j]=i;pan[j+1]=i;
count[i]-=2;
}
}
printf("%ld\n",k);
// printf("%ld %ld\n",ans,k);return 0;
l=1;
for (i=1;i<=k;i++)
{
for (j=1;j<=(ans>>1);j++)
{
while (count[l]<=0) {l+=1;}
temp[j]=l;
count[l]-=2;
}
// print(temp,ans);
for (j=1;j<=(ans>>1);j++)
{
printf("%c",encode[temp[j]]);
}
if ((pan[i]>0)) {printf("%c",encode[pan[i]]);}
for (j=(ans>>1);j>=1;j--)
{
printf("%c",encode[temp[j]]);
}
if (i<k) {printf(" ");}
}
printf("\n");
return 0;
}
| |
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, such as madam or racecar.Your task is to help Kolya and determine the minimum number of palindromes of equal lengths to cut s into, if it is allowed to rearrange letters in s before cuttings. | Print to the first line an integer k — minimum number of palindromes into which you can cut a given string. Print to the second line k strings — the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length. | C | d062ba289fd9c373a31ca5e099f9306c | 2d69c86b2fcb1d45bd5a943bd5e672d9 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1508573100 | ["6\naabaac", "8\n0rTrT022", "2\naA"] | null | PASSED | 1,800 | standard input | 3 seconds | The first line contains an integer n (1 ≤ n ≤ 4·105) — the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits. | ["2\naba aca", "1\n02TrrT20", "2\na A"] | #include <stdio.h>
#include <string.h>
#include <ctype.h>
#define uLL unsigned long long
#define LL long long
void print(long *a,long size) {long i;for (i=1;i<size;i++) {printf("%ld ",a[i]);}printf("%ld\n",a[i]);}
char encode[10000];
long pan[2000000],temp[2000000],num[2000000],count[2000000];
long n,ans;
void ini()
{
long i;
for (i=1;i<=10;i++)
{
encode[i]='0'+i-1;
}
for (i=11;i<=36;i++)
{
encode[i]='a'+i-11;
}
for (i=37;i<=62;i++)
{
encode[i]='A'+i-37;
}
}
int legal(char ch)
{
long ans;
ans=0;
if (isalpha(ch)!=0)
{
if (islower(ch)!=0)
{
ans=ch-'a'+11;
}
else
{
ans=ch-'A'+37;
}
}
else
{
if (isdigit(ch)!=0)
{
ans=ch-'0'+1;
}
}
return ans;
}
char str[2000000];
int main()
{
// freopen("in.in","r",stdin);
long i,j,k,a,b,c,l,odd;
ini();
/* for (i=1;i<=62;i++)
{
printf("%c %ld\n",encode[i],legal(encode[i]));
}*/
scanf("%ld",&n);
while (1)
{
gets(str);
if (legal(*str)!=0) {break;}
}
for (i=1,j=0;i<=n;i++,j++)
{
num[i]=legal(str[j]);
if (num[i]<=0) {while (1){a+=1;}}
}
memset(count,0,sizeof(*count)*(100));
for (i=1;i<=n;i++)
{
count[num[i]]+=1;
}
// print(count,62);
odd=0;
for (i=1;i<=62;i++)
{
odd+=count[i]&1;
}
for (i=n;i>1;i--)
{
if (n%i==0)
{
k=n/i;
if (i&1)
{
if (odd<=k) {goto SUCC;} else {goto FAIL;}
}
else
{
if (odd==0) {goto SUCC;} else {goto FAIL;}
}
FAIL:
continue;
}
}
SUCC:
ans=i;k=n/i;
memset(pan,0,sizeof(*pan)*(k+1));
if (ans&1)
{
for (i=1,j=0;i<=62;i++)
{
if (count[i]&1)
{
count[i]-=1;
pan[++j]=i;
}
}
for (j+=1,i=1;j+1<=k;j+=2)
{
while (count[i]<=0) {i+=1;}
pan[j]=i;pan[j+1]=i;
count[i]-=2;
}
}
printf("%ld\n",k);
// printf("%ld %ld\n",ans,k);return 0;
l=1;
for (i=1;i<=k;i++)
{
for (j=1;j<=(ans>>1);j++)
{
while (count[l]<=0) {l+=1;}
temp[j]=l;
count[l]-=2;
}
// print(temp,ans);
for (j=1;j<=(ans>>1);j++)
{
printf("%c",encode[temp[j]]);
}
if (pan[i]>0) {printf("%c",encode[pan[i]]);}
for (j=(ans>>1);j>=1;j--)
{
printf("%c",encode[temp[j]]);
}
if (i<k) {printf(" ");}
}
printf("\n");
return 0;
}
| |
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. A palindrome is a string which reads the same backward as forward, such as madam or racecar.Your task is to help Kolya and determine the minimum number of palindromes of equal lengths to cut s into, if it is allowed to rearrange letters in s before cuttings. | Print to the first line an integer k — minimum number of palindromes into which you can cut a given string. Print to the second line k strings — the palindromes themselves. Separate them by a space. You are allowed to print palindromes in arbitrary order. All of them should have the same length. | C | d062ba289fd9c373a31ca5e099f9306c | 3eadd85d0ace7cc08562fa8353630f74 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"brute force",
"strings"
] | 1508573100 | ["6\naabaac", "8\n0rTrT022", "2\naA"] | null | PASSED | 1,800 | standard input | 3 seconds | The first line contains an integer n (1 ≤ n ≤ 4·105) — the length of string s. The second line contains a string s of length n consisting of lowercase and uppercase Latin letters and digits. | ["2\naba aca", "1\n02TrrT20", "2\na A"] | #include <stdio.h>
#include <string.h>
#include <ctype.h>
#define uLL unsigned long long
#define LL long long
void print(long *a,long size) {long i;for (i=1;i<size;i++) {printf("%ld ",a[i]);}printf("%ld\n",a[i]);}
char encode[10000];
long pan[2000000],temp[2000000],num[2000000],count[2000000];
long n,ans;
void ini()
{
long i;
for (i=1;i<=10;i++)
{
encode[i]='0'+i-1;
}
for (i=11;i<=36;i++)
{
encode[i]='a'+i-11;
}
for (i=37;i<=62;i++)
{
encode[i]='A'+i-37;
}
}
int legal(char ch)
{
long ans;
ans=0;
if (isalpha(ch)!=0)
{
if (islower(ch)!=0)
{
ans=ch-'a'+11;
}
else
{
ans=ch-'A'+37;
}
}
else
{
if (isdigit(ch)!=0)
{
ans=ch-'0'+1;
}
}
return ans;
}
char str[2000000];
int main()
{
// freopen("in.in","r",stdin);
long i,j,k,a,b,c,l,odd;
ini();
/* for (i=1;i<=62;i++)
{
printf("%c %ld\n",encode[i],legal(encode[i]));
}*/
scanf("%ld",&n);
while (1)
{
gets(str);
if (legal(*str)!=0) {break;}
}
for (i=1,j=0;i<=n;i++,j++)
{
num[i]=legal(str[j]);
if (num[i]<=0) {while (1){a+=1;}}
}
memset(count,0,sizeof(*count)*(100));
for (i=1;i<=n;i++)
{
count[num[i]]+=1;
}
// print(count,62);
odd=0;
for (i=1;i<=100;i++)
{
odd+=count[i]&1;
}
for (i=n;i>1;i--)
{
if (n%i==0)
{
k=n/i;
if (i&1)
{
if (odd<=k) {goto SUCC;} else {goto FAIL;}
}
else
{
if (odd==0) {goto SUCC;} else {goto FAIL;}
}
FAIL:
continue;
}
}
SUCC:
ans=i;k=n/i;
memset(pan,0,sizeof(*pan)*(k+1));
if (ans&1)
{
for (i=1,j=0;i<=100;i++)
{
if (count[i]&1)
{
count[i]-=1;
pan[++j]=i;
}
}
for (j+=1,i=1;j+1<=k;j+=2)
{
while (count[i]<=0) {i+=1;}
pan[j]=i;pan[j+1]=i;
count[i]-=2;
}
}
printf("%ld\n",k);
// printf("%ld %ld\n",ans,k);return 0;
l=1;
for (i=1;i<=k;i++)
{
for (j=1;j<=(ans>>1);j++)
{
while (count[l]<=0) {l+=1;}
temp[j]=l;
count[l]-=2;
}
// print(temp,ans);
for (j=1;j<=(ans>>1);j++)
{
printf("%c",encode[temp[j]]);
}
if (pan[i]>0) {printf("%c",encode[pan[i]]);}
for (j=(ans>>1);j>=1;j--)
{
printf("%c",encode[temp[j]]);
}
if (i<k) {printf(" ");}
}
printf("\n");
return 0;
}
| |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | e2cadf9adf9af76a9224c728b430df55 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include<stdio.h>
int main()
{
long long int n,k ,t,l;
scanf("%lld",&t);
while(t--)
{
scanf("%lld%lld",&n,&k);
l=(k-1)/(n-1 );
printf("%lld\n",k+l);
}
}
| |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | 9262b1804696a960be3dd4a4bcf2c4e7 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include<stdio.h>
int main()
{
int t;
long long n,k,m,s,a;
scanf("%d",&t);
long long r[t];
for(int i=0;i<t;i++)
{
scanf("%lld %lld",&n,&k);
s=n-1;
m=k/s;
a=k%s;
if(a==0)
r[i]=(m*n)+a-1;
else
r[i]=(m*n)+a;
}
for(int i=0;i<t;i++)
{
printf("%lld\n",r[i]);
}
}
| |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | a3d6ea7f8add28ab6209e9276264e480 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include <stdio.h>
#include <math.h>
int solve(int n, int k){
return k + floor((k - 1) / (n - 1));
}
int main(){
int n, k, t;
scanf("%d", &t);
for(int i = 1; i <= t; i++){
scanf("%d %d", &n, &k);
printf("%d\n", solve(n, k));
}
} | |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | 32f76345849b7229aba0347a8fee5d54 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include <stdio.h>
int main(void) {
int t;
scanf("%d\n",&t);
while(t--){
long int n,k;
scanf("%ld %ld\n",&n,&k);
if(n==2){
printf("%ld\n",2*k-1);
}
else{
long int b=k/(n-1);
if(k%(n-1)==0){
b=k/(n-1);
b--;
}
/* long int a=n*b;
printf("%ld\n",a);
k=k-(n-1)*b;
for(long int i=1;i<=k;i++){
a++;
}*/
long int a=k+b;
printf("%ld\n",a);
}
}
return 0;
}
| |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | 3626e802c0a0aaa8bf8cca7f40e620be | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
int n, k, arr[1005];
int mod(int k, int n)
{
int a;
a = k / n;
return a;
}
void solve(int x)
{
int i;
i = k / n;
arr[x] = k;
do
{
arr[x] += mod(k, n);
k = mod(k, n) + k % n;
}while(k>=n);
printf("%d\n", arr[x]);
}
void nhap(int x)
{
scanf("%d%d", &n, &k);
}
int main()
{
int x, n1;
scanf("%d", &n1);
for (x = 0; x < n1; ++x)
{
nhap(x);
solve(x);
}
} | |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | 427c967ceb8b4ac8f8ea465a25b379d3 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,m;
scanf("%d %d",&n,&m);
if(m%(n-1)==0)
printf("%d\n",(m/(n-1))*n-1);
else
printf("%d\n",(m/(n-1))*n+m%(n-1));
}
} | |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | ea4a6fa08f3a40871bb28a51e6027f65 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include<stdio.h>
#define I64 long long int
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
I64 n,k,m,i;
scanf("%I64d%I64d",&n,&k);
if(n>k)
printf("%I64d\n",k);
else
printf("%I64d\n",k+(k-1)/(n-1));
}
}
| |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | ed0ddd3989affe68443b1fae6a9a040f | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include<stdio.h>
int main()
{
long long int n,i,a,b,x;
scanf("%lld",&n);
while(n--)
{
scanf("%lld %lld",&a,&b);
x=b*a/(a-1);
if(x%a==0)
{
x--;
}
printf("%lld\n",x);
}
return 0;
}
| |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | 650ff4bdee6b1a82ff7d1529ac8ede57 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int t,n,k,i,j,count;
scanf("%d",&t);
for(i=0;i<t;i++){
scanf("%d%d",&n,&k);
printf("%d\n",k+(k-1)/(n-1));
}
return 0;
} | |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | e3bc8053c893609089faf16831c20dc6 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include <stdio.h>
int main()
{
int T;
long long n,k,i, l,ans;
scanf("%d", &T);
while(T--)
{
scanf("%lld %lld", &n , &k);
ans = k + ((k-1) / (n-1));
printf("%lld\n", ans);
}
return 0;
}
| |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | efb5dd53164dbc39f67e641c8c9ce06c | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include <stdio.h>
main(){
int n=0;
scanf("%d",&n);
int i=1;
for(i=1;i<=n;i++){
int a=1;
scanf("%d",&a);
int b=0;
scanf("%d",&b);
int c=0;
int d=0;
int e=0;
c=b%(a-1);
d=b/(a-1);
if(c==0){
e=a*d-1;
}else{
e=a*d+c;
}
printf("%d\n",e);
}
} | |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | 1a70bf0cfb2e452029be8d1648758d48 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include <stdio.h>
int main()
{
int i,t,n,k,limit_of_multipliction,left_number,number_of_times,numbers,kth;
scanf("%d",&t);
for(i=0;i<t;i++){
scanf("%d %d",&n,&k);
if(n>k){
printf("%d\n",k);
continue;
}
number_of_times = k/(n-1);
limit_of_multipliction = number_of_times * n;
numbers = (n-1)*number_of_times;
left_number = k - numbers;
if(left_number == 0){
left_number = -1;
}
kth = limit_of_multipliction + left_number;
printf("%d\n",kth);
}
return 0;
}
| |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | 38c9be53b90320faaf890f6901707067 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include<stdio.h>
int main( )
{
int a,b,c,d,i,j,k,l,x,m,n;
scanf("%d",&x);
while(x--){
scanf("%d %d",&a,&b);
if(a>b){
printf("%d\n",b);
}
else{
c=b/(a-1);
c=c*a;
d=b%(a-1);
m=c+d;
if(m%a==0)
m-=1;
printf("%d\n",m);
}
}
return 0;
}
| |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | bdb5e5eab543715e602e7c2e528bc4c4 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include<stdio.h>
int w[100005],q[100005];
int main( )
{
int a,b,c,d,x,y,i,j,k;
scanf("%d",&a);
while(a--){
scanf("%d %d",&b,&c);
if(b==c){
printf("%d\n",c+1);
}
else if(b>c){
printf("%d\n",c);
}
else{
d=b-1;
if(c%d==0){
printf("%d\n",b*(c/d)-1);
}
else{
x=b*(c/d)+c%d;
printf("%d\n",x);
}
}
}
return 0;
}
| |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | 53890a754b25ed9d0047c5635ae8a319 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include<stdio.h>
int main()
{
int test=0;
scanf("%d",&test);
while(test--){
long int k,n;
scanf("%ld%ld",&n,&k);
long int p=(k-1)/(n-1);
printf("%ld\n",p+k);
}
return 0;
}
| |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | e8a154d9792b4d9d23f91435dce7cfa6 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include <stdio.h>
#include <math.h>
int main(){
int t;
scanf("%d", &t);
while(t--){
long n, k;
scanf("%ld %ld", &n, &k);
long p = floor((k - 1)/(n - 1));
printf("%ld\n", k + p);
}
return 0;
}
| |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | d473d6cb908b974e7917fba07e3bdd2c | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include<stdio.h>
int main()
{
int t,i;
scanf("%d",&t);
for(i=0;i<t;i++)
{
long long int n,k;
scanf("%lld %lld",&n,&k);
if(k%(n-1)==0)
{
long long int g=n*k/(n-1)-1;
printf("\n%lld",g);
}
else
{
long long int h=n*(k/(n-1))+k%(n-1);
printf("\n%lld",h);
}
}
}
| |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | e6f6665395955df11758ca4426ea2e34 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include "stdio.h"
typedef long long ll;
void solve();
int main(void)
{
int t;
scanf("%d ",&t);
while(t--)
solve();
return 0;
}
void solve()
{
ll n, k;
scanf("%llu%llu", &n, &k);
ll ans = (k - 1) / (n - 1) * n;
ans += k - (k - 1) / (n - 1) * (n - 1);
printf("%llu\n", ans);
}
| |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | 5d979be980aa8bfc1a8a4574b8ea3f3e | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | /// https://codeforces.com/problemset/problem/1352/C
#include "stdio.h"
typedef unsigned long long ll;
void solve();
int main(void)
{
int t;
scanf("%d ",&t);
while(t--)
solve();
return 0;
}
void solve()
{
ll n, k;
scanf("%llu%llu", &n, &k);
ll low = 0, high = 1e10;
ll ans;
while(low < high)
{
ll mid = low + (high - low) / 2;
/// mid / n means these many numbers are divisible by n
/// mid - mid / n means these numbers are not divisible by n
/// and we want to converge towards left!
if(mid - mid / n >= k)
{
/// bcoz that's the main question
/// to not include multiple of n
if(mid % n != 0)
ans = mid;
/// not mid - 1 because the condition includes equality
high = mid;
}
else
low = mid + 1;
}
printf("%llu\n", ans);
}
| |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | 3a93b93b945aea5025de7beaa86e47c5 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include "stdio.h"
int main(void)
{
int t;
scanf("%d",&t);
while(t--)
{
int n, k;
scanf("%d%d",&n,&k);
int temp = n - 1, num;
if(k % temp == 0)
num = k / temp * n - 1;
else
num = k / temp * n + k % temp;
printf("%d\n",num);
}
return 0;
}
| |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | bb07d210a356665deed7fac8cb63e3c7 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include<stdio.h>
int main()
{
int t,i;
scanf("%d",&t);
for(i=1;i<=t;i++){
int n,k,d;
scanf("%d%d",&n,&k);
d=k/(n-1);
if((k+d)%n==0){
if((k+d)-((k+d)/n)==k)printf("%d\n",(k+d-1));
else printf("%d\n",k+d+1);
}
else printf("%d\n",k+d);
}
}
| |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | dc4dd5178bf1d9f74b1cf6911d0b4b6f | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include<stdio.h>
int main()
{
int t,i;
scanf("%d",&t);
for(i=1;i<=t;i++){
int n,k,d;
scanf("%d%d",&n,&k);
d=k/(n-1);
if((k+d)%n==0)printf("%d\n",(k+d-1));
else printf("%d\n",k+d);
}
} | |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | d3de5d2000bcc4d7006288c9ffc40253 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include<stdio.h>
int main()
{
int a;
scanf("%d",&a);
for(int i=0;i<a;i++)
{
int n,k;
scanf("%d %d",&n,&k);
int a=n-1;
int b=k-1;
int p=b/a;
printf("%d\n",k+p);
}
return 0;
} | |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | 6707c6a5bb9f1ed9fc8c5de55fcce648 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | /* AUTHOR: AKASH JAIN
* EMAIL: akash19jain@gmail.com
* ID: akash19jain
* DATE: 10-05-2020 18:04:05
*/
// #include<algorithm>
// #include <bits/stdc++.h>
// using namespace std;
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
#define SC1(x) scanf("%lld",&x)
#define SC2(x,y) scanf("%lld%lld",&x,&y)
#define SC3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define SCS(x) scanf("\n%s", x)
#define SCA(a,n) for(long long i=0;i<n;i++) scanf("%lld",&a[i]);
#define PF1(x) printf("%lld\n",x)
#define PF2(x,y) printf("%lld %lld\n",x,y)
#define PF3(x,y,z) printf("%lld %lld %lld\n",x,y,z)
#define PFA(a,n) for(long long i=0;i<n;i++) printf("%lld ",a[i]); printf("\n");
#define PFN printf("\n")
#define PFS(x) printf("%s\n",x)
#define REP(i,n) for(long long i=0;i<(n);++i)
#define FOR(i,a,b) for(long long i=(a);i<=(b);++i)
#define FORD(i,a,b) for(long long i=(a);i>=(b);--i)
#define WHILE(n) while(n--)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define ITOC(c) ((char)(((ll)'0')+c))
#define MID(s,e) (s+(e-s)/2)
#define SZ(a) strlen(a)
#define PI 3.1415926535897932384626433832795
#define DEB(x) printf("The value of \"%s\" is: %d\n",#x,x)
#define CASES ll t;SC1(t);while(t--)
#define ABS(a) ((a>0)?a:-(a))
#define SWAP(a,b) ll z=a;a=b;b=z
#define SWAPC(a,b) char z=a;a=b;b=z
#define FLSH fflush(stdout)
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned long long ull;
const ll INF = 1 << 29;
const ll MOD = 1000000007;
const ll FMOD = 998244353;
const ll MAX = 10000000005;
const ll MIN = -10000000005;
#define FILEIO(name) \ freopen(name".in", "r", stdin); \ freopen(name".out", "w", stdout);
int cmp(const void * a, const void * b);
long long maxv(long long a, long long b);
long long minv(long long a, long long b);
long long gcd(long long u, long long v);
long long digits(long long n);
bool ispoweroftwo(long long n);
bool isvowel(char x);
ll chartoint(char ch);
ll CEIL(ll x, ll y);
ll FLOOR(ll x, ll y);
int main()
{
#ifndef ONLINE_JUDGE
freopen("F:\\COMPETITIVE-PROGRAMMING\\inp.txt", "r", stdin);
freopen("F:\\COMPETITIVE-PROGRAMMING\\out.txt", "w", stdout);
#endif
CASES
{
ll n, k;
SC2(n, k);
ll x = (k - 1) / (n - 1);
x = x + k;
PF1(x);
}
return 0;
}
//qsort(arr,n,sizeof(arr[0]),cmp);
int cmp (const void * a, const void * b)
{
if ( *(ll*)a - * (ll*)b < 0 ) return -1;
if ( *(ll*)a - * (ll*)b > 0 ) return 1;
return 0;
}
long long maxv(long long a, long long b)
{
if (a > b) return a;
return b;
}
long long minv(long long a, long long b)
{
if (a < b) return a;
return b;
}
long long gcd(long long u, long long v)
{
if (v == 0) return u;
return gcd(v, u % v);
}
long long digits(long long n) //to calculate no of digits in a number
{
return floor(log10(n)) + 1;
}
bool ispoweroftwo(long long x)
{
return x && (!(x & (x - 1)));
}
bool isvowel(char x)
{
return (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u' );
}
ll chartoint(char ch)
{
if (ch >= 'A' && ch <= 'Z') return (ch - 'A');
else if (ch >= '0' && ch <= '9') return (ch - '0');
else if (ch >= 'a' && ch <= 'z') return (ch - 'a');
else return 0;
}
ll CEIL(ll x, ll y)
{
if (x % y == 0) return (x / y);
else return (x / y + 1);
}
ll FLOOR(ll x, ll y)
{
if (x % y == 0) return (x / y);
else return (x / y - 1);
} | |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | 7c6c35dade6fe1a3862827806d74186a | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include<stdio.h>
int main()
{
long long int i,t,n,k,a,b,c;
scanf("%lld",&t);
for(i=1;i<t+1;i++){
scanf("%lld%lld",&n,&k);
a=k-1;
b=n-1;
c=a/b;
printf("%lld\n",k+c);
}
return 0;
}
| |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | b3422a0f081ff9c7707ae5513a5adc34 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include <stdio.h>
int main(void) {
int iter;
scanf("%d", &iter);
int n, k;
for (int i = 0; i < iter; i++) {
scanf("%d%d", &n, &k);
if (k <= (n - 1))
printf("%d\n", k);
else {
int p = 0;
if (k % (n - 1) == 0)
p = (k - 1) / (n - 1);
else
p = k / (n - 1);
printf("%d\n", p + k);
}
}
return 0;
} | |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | 360550e2177215810d53dda093a290e4 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | /* bai 11 1352 C */
#include<stdio.h>
#include<math.h>
int so(int n, int k){
return (k + floor(k - 1) / (n - 1));
}
int main(){
int T;
scanf("%d",&T);
while(T--){
int n,k;
scanf("%d%d",&n,&k);
printf("%d\n", so(n, k));
}
return 0;
} | |
You are given two positive integers $$$n$$$ and $$$k$$$. Print the $$$k$$$-th positive integer that is not divisible by $$$n$$$.For example, if $$$n=3$$$, and $$$k=7$$$, then all numbers that are not divisible by $$$3$$$ are: $$$1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$$$. The $$$7$$$-th number among them is $$$10$$$. | For each test case print the $$$k$$$-th positive integer that is not divisible by $$$n$$$. | C | 7d6f76e24fe9a352beea820ab56f03b6 | 579af3838013945e254fceb82ee4aa6d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1589034900 | ["6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$2 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$). | ["10\n15\n1999999999\n113\n1000000001\n1"] | #include<stdio.h>
int main()
{
int t;
int n,k;
scanf("%d",&t);
while(t--)
{
scanf("%d %d",&n,&k);
int a=k+(k/(n-1));
if(a%n==0)
{
printf("%d\n",a-1);
}
else
{
printf("%d\n",a);
}
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.