您的位置:首页 > 其它

第十周 5.2 --- 5.8

2016-05-02 19:29 387 查看
似乎什么都没干就半期了...

5.2

B.卿学姐与基本法

离散化

卡了好几天,,学了一种有一点点不一样的离散化

写挫还是犯了和寒假一样的错,离散化之后,update (1,1,tot)而不是那个 n 了

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;

int n;
multiset<int> s;
const int maxn = 1e2+5;
int a[maxn],cnt;

void fenjie( int x){
int y = x;
for(int j = 2;j*j <= y;j++){
if(y%j == 0){
while(y%j == 0){
a[++cnt] = j;
y = y/j;
if(cnt == 2) return;
}
if(cnt == 2) return;
}
}
if(y > 1) a[++cnt] = y;
}

void solve(){
n = n-3;
if(n == 0){
puts("4");
return;
}
if(n < 4){
puts("No such base");
return;
}

int y = n;
cnt = 0;
memset(a,0,sizeof(a));
fenjie(y);
if(a[1] > 3){
printf("%d\n",a[1]);
return;
}
if(a[1]*a[2] > 3){
printf("%d\n",a[1]*a[2]);
return;
}
printf("No such base\n");
}

int main(){
while(scanf("%d",&n)){
if(n == 0) break;
solve();
}
return 0;
}


View Code

补完水题,补不动了.........................
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: