很神奇,正确性证明怎么证明??
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
int num[7] = {0, 1, 2, 4, 6, 7, 8};
int w[7] = {6, 2, 5, 4, 6, 3, 7};
int main() {
cin.tie(0) -> ios::sync_with_stdio(0);
int t; cin >> t;
while(t --) {
int n; cin >> n;
int p = ceil(n / 7.0);
bool f = 1;
if(n % 7 == 1) {
cout << "-1\n";
continue;
}
while(p > 0) {
int i;
if(f) i = 1, f = 0;
else i = 0;
for(; i <= 6; i ++) {
if(n - w[i] < 0) continue;
int np = ceil((n - w[i]) / 7.0);
if(np == p - 1) {
cout << num[i];
p --; n -= w[i];
break;
}
}
}
cout << "\n";
}
return 0;
}