CSP 202209-1 如此编码 C++

 链接

 1 #include <iostream>
 2 #include <vector>
 3 
 4 int main() {
 5     int x{}, m{};
 6     std::cin >> x >> m;
 7     std::vector<std::vector<int>> nc(x+1,std::vector<int>(2,1));//nc是二维数组 ,第一列代表n数组,第二列代表c数组 x+1是为了方便使用c0将数组增加一行
 8     std::vector<int> b(x + 1,0);
 9 
10     for (int i{1}; i <= x; i++) {
11         std::cin >> nc[i][0];
12         nc[i][1] *= (nc[i][0] * nc[i - 1][1]);
13 
14         b[i] = (m % nc[i][1]) / nc[i - 1][1];
15     }
16 
17     for (int i{ 1 }; i <= x; i++) {
18         std::cout << b[i] << ' ';
19     }
20 }

 

posted @ 2022-11-14 12:35  任由天明  阅读(118)  评论(0)    收藏  举报