热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

UVA11440HelpMr.Tomisu欧拉phi函数

欧拉phi函数的改进版..HelpTomisuTimeLimit: 7000MSMemoryLimit: Unknow


欧拉phi函数的改进版.....


Help Tomisu
Time Limit: 7000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu

Submit Status

Description

技术分享

Problem D
Help Mr. Tomisu
Input: 
Standard Input

Output: Standard Output

After wasting a significant time of his life in problem-setting, Mr. Tomisu is now searching for glory: A glory that will make him famous like Goldbach and rich like Bill Gates :). And he has chosen the field of Number Theory as his prime interest. His creator did not make him very bright and so he needs your help to solve an elementary problem, using which he will begin his pursuit for glory!

Tomisu has come to know that finding out numbers having large prime factors are very important in cryptography. Given two integers N and M, he aims to count the number of integers x between 2 and N! (factorial N), having the property that all prime factors of x are greater than M.

Input

The input file contains at most 500 lines of inputs. Each line contains two integers N (1

Output

For each line of input produce one line of output. This line contains the value T % 100000007 (Modulo 100000007 value of T). Here T is the total number of numbers between 1 and N! (factorial N) which have prime factors greater than M. 

Sample Input                                     Output for Sample Input

100 10

100 20

10000 9000

0 0

43274465

70342844

39714141


Problemsetter: Shahriar Manzoor

Special Thanks: Per Austrin

Source

Root :: AOAPC II: Beginning Algorithm Contests (Second Edition) (Rujia Liu) :: Chapter 10. Maths :: Examples
Root :: Prominent Problemsetters :: Shahriar Manzoor

Root :: AOAPC I: Beginning Algorithm Contests -- Training Guide (Rujia Liu) :: Chapter 2. Mathematics :: Number Theory :: Exercises: Intermediate

Submit Status

技术分享


/* ***********************************************
Author        :CKboss
Created Time  :2015年02月02日 星期一 16时13分33秒
File Name     :UVA11440.cpp
************************************************ */

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

using namespace std;

typedef long long int LL;

const LL mod = 100000007LL ;
const int maxn = 10001000;

LL n,m;

bool vis[maxn];
LL phiac[maxn];

/// get prime
void getPRIME()
{
	memset(vis,true,sizeof(vis));
	vis[0]=vis[1]=false;
	for(int i=2;i*i>n>>m)
	{
		if(n==0&&m==0) break;
		LL temp = phiac[m];
		for(int i=m+1;i<=n;i++)
			temp =( temp * i )%mod;
		cout<<(temp-1+mod)%mod<



UVA 11440 Help Mr. Tomisu 欧拉phi函数


推荐阅读
author-avatar
无语噶流浪
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有