https://ac.nowcoder.com/acm/contest/338/E

C++版本一

题解:

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <bitset>
using namespace std;
 
#define LL long long
const int maxn = 20;
int T;
LL x, k, ans;
int num[maxn];
 
int main() {
    #ifdef Dmaxiya
    freopen("test.txt", "r", stdin);
    #endif // Dmaxiya
    ios::sync_with_stdio(false);
 
    scanf("%d", &T);
    while(T--) {
        ans = 987654321000000000LL;
        scanf("%lld%lld", &x, &k);
        for(int i = 0; i < k; ++i) {
            scanf("%d", &num[i]);
        }
        printf("%lld\n", ans + (x - ans % x));
    }
 
    return 0;
}

C++版本二

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,q,ans;
int a;
char str;
int main()
{
#ifdef DEBUG
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#endif
    scanf("%d",&t);
    while(t--){
        scanf("%d%d",&n,&k);
        ll N=123456789000000000;
        for(int i=1;i<=k;i++)
            scanf("%d",&m);
        cout<<N+(n-N%n)<<endl;
    }
    //cout << "Hello world!" << endl;
    return 0;
}

C++版本三

题解:

 

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,q,ans;
int a;
char str;
int main()
{
#ifdef DEBUG
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#endif
    scanf("%d",&t);
    while(t--){
        scanf("%d%d",&n,&k);
        ll N=102345678900000000;
        for(int i=1;i<=k;i++)
            scanf("%d",&m);
        if(N%n)
            cout<<N+(n-N%n)<<endl;
        else
            cout<<N<<endl;
    }
    //cout << "Hello world!" << endl;
    return 0;
}