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 ...
随机推荐
- MyEclipse 10 和 2014 两个版本共存破解 - imsoft.cnblogs
第一步:运行 (run.bat)文件, 输入任意用户名 第二步:点击Systemid... 按钮,自动生成本机器的systemid. 第三步: 点菜单Tools->RebuildKey 第四 ...
- 十五个最常用Linux命令行 - imsoft.cnblogs
众多Linux管理员在使用Linux的时候会经常使用到很多Linux命令行,其中有绝大部分不是经常使用到的.在本文中主要为大家总结了经常使用的十五个最常用Linux命令行,希望对刚刚接触Linux命令 ...
- Java单例类的简单实现
对于java新手来说,单例类给我的印象挺深,之前一道web后台笔试题就是写单例类.*.*可惜当时不了解. 在大部分时候,我们将类的构造器定义成public访问权限,允许任何类自由创建该类的对象.但在某 ...
- HTML <area> 标签 带有可点击区域的图像映射(图像映射指的是带有可点击区域的图像)
例子: <img src="planets.gif" width="145" height="126" alt="Plane ...
- 1-3-2 Windows应用程序常用消息
主要内容:介绍Windows编程中常用的消息 1.WM_LBUTTONDOWN产生单击鼠标左键的消息 lParam: 低字节包含当前光标的X坐标值 X = LOWORD(lParam); 高字节包含当 ...
- HDU-4777 Rabbit Kingdom(区间更新求和)
题目大意:给一个n个整数的数列,q次询问,每次询问区间[l,r]中与区间中其它数互质的数的个数.. 题目分析:离线处理,这里以询问区间的左端点从小到大的顺序为例.为了叙述方便,用f(l,r)表示区间[ ...
- IOS开发之SWIFT进阶部分
概述 上一篇文章<iOS开发系列--Swift语言> 中对Swift的语法特点以及它和C.ObjC等其他语言的用法区别进行了介绍.当然,这只是Swift的入门基础,但是仅仅了解这些对于使用 ...
- 越狱Season 1-Episode 21: Go
Season 1, Episode 21: Go -Michael: I need you to let me get us out of here. 我需要你帮我出去 -Patoshik: If y ...
- 学习Logistic Regression的笔记与理解(转)
学习Logistic Regression的笔记与理解 1.首先从结果往前来看下how logistic regression make predictions. 设我们某个测试数据为X(x0,x1, ...
- android读取远程图片案例
关键代码:Bitmap bitmap=BitmapFactory.decodeByteArray(data, 0, data.length);imageview.setImageBitmap(bitm ...