Educational Codeforces Round 70 (Rated for Div. 2) B D
2019-08-09 18:25
357 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_43676357/article/details/98972807
#include <iostream> #include <string> #include <algorithm> #define llint long long #define inf 1000000000000000000 using namespace std; string s; llint cnt[15]; llint cost[15]; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> s; for (int i = 1; i < s.size(); i++) { int a = s[i] - '0', b = s[i - 1] - '0'; cnt[(a - b + 10) % 10]++; } for (int x = 0; x < 10; x++) { for (int y = 0; y < 10; y++) { for (int g = 0; g < 10; g++) { llint mn = inf; for (llint i = 0; i <= 10; i++) { for (llint j = 0; j <= 10; j++) { if (i + j == 0) continue; if ((i*x + j * y) % 10 == g) mn = min(mn, i + j); } } cost[g] = mn - 1; } llint ans = 0; for (int g = 0; g < 10; g++) { if (cnt[g] > 0 && cost[g] > inf / 2) { ans = -1; break; } ans += cnt[g] * cost[g]; } cout << ans << " "; } cout << endl; } return 0; }
这题其实不难
#include <bits/stdc++.h> using namespace std; template<class T> void ckmin(T &a, T b) { a = min(a, b); } template<class T> void ckmax(T &a, T b) { a = max(a, b); } #define pb push_back #define mp make_pair #define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define F first #define S second #define sz(x) (int)x.size() #define all(x) (x).begin(), (x).end() #define rep(i, n) for(int i = 0; i < n; ++i) #define repr(i,n) for(int i = n - 1; i >= 0; --i) #define Rep(i, a, n) for(int i = (a); i <=(n); ++i) #define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it) #define Repr(i, a, n) for(int i = (n); i >= (a); --i) typedef long long ll; const int inf = int(1e9); const int mod = 1e9 + 7; const int N = 1e6 + 555; const long double PI = acos(-1.0); void solve() { int n; cin >> n; int res = 1; while(res * (res + 1) / 2 <= n) res++; n -= res * (res - 1)/ 2; string ans = "133"; for(int i = 0; i < n; ++i) ans += '7'; for(int i = 0; i < res - 2; ++i) ans += '3'; ans += '7'; cout << ans << endl; } int main() { Red; int T; cin >> T; while(T--) solve(); return 0; }
相关文章推荐
- Educational Codeforces Round 70 (Rated for Div. 2) D. Print a 1337-string...
- Educational Codeforces Round 38 (Rated for Div. 2) A. Word Correction
- C. Playlist---(贪心+优先队列)Educational Codeforces Round 62 (Rated for Div. 2)
- Educational Codeforces Round 39 (Rated for Div. 2) B. Weird Subtraction Process
- codeforces Educational Codeforces Round 33 (Rated for Div. 2)B
- Educational Codeforces Round 37 (Rated for Div. 2)【A B C】【水】【模拟】
- Codeforces Educational Codeforces Round 42 (Rated for Div. 2) D,E,F
- Educational Codeforces Round 34 (Rated for Div. 2) D - Almost Difference
- Educational Codeforces Round 38 (Rated for Div. 2) B. Run For Your Prize
- Educational Codeforces Round 35 (Rated for Div. 2) A
- Educational Codeforces Round 33 (Rated for Div. 2) 题解
- Educational Codeforces Round 36 (Rated for Div. 2)C. Permute Digits(贪心)
- Educational Codeforces Round 64 (Rated for Div. 2) Problem - A - Codeforces Inscribed Figures
- Educational Codeforces Round 65 (Rated for Div. 2)
- Educational Codeforces Round 40 (Rated for Div. 2) E. Water Taps
- Educational Codeforces Round 62 (Rated for Div. 2)
- Educational Codeforces Round 34 (Rated for Div. 2)
- Educational Codeforces Round 37 (Rated for Div. 2)F. SUM and REPLACE
- Educational Codeforces Round 39 (Rated for Div. 2) codeforces946 D. Timetable-数据处理+分组背包(处理炸裂)
- Educational Codeforces Round 62 (Rated for Div. 2)C. Playlist(优先队列)