码迷,mamicode.com
首页 > 其他好文 > 详细

PE刷题记

时间:2018-07-20 22:26:41      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:algo   ccf   none   getch   hid   opened   sed   print   暴力   

PE

最喜欢做这种很有意思的数学题了虽然数学很垃圾

但是这个网站的提交方式好鬼畜啊qwq

1.

直接枚举

2.

直接枚举

3.

$\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;
}
/*
*/
T3

4.

暴力枚举

技术分享图片
#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;
}
/*
*/
T4

 

PE刷题记

标签:algo   ccf   none   getch   hid   opened   sed   print   暴力   

原文地址:https://www.cnblogs.com/zwfymqz/p/9343771.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!