子数整数(luogu 1151)
生活随笔
收集整理的這篇文章主要介紹了
子数整数(luogu 1151)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
子數(shù)整數(shù)
luogu 1151
題目大意
給出一個數(shù)k,讓你在10000~30000中求出滿足前三位,中間三位,后三位都可被k整除的數(shù)
輸入樣例
15輸出樣例
22555 25555 28555 30000數(shù)據(jù)范圍
0<k<1000
解題思路
暴力枚舉
代碼
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define ll long long #define fst(x) ((x) / 100) #define scd(x) ((x) / 10 % 1000) #define trd(x) ((x) % 1000) using namespace std; int n, g; void writ(int x) {if (x / 10) writ(x / 10);putchar(x % 10 + 48); } void write(int x) {if (x < 0) putchar('-'), x = -x;writ(x);putchar(10);return; } int main() {scanf("%d", &n);for (int i = 10000; i <= 30000; ++i)if (fst(i) % n == 0 && scd(i) % n == 0 && trd(i) % n == 0)write(i), g = 1;if (!g) puts("No");return 0; }總結(jié)
以上是生活随笔為你收集整理的子数整数(luogu 1151)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 史上最坑爹的游戏6攻略 全流程攻略介绍
- 下一篇: 【数学】拉格朗日插值(luogu 478