Submission #305588


Source Code Expand

//By Lin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<cctype>
#include<cmath>

#define eps 1e-9
#define sqr(x) ((x)*(x))
#define Rep(i,n) for(int i = 0; i<n; i++)
#define foreach(i,n) for( __typeof(n.begin()) i = n.begin(); i!=n.end(); i++)
#define X first
#define Y second
#define mp(x,y) make_pair(x,y)

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define N 100010

int digit[5];
bool f[5];

void deal(int k) {
	if (f[k]) {
		digit[k] ++;
		if (digit[k] == 10) {
			digit[k] = 9;
			f[k] = false;
			deal(k - 1);
		}
	}
	else {
		digit[k] --;
		if (digit[k] == -1) {
			digit[k] = 0;
			f[k] = true;
			deal(k - 1);
		}
	}
}
int		main(){
	int n;
	scanf("%d", &n);
	Rep(i, n) f[i] = true, digit[i] = 0;
	int ans = 1;
	Rep(i, n) ans *= 10;
	ans -= 1;
	printf("%d\n", ans);
	Rep(i, n) printf("%d", digit[i]);
	puts("");
	Rep(t, ans) {
		deal(n - 1);
		Rep(i, n) printf("%d", digit[i]);
		puts("");
	}
	return 0;
}

Submission Info

Submission Time
Task A - Lock
User asian-2014-778
Language C++ (G++ 4.6.4)
Score 100
Code Size 1103 Byte
Status AC
Exec Time 102 ms
Memory 800 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:50:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 2
AC × 5
Set Name Test Cases
Sample subtask0_sample_01.txt, subtask0_sample_02.txt
All subtask0_sample_01.txt, subtask0_sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt
Case Name Status Exec Time Memory
subtask0_sample_01.txt AC 21 ms 800 KB
subtask0_sample_02.txt AC 22 ms 736 KB
subtask1_01.txt AC 22 ms 796 KB
subtask1_02.txt AC 29 ms 672 KB
subtask1_03.txt AC 102 ms 796 KB