第三题一直为0,也不知道为啥,就很烦。 #include<iostream> (5488)#include<vector> #include<stdio.h> (5570)#include<algorithm> #include<stdlib.h> using namespace std; bool nthUglyNumber(vector<int> test) { int a = test[0], b = test[1], c = test[2], d = test[3]; while (d > a) { if (d % c == 0) d = d / c; else { d = d - b; } } if (d == a) return true; else return false; } int main() { int T; cin >> T; vector<vector<int>> inputs(T, vector<int>(4)); for (int i = 0;i < T;i++) { cin >> inputs[i][0] >> inputs[i][1] >> inputs[i][2] >> inputs[i][3]; } bool a; for (int i = 0;i < T;i++) { a = nthUglyNumber(inputs[i]); cout << a; if (i < T - 1) cout << endl; } }
1 1

相关推荐

不愿透露姓名的神秘牛友
昨天 11:29
已编辑
斯卡蒂味的鱼汤:知道你不会来数马,就不捞你😂最近数马疯狂扩招,招聘要求挺低的,你能力肯定够,应该就是因为太强了,知道你不会来才不捞你
投递腾讯云智研发等公司10个岗位
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务