bzoj3034: Heaven Cow与God Bull
Description
__int64 ago,there's a heaven cow called sjy...
A god bull named wzc fell in love with her...
As an OI & MOer,wzc gave sjy a quesiton...
给定一个整数n,求一个整数m,满足m<=n,并且m/phi(m)的值最大。
注:phi(m)代表m的欧拉函数,即不大于m且与m互质的数的个数。
Input
第一行是一个整数T,表示该测试点有T组数据。
接下来T行,每行一个整数n,意义如上所述。
Output
输出一共T行,每行一个整数m。
若对于某个n,有不止一个满足条件的m,则输出最小的m。
#include<cstdio>
#include<cstring>
int ps[],pp=;
bool isnp[];
int T;
char str[];
int p10[]={,,,};
struct integer{
int x[],id,ed;
void read(){
scanf("%s",str);
int l=strlen(str)-;
for(int i=;i<=l;i++){
x[i>>]+=p10[i&]*(str[l-i]-'');
}
}
void print(){
int p=;
while(p&&!x[p])--p;
printf("%d",x[p]);
for(int i=p-;~i;--i)printf("%04d",x[i]);
putchar();
}
void operator*=(int a){
for(int i=;i<;i++)x[i]*=a;
for(int i=;i<;i++)x[i+]+=x[i]/,x[i]%=;
}
}q[],v,v1;
bool operator>(integer&a,integer&b){
for(int i=;~i;--i){
if(a.x[i]!=b.x[i])return a.x[i]>b.x[i];
}
return ;
}
int main(){
for(int i=;i<=;i++){
if(!isnp[i])ps[pp++]=i;
for(int j=;j<pp&&i*ps[j]<=;j++){
isnp[i*ps[j]]=;
if(i%ps[j]==)break;
}
}
scanf("%d",&T);
for(int i=;i<T;i++){
q[i].id=i;
q[i].read();
}
v.x[]=v1.x[]=;
for(int i=;i<pp;i++){
v*=ps[i];
for(int j=;j<T;j++)if(!q[j].ed&&v>q[j]){
q[j]=v1;
q[j].ed=;
}
v1=v;
}
for(int i=;i<T;i++){
for(int j=;j<T;j++)if(q[j].id==i){
q[j].print();
}
}
return ;
}
bzoj3034: Heaven Cow与God Bull的更多相关文章
- 【Heaven Cow与God Bull】题解
题目 Description __int64 ago,there's a heaven cow called sjy... A god bull named wzc fell in love with ...
- 「Poetize3」Heaven Cow与God Bull
描述 Description 给定一个整数n,求一个整数m,满足m<=n,并且m/phi(m)的值最大.注:phi(m)代表m的欧拉函数,即不大于m且与m互质的数的个数. 题解:m/phi(m) ...
- tyvj 1934 高精度
「Poetize3」Heaven Cow与God Bull From wwwwodddd 背景 Background __int64 ago,there's a heaven cow call ...
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- BootStrap下拉框搜索功能
<!DOCTYPE html> <html> <head> <title>jQuery bootstrap-select可搜索多选下拉列表插件-www. ...
- Bull And Cows
package cn.edu.xidian.sselab.hashtable; import java.util.HashMap;import java.util.Map;import java.ut ...
- POJ 3278 Catch That Cow(bfs)
传送门 Catch That Cow Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 80273 Accepted: 25 ...
- 【BZOJ1623】 [Usaco2008 Open]Cow Cars 奶牛飞车 贪心
SB贪心,一开始还想着用二分,看了眼黄学长的blog,发现自己SB了... 最小道路=已选取的奶牛/道路总数. #include <iostream> #include <cstdi ...
- HDU Cow Sorting (树状数组)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2838 Cow Sorting Problem Description Sherlock's N (1 ...
随机推荐
- PAT (Basic Level) Practise:1021. 个位数统计
[题目链接] 给定一个k位整数N = dk-1*10k-1 + ... + d1*101 + d0 (0<=di<=9, i=0,...,k-1, dk-1>0),请编写程序统计每种 ...
- 如何创建 C# 控制台应用程序
[转] 如何:创建 C# 控制台应用程序 本主题旨在生成最简单形式的 C# 程序(控制台应用程序)熟悉 Visual Studio 2008 开发环境.由于控制台应用程序是在命令行执行其所有的输入和输 ...
- CentOS下Web服务器环境搭建LNMP一键安装包
CentOS下Web服务器环境搭建LNMP一键安装包 时间:2014-09-04 00:50来源:osyunwei.com 作者:osyunwei.com 举报 点击:3797次 最新版本:lnmp- ...
- 双系统安装要点 - imsoft.cnblogs
1.用磁盘工具 取消当前激活分区,并隐藏当前激活分区2.按照普通的形式安装系统 Ghost安装和简单安装都可以3用修复启动项工具 修复之前处隐藏的系统启动项 OK,再就不会看到烦人的蓝屏了!
- 227. Basic Calculator II
Implement a basic calculator to evaluate a simple expression string. The expression string contains ...
- 软件工程课程作业(二)--四则运算2改进版(c++)
题目要求: 1.避免题目重复 2.可定制(数量/打印方式) 3.可以控制下列参数 (1)是否有乘除法 (2)是否有括号 (3)数值范围 (4)加减有无负数 (5)除法有无余数 关键设计思想: oper ...
- TFTP网络协议分析---15
TFTP网络协议分析 周学伟 文档说明:所有函数都依托与两个出口,发送和接收. 1:作为发送时,要完成基于TFTP协议下的文件传输,但前提是知道木的PC机的MAC地址,因为当发送TFTP请求包时必须提 ...
- php部分---人员表和民族表的显示、修改、删除
1.连接数据库 进行网页的显示 <table width="100%" border="1" cellpadding="0" cell ...
- URAL 1004 Sightseeing Trip(最小环)
Sightseeing Trip Time limit: 0.5 secondMemory limit: 64 MB There is a travel agency in Adelton town ...
- timus 1106 Two Teams(二部图)
Two Teams Time limit: 1.0 secondMemory limit: 64 MB The group of people consists of N members. Every ...