2012年10月18日 星期四

SGU 107 987654321 problem

There are only 8 answer:

111111111
119357639
380642361
388888889
611111111
619357639
880642361
888888889

And you can see that any number end with the numbers above is okay

So the answer is apparently clear.

//By momo
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n;
    scanf("%d\n", &n);
    if(n < 9) printf("0\n");
    else{
        if(n == 9) printf("8\n");
        else{
            printf("72");
            for(int i = 10; i < n; i++) printf("0");
            puts("");
        }
    }
}

沒有留言:

張貼留言