A. 这是一道简单的水题~
生活随笔
收集整理的這篇文章主要介紹了
A. 这是一道简单的水题~
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
A. 這是一道簡單的水題~
pbz最近沉浸在數學中無法自拔,他發現了一種非常有趣的數,這個數的十進制表示形式中只含有8和9,這個數有著很好的寓意,代表了pbz的夢想和期望,他想知道對于任意的給定的正整數N,有多少個正整數M使得N*M所得得數是pbz所想要的數。
Input
第一行給出一個T,表示有T組案例,每個測試用例由一行組成,每行輸入一個正整數N(1<=N*M<=1e10)
Output
對于每個輸入的N,按升序輸出所有符合條件的M,如果M不存在的話就輸出“\This is not of value!\”。
Sample Input
2
5
9
Sample Output
\This is not of value!\
1
11
111
1111
11111
111111
1111111
11111111
98765432
111111111
987654321
987654322
987654332
987654432
987655432
987665432
987765432
988765432
998765432
1098765432
1111111111
只有 8 9 兩個選擇bfs就好
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<string> #include<algorithm> #include<stack> #include<queue> #include<cctype> #include<functional> using namespace std; #define swap(a,b) {long long c=a;a=b;b=c;} const int MAX = 999999; const double Eps = 1e-12; const double PI = acos(-1.0); int gcd(int x, int y) {return x%y == 0 ? y : gcd(y, x%y); } long long num[1000005] = { 8,9 }; long long j; int main() {j = 2;long long i;for ( i = 0;;i++){num[j++] = num[i] * 10 + 8;if (num[j - 1]>10000000000)break;num[j++] = num[i] * 10 + 9;if (num[j - 1]>10000000000)break;}int t;scanf("%d", &t);while (t--){long long n;scanf("%lld", &n);int flag = 0;for (int i = 0;i<j;i++){if (num[i] % n == 0 && num[i] <= 1e+10){flag = 1;printf("%lld\n", num[i] / n);}if (num[i]>10000000000)break;}if (flag==0) printf("\\This is not of value!\\\n");}return 0; }總結
以上是生活随笔為你收集整理的A. 这是一道简单的水题~的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: webstorm最新版激活破解
- 下一篇: win10计算机信息更改图,win10修