Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 求解数据问题

Posted by hanyin at 2016-03-26 16:31:02 on Problem 2773
```#include <cstdio>
#include <algorithm>
#include<math.h>
#include<string.h>
#include<memory.h>
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include <stdio.h>
#include <stack>
#include <set>
#define MOd 0x7FFFFFFF;
#define mod 65537;
typedef  long long LL;
using namespace std;
int m,k;
int prime[1000000],num[1000000],num2[3000000];

void eluer(){
for(int i=2;i<=1000000;i++){
if(prime[i]==0){
for(int j=i+i;j<=1000000;j+=i)
prime[j]=1;

}

}
}

int main(){
freopen("in.txt","r",stdin);
prime[1]=0;
eluer();
while(~scanf("%d%d",&m,&k)){
int i,j;
if(m==1){
cout<<k<<endl;
continue;
}
int fg=0;
fg++;
num[fg]=1;
//memset(num2,0,sizeof(num2));
for(i=1;i<=m;i++)
num2[i]=0;
for(i=2;i<=m;i++){
if(prime[i]==0&&m%i==0){
for( j=i;j<=m;j+=i)
num2[j]=1;
}
}
for(i=2;i<=m;i++){
if(num2[i]!=1){
fg++;
num[fg]=i;
//  cout<<i<<endl;
}

}
long long t=k/fg;
k=k%fg;
if(k==0)
k=fg,t--;
long long sum=t*m+num[k];
cout<<sum<<endl;
}
return 0;
}

Followed by: