首页 > 其他分享 >Codeforces 1360 D. Buying Shovels

Codeforces 1360 D. Buying Shovels

时间:2023-02-03 11:32:55浏览次数:48  
标签:铲子 题意 买法 int min Codeforces 1360 ans Shovels


Codeforces 1360 D. Buying Shovels_i++

题意:

要买 Codeforces 1360 D. Buying Shovels_i++_02 个铲子,商店中有 Codeforces 1360 D. Buying Shovels_i++_03中不同的卖法,依次每一次卖 Codeforces 1360 D. Buying Shovels_i++_04Codeforces 1360 D. Buying Shovels_i++_03 个铲子,现在只能选择其中的一种买法,问最少买几次同一种的买法,使得刚好买到 Codeforces 1360 D. Buying Shovels_i++_02

直接选择小于 Codeforces 1360 D. Buying Shovels_i++_03Codeforces 1360 D. Buying Shovels_i++_02

AC代码:

int n, m, k;
int main()
{
int t;
sd(t);
while (t--)
{
sdd(n, k);
int ans = inf;
for (int i = 1; i * i <= n; i++)
{
if (n % i == 0)
{
if (i <= k)
ans = min(ans, n / i);
if (n / i <= k)
ans = min(ans, i);
}
}
pd(ans);
}
return 0;
}


标签:铲子,题意,买法,int,min,Codeforces,1360,ans,Shovels
From: https://blog.51cto.com/u_15952369/6035735

相关文章

  • Codeforces 1360 E. Polygon
    题意:在一个的网格上方和左边都有一排大炮,每次可以发射一个,遇到边界和都会停下来,有没有一种发射频率可以组成给出的大炮的位置在左和上,所以每个非右边界或者下边界的......
  • Codeforces 1358 C. Celex Update
    题意:一个矩形内有多个方格,每个方格都按照顺序填写了一些数。给两个坐标,求这两个坐标间路径经过的数字和不同的路线总数。可以看出比如要从走到,这两种走法和第二个比......
  • Codeforces 1354 D. Multiset(树状数组)
    题意;要你实现一个求第k大数的数据结构。树状数组模板题。AC代码:constintN=1e6+50;inta[N];intn,q;voidadd(intp,intval){while(p<=n){a[p]+=va......
  • codeforces 580C Kefa and Park (树上DFS)
    Description:Kefadecidedtocelebratehisfirstbigsalarybygoingtotherestaurant.Helivesbyanunusualpark.Theparkisarootedtreeconsistingof n ve......
  • CodeForces - 253E Table with Letters - 2
    Description:Let'sconsideranetworkprinterthatfunctionslikethat.Itstartsworkingattime0.Ineachseconditcanprintonepageofatext.Atsomemomen......
  • Codeforces1201 B Maximum Median (二分)
    Description:Youaregivenanarray aa of nn integers,where nn isodd.Youcanmakethefollowingoperationwithit:Chooseoneoftheelementsofthearray......
  • Codeforces Round #596 D
    找到a[i]*a[j]=x^k符合这个式子的有多少种组合。分解质因子来做就行了AC代码:#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<s......
  • Codeforces-343D Water Tree(树链剖分)
    Description:MadscientistMikehasconstructedarootedtree,whichconsistsof n vertices.Eachvertexisareservoirwhichcanbeeitheremptyorfilledw......
  • Codeforces Round #596 B2. TV Subscriptions
    题意就是让你在N个数中找到D个连续的数,使这D个数中不同的数最小。hard数据较大,优化到nlogn才能过。具体怎么优化看代码吧AC代码:#include<cstdio>#include<cstring>......
  • Codeforces Round #596 C. p-binary
    给定N和p,让你找到满足2^x+p最少有多少不同的项。就把N转成二进制然后枚举P的个数就是答案,昨天特判没写好,今天早上起来发现被卡掉了。rank又出1000了。AC代码:#include<......