为啥零分??哪位dalao帮忙看一下

P1150 Peter 的烟

f2_longtian @ 2021-02-22 19:13:44

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int x[100000000];
    int i=0;
    while(n>k)
    {
        x[i]=n/k;
        i+=1;
        n=n/k;
    }
    n=n/k;
    cout<<n+n/k+x;
    return 0;
}

by 渡鸦2007 @ 2021-02-22 19:17:25

@13683327376a

  1. int x[100000000];放到主函数外

  2. cout<<n+n/k+x; x是数组啊,怎么加?


by yuchenren @ 2021-02-22 19:17:36

观察样例后得到结果是 n + (n - 1) \div (k - 1)


by zimujun @ 2021-02-22 19:19:57

@13683327376a


by f2_longtian @ 2021-02-22 19:20:32

感谢各位大佬


by Masna_Kimoyo @ 2021-02-22 19:36:10

@13683327376a 我是虫地


|