Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- #include<iostream>
- int main() {
- int T;
- cin >> T;
- while (T >= 1) {
- int n, flag;
- cin >> n;
- int z = n;
- if(n%5==0){
- for(int r=1;r<=n;r++){
- cout<<"3";
- }cout<<"n";
- }
- else if(n%5!=0){
- for (int i = 3; i <= n; i += 3) {
- if ((z - i) % 5 == 0) {
- flag = i;
- break;
- }
- }
- if (flag == 0|| (n-flag)%5!=0) {
- cout << "-1"<<"n";
- }
- else {
- for (int x = 1; x <= flag; x++) {
- cout << "5";
- }
- for (int y = 1; y <= (n - flag); y++) {
- cout << "3";
- }
- cout<<"n";
- }
- }
- T--;
- }
- }
- 3 * f + 5 * t = n
- f = n/3 - 5/3 * t
- n % 3 == (5 * t) % 3
- switch (n % 5):
- case 0: t = 0;
- case 1: t = 2;
- case 2: t = 1;
- if (5 * t <= n):
- print "5".repeat(n - 5 * t) + "3".repeat(5 * t)
- else
- print "-1"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement