黑心啤酒厂
Time limit per test: 1.0 seconds
Time limit all tests: 1.0 seconds
Memory limit: 256 megabytes
Accept / Submit: 1001 / 3217
黑心啤酒厂为了让大家买啤酒,会把一瓶酒设计成恰好能倒七杯。由于聚会时经常会有大家一起干杯这样的事情,干杯之前又要给每个人都倒满,所以来两个人的时候,干完三轮,恰好多一杯;三个人的时候,干完两轮,恰好多一杯;四个人的时候会多三杯。在上述情况下,为了践行不浪费的原则,就会多买一瓶啤酒,再干一轮。当然多买的啤酒可能又有多了……然后循环往复,喝了好多好多。直到啤酒刚刚好喝完为止。
现在啤酒厂把酒瓶设计成刚好能倒 x 杯,请依次求出有 2 人、3 人,一直到 n 人参加聚会时,啤酒厂各能卖出多少瓶啤酒。
Input
输入只有一行,两个整数 x,n (1≤x≤109,2≤n≤105)。
Output
输出 n−1 行,分别表示 2,3,…,n 人参加聚会时,能卖出的啤酒瓶数。
Examples
input
7 5
output
2
3
4
5
Time limit per test: 1.0 seconds
Time limit all tests: 1.0 seconds
Memory limit: 256 megabytes
Accept / Submit: 1001 / 3217
黑心啤酒厂为了让大家买啤酒,会把一瓶酒设计成恰好能倒七杯。由于聚会时经常会有大家一起干杯这样的事情,干杯之前又要给每个人都倒满,所以来两个人的时候,干完三轮,恰好多一杯;三个人的时候,干完两轮,恰好多一杯;四个人的时候会多三杯。在上述情况下,为了践行不浪费的原则,就会多买一瓶啤酒,再干一轮。当然多买的啤酒可能又有多了……然后循环往复,喝了好多好多。直到啤酒刚刚好喝完为止。
现在啤酒厂把酒瓶设计成刚好能倒 x 杯,请依次求出有 2 人、3 人,一直到 n 人参加聚会时,啤酒厂各能卖出多少瓶啤酒。
Input
输入只有一行,两个整数 x,n (1≤x≤109,2≤n≤105)。
Output
输出 n−1 行,分别表示 2,3,…,n 人参加聚会时,能卖出的啤酒瓶数。
Examples
input
7 5
output
2
3
4
5
水题
最小公倍数 除以x就好了
下面是ac代码
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<iostream>
using namespace std;
#define MID(x,y) ((x+y)>>1)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int N=2e5+7;
int x,n,i;
int gcdd(int a,int b){
int c;
while(b!=0)
{ c=a%b; a=b; b=c;}
return i/a;
}
int main()
{
//freopen("f:/input.txt", "r", stdin);
int j,k,s;
scanf("%d%d",&x,&n);
for(i=2;i<=n;i++){
if(x>=i){
k=gcdd(x,i);
}else{
k=gcdd(i,x);
}
printf("%d\n",k);
}
}