441 - Lotto
Posted: Wed Feb 21, 2007 8:48 am
Any trick in getting AC instead of PE on this problem 441 (Lotto)? I tried couple newline variations but still no luck.
Also exactly one space between integers sholud be followed.The test cases have to be separated from each other by exactly one blank line. Do not put a blank line after the last test case.
Code: Select all
7 1 2 3 4 5 6 7
7 1 2 3 4 5 6 7
0
Code: Select all
1 2 3 4 5 6\n
1 2 3 4 5 7\n
1 2 3 4 6 7\n
1 2 3 5 6 7\n
1 2 4 5 6 7\n
1 3 4 5 6 7\n
2 3 4 5 6 7\n\n
1 2 3 4 5 6\n
1 2 3 4 5 7\n
1 2 3 4 6 7\n
1 2 3 5 6 7\n
1 2 4 5 6 7\n
1 3 4 5 6 7\n
2 3 4 5 6 7\n
Code: Select all
Yes!!!
I got Accepted i was taking the input in wrong way
Again thank you very much linux
Code: Select all
#include<stdio.h>
int main()
{
int i,j,size,a[49],b[6],l,k,m,n;
while(1)
{
scanf("%d",&size);
if(size==0)
break;
for(i=0;i<size;i++)
{
scanf("%d",&a[i]);
if(i<6)
b[i]=a[i];
}
j=4;
l=5;
n=l+1;
m=size;
for(i=0;i<6;i++)
printf("%d ",b[i]);
while(j>=(-1))
{
if(l>j)
{
if(n<m)
{
b[l]=a[n];
printf("\n");
for(i=0;i<6;i++)
printf("%d ",b[i]);
n++;
}
else
{
n=l+1;
l--;
m--;
}
}
else
{
k=0;
for(i=0;i<7;i++)
{
if(i==j)
continue;
b[k]=a[i];
k++;
}
n=i;
if(j>=0)
{
printf("\n");
for(i=0;i<6;i++)
printf("%d ",b[i]);
}
j--;
m=size;
l=5;
}
}
printf("\n");
}
return 0;
}
2. This print a space after the last number,which should no be.The test cases have to be separated from each other by exactly one blank line. Do not put a blank line after the last test case.
Code: Select all
printf("%d ",b[i]);
Code: Select all
#include<stdio.h>
int main()
{
int i,j,size,a[49],b[6],l,k,m,n,c=0;
while(1)
{
if(c==1)
printf("\n");
scanf("%d",&size);
if(size==0)
break;
for(i=0;i<size;i++)
{
scanf("%d",&a[i]);
if(i<6)
b[i]=a[i];
}
c=1;
j=4;
l=5;
n=l+1;
m=size;
for(i=0;i<6;i++)
{
printf("%d",b[i]);
if(i<5)
printf(" ");
else
printf("\n");
}
while(j>=(-1))
{
if(l>j)
{
if(n<m)
{
b[l]=a[n];
for(i=0;i<6;i++)
{
printf("%d",b[i]);
if(i<5)
printf(" ");
else
printf("\n");
}
n++;
}
else
{
n=l+1;
l--;
m--;
}
}
else
{
k=0;
for(i=0;i<7;i++)
{
if(i==j)
continue;
b[k]=a[i];
k++;
}
n=i;
if(j>=0)
{
for(i=0;i<6;i++)
{
printf("%d",b[i]);
if(i<5)
printf(" ");
else
printf("\n");
}
}
j--;
m=size;
l=5;
}
}
}
return 0;
}
Code: Select all
#include <iostream>
using namespace std;
int s[13];
int Base2[13];
int main()
{
int k;
int i, j;
int ktimes2;
int cnt = 0;
int imsi;
int cntzero = 0;
int first = false;
while (cin >> k){
if (k == 0) break;
if (first) cout << endl;
first = true;
for (i = 0; i < k; i++){
cin >> s[i];
}
ktimes2 = 1;
for (i = 0; i < k; i++){
ktimes2 *= 2;
}
for (i = 0; i < ktimes2; i++){
imsi = i;
for (j = 0; j < 13; j++){
Base2[j] = 0;
}
cnt = 0;
while (imsi > 0){
Base2[cnt++] = imsi%2;
imsi /= 2;
}
cntzero = 0;
for (j = 0; j < k; j++){
if (Base2[j] == 1) cntzero++;
}
if (cntzero == 6){
for (j = 0; j < k; j++){
if (Base2[j] == 1){
if (j != k-1){
cout << s[j] << " ";
}
else cout << s[j];
}
}
cout << endl;
}
}
}
return 0;
}
Code: Select all
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<string,string> ss;
typedef vector<ss> vss;
#define all(a) a.begin(), a.end()
#define in(a,b) ( (b).find(a) != (b).end())
#define pb push_back
int main(int argc, char const *argv[]) {
int n;
vi v;
cin>>n;
while(n!=0){
while(cin.peek()!='\n'){
v.pb(n);
cin>>n;
}
v.pb(n);
sort(all(v));
auto it = unique(all(v));
v.resize(distance(v.begin(),it));
for (int i = 0; i < v.size(); i++) {
for (int j = i+1; j < v.size() && v[i]!=v[j]; j++) {
for (int k = j+1; k < v.size() && v[j]!=v[k]; k++) {
for (int l = k+1; l < v.size() && v[k]!=v[l]; l++) {
for (int z = l+1;z < v.size() && v[l]!=v[z];z++) {
for (int x = z+1; x < v.size() && v[z]!=v[x]; x++) {
cout<<v[i]<<" "<<v[j]<<" "<<v[k]<<" "<<v[l]<<" "<<v[z]<<" "<<v[x]<<endl;
}
}
}
}
}
}
cin>>n;
if(n!=0)
cout<<endl;
v.clear();
}
return 0;
}
Code: Select all
while (cin >> n) {
if (n == 0) break;
v.clear();
// Read set
// No need to sort as the input is already sorted.
// We also assume that there is no duplicate in the set
if (testcase > 1)
printf("\n");
// Process and output here..
}