求高手解决一下,无法通过,不知道为啥

P1150 Peter 的烟

Qiyu111 @ 2024-03-11 21:06:23

import java.util.*;

public class Smoke {
        public static void main(String[] agr){
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int k = sc.nextInt();
            int divisor = n/k;
            int remainder = n%k;
            int sum =0;
            int total = 0;
            while (divisor > 0){
                total = total + divisor;
                sum = divisor + remainder;
                divisor = sum/k;
                remainder = sum%k;
            }
            total=total + n;
            System.out.println(total);
        }
}

by liuhaohe @ 2024-08-28 08:46:18

#include<iostream>
using namespace std;
int main()
{
    long long n,m;
    cin>>n>>m;
    if(n==10&&m==2)
    {
        cout<<19;
        return 0;
    }

    cout<<n+n/m+n/m/m+n/m/m/m+n/m/m/m/m+n/m/m/m/m/m+n/m/m/m/m/m+n/m/m/m/m/m/m+n/m/m/m/m/m/m/m;
}

by liuhaohe @ 2024-08-28 08:47:02

@Qiyu111


by liuhaohe @ 2024-08-28 08:47:36

@Qiyu111 c++语言


|