Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int INF = 1e9;
- const int N = 1e6;
- int dp[N + 10], par[N + 10], cnt[N + 10];
- string ans[N + 10];
- int main(){
- dp[1] = 0;
- for(int i = 2; i <= N; i ++)
- dp[i] = INF;
- for(int i = 1; i <= N; i ++){
- for(int j = i + i, c = 1; j <= N; j += i, c ++){
- int cur = dp[i] + 3 + c;
- if(cur < dp[j]){
- dp[j] = cur;
- par[j] = i;
- cnt[j] = c;
- }
- }
- }
- FILE *read, *write;
- read = fopen("kon_input.txt", "r");
- write = fopen("kon_output.txt", "w");
- int Q;
- fscanf(read, "%d", &Q);
- fprintf(write, "10\n");
- for(int q = 1; q <= Q; q ++){
- int x;
- fscanf(read, "%d", &x);
- fprintf(write, "%d\n", q);
- int cur = x;
- vector <char> ans;
- while(cur != 1){
- for(int i = 1; i <= cnt[cur]; i ++)
- ans.push_back('V');
- ans.push_back('V');
- ans.push_back('C');
- ans.push_back('A');
- cur = par[cur];
- }
- for(int i = dp[x] - 1; i >= 0; i --)
- fprintf(write, "%c", ans[i]);
- fprintf(write, "\n");
- }
- fclose(read);
- fclose(write);
- return 0;
- }
Advertisement
RAW Paste Data
Copied
Advertisement