标签:algo ccf none getch hid opened sed print 暴力
最喜欢做这种很有意思的数学题了虽然数学很垃圾
但是这个网站的提交方式好鬼畜啊qwq
直接枚举
直接枚举
$\sqrt(n)$枚举
#include<cstdio> #include<vector> #include<set> #include<algorithm> #define sit #define LL long long using namespace std; const int MAXN = 1e6 + 10; inline int read() { char c = getchar(); LL x = 0, f = 1; while(c < ‘0‘ || c > ‘9‘) {if(c == ‘-‘) f = -1; c = getchar();} while(c >= ‘0‘ && c <= ‘9‘) x = x * 10 + c - ‘0‘, c = getchar(); return x * f; } LL ans = 600851475143; int main() { LL out = 0; for(LL i = 2; i * i <= ans; i++) { if(ans % i == 0) { out = max(out, i); while(ans % i == 0) ans /= i; } } printf("%I64d", max(out, ans)); return 0; } /* */
暴力枚举
#include<cstdio> #include<vector> #include<set> #include<algorithm> #define sit #define LL long long using namespace std; const int MAXN = 1e6 + 10; inline int read() { char c = getchar(); LL x = 0, f = 1; while(c < ‘0‘ || c > ‘9‘) {if(c == ‘-‘) f = -1; c = getchar();} while(c >= ‘0‘ && c <= ‘9‘) x = x * 10 + c - ‘0‘, c = getchar(); return x * f; } int ans; int main() { int ans = 0; for(int i = 100; i <= 999; i++) { for(int j = 100; j <= 999; j++) { int x = i * j; int a[20], tot = 0, flag = 0; while(x) a[++tot] = x % 10, x /= 10; for(int k = 1; k <= tot; k++) if(a[k] != a[tot - k + 1]) {flag = 1; break;} if(flag == 0) ans = max(ans, i * j); } } printf("%d", ans); return 0; } /* */
标签:algo ccf none getch hid opened sed print 暴力
原文地址:https://www.cnblogs.com/zwfymqz/p/9343771.html