哪里错了,大佬帮帮忙

P1150 Peter 的烟

13146367338hk @ 2024-07-09 09:23:24

#include<iostream>
using namespace std;
int main()
{
    int k,n,a; 
    int p;
    cin>>n>>k;
    p=n+1-1;
    a=n/2;
    p=p+a;
    p=p-1;
    cout<<p<<endl;
    return 0;
}#include <iostream>
using namespace std;
int main()
{
    long long x,y,z=0,a; 
    cin>>x>>y;
    for(int i=x;i<=y;i++)
    {
        a=0;
        for(int j=2;j<=i;j++)
        {

        if(i%j==0);
        {
            a = a+1;
        }

        }

        if(a!=0)
        {
            z = z+1;
        }   

    }
    cout<<z<<endl;
    return 0; 
}

by FALLTOHER_LOVE @ 2024-07-09 09:27:28

#include <bits/stdc++.h>
     using namespace std;
     int main(){
         int n,k;
         cin>>n>>k;
         cout<<n+(n-1)/(k-1);
         return 0;
     }

不需要这么麻烦吧?!


by FALLTOHER_LOVE @ 2024-07-09 09:33:40

#include <bits/stdc++.h>
using namespace std;
int main(){
   int n,k;
   cin>>n>>k;  \\输入
   cout<<n+(n-1)/(k-1); \\n+换来的烟
   return 0;
     }

直接相除向下取整,加上就行。(求关)


by 13146367338hk @ 2024-07-09 09:35:37

谢谢已关注


by tangyiqi @ 2024-07-09 17:30:04

@zengyq_2011 我没实力,但我想告诉你:“你的注释斜线方向不对,真正的注释斜线在‘?’这里”


by FALLTOHER_LOVE @ 2024-07-09 21:31:30

@tangyq_2011 谢谢,确实是错了。但要非要有没实力的人的话那只可能是我hh。


by FALLTOHER_LOVE @ 2024-07-09 21:32:56

有事的话就私聊吧。


by Bao0714 @ 2024-07-12 21:30:29

@13146367338hk

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b=0,c,ans=0;
    cin>>a>>c;
    while(a>0)
    {
        ans++;
        a--;
        b++;
        if(b>=c)
        {
            b-=c;
            a++;
        }
    }
    cout<<ans;
    return 0;
}

AC


by caizimo @ 2024-07-23 10:53:38

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
const int N=2e5+10;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n,k; cin>>n>>k;
    for(int i=1;i<=n;i++){
        if(i%k==0) n++;
    }
    cout<<n; 
    return 0;
}

|