刚开始是模拟做的,能过样例但是过不了数据:
#include<bits/stdc++.h>
using namespace std;
#define int long long
int k = 3;
signed main()
{
int a, b, n; cin >> a >> b >> n;
double temp = a * 1.0 / b;
string str = to_string(temp);
for (int i = 0; i < str.size(); i++)
{
if (str[i] == '.')
{int j = i + n;
while (k--)
{
cout << str[j];
j++;
}
}
}
return 0;
}