Submission #815302
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define sd(mark) scanf("%d",&mark)
#define ss(mark) scanf("%s",&mark)
#define slld(mark) scanf("%lld",&mark)
#define clr(mark) memset(mark,0,sizeof(mark))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define sz(x) (int((x).size()))
#define PII pair<int,int>
#define PIL pair<int,long long>
#define PLL pair<long long,long long>
#define PIS pair<int,string>
#define MII map<int,int>
#define LL long long
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(a);i--)
#define FILEIO(name) \
freopen(name".in", "r", stdin); \
freopen(name".out", "w", stdout);
#define INF 2000000000 // 2 * 10^9
#define INFLL 1000000000000000000LL // 10^18
#define mod 1000000007
#define N 1012345
bool a[10];
void solve()
{
int n,k,i,d,pw;
for(i=0;i<10;++i)
a[i] = 1;
sd(n);
sd(k);
for(i=0;i<k;++i)
{
sd(d);
a[d] = 0;
}
pw = 1;
for(;pw<n;pw*=10);
for(;n<=pw;++n)
{
int tmp = n;
while(tmp)
{
if(!a[tmp%10]) break;
tmp /= 10;
}
if(tmp==0)
{
//cout << " here " << endl;
printf("%d\n",n);
return;
}
}
int dig = 0;
while(pw)
{
dig++;
pw/=10;
}
//cout << "here!! " << endl;
if(a[0])
{
for(i=1;i<10;++i)
{
//cout << " a["<<i<<"]: " <<a[i] << endl;
if(a[i]) break;
}
printf("%d",i);
dig--;
while(dig--)
{
printf("0");
}
printf("\n");
}
else
{
for(i=1;i<10;++i)
{
if(a[i]) break;
}
while(dig--)
{
printf("%d",i);
}
printf("\n");
}
}
int main()
{
int t = 1;
//scanf("%d",&t);
while(t--)
{
solve();
}
}
Submission Info
| Submission Time |
|
| Task |
C - Iroha's Obsession |
| User |
anubhav94 |
| Language |
C++14 (GCC 5.4.1) |
| Score |
300 |
| Code Size |
2117 Byte |
| Status |
AC |
| Exec Time |
4 ms |
| Memory |
256 KiB |
Compile Error
./Main.cpp: In function ‘void solve()’:
./Main.cpp:39:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
sd(n);
^
./Main.cpp:40:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
sd(k);
^
./Main.cpp:43:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
sd(d);
^
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
300 / 300 |
| Status |
AC
|
|
| Set Name |
Test Cases |
| Sample |
|
| All |
subtask0_sample_01.txt, subtask0_sample_02.txt, subtask1_X_01.txt, subtask1_X_02.txt, subtask1_X_03.txt, subtask1_X_04.txt, subtask1_X_05.txt, subtask1_X_06.txt, subtask1_X_07.txt, subtask1_X_08.txt |
| Case Name |
Status |
Exec Time |
Memory |
| subtask0_sample_01.txt |
AC |
4 ms |
256 KiB |
| subtask0_sample_02.txt |
AC |
4 ms |
256 KiB |
| subtask1_X_01.txt |
AC |
4 ms |
256 KiB |
| subtask1_X_02.txt |
AC |
4 ms |
256 KiB |
| subtask1_X_03.txt |
AC |
4 ms |
256 KiB |
| subtask1_X_04.txt |
AC |
4 ms |
256 KiB |
| subtask1_X_05.txt |
AC |
4 ms |
256 KiB |
| subtask1_X_06.txt |
AC |
4 ms |
256 KiB |
| subtask1_X_07.txt |
AC |
4 ms |
256 KiB |
| subtask1_X_08.txt |
AC |
4 ms |
256 KiB |