从这里开始
- 题目列表
- 瞎扯
- Problem A Find a Number
- Problem B Berkomnadzor
- Problem C Cloud Computing
- Problem D Garbage Disposal
- Problem E Getting Deals Done
- Problem F Debate
- Problem G Monsters and Potions
- Problem H BerOS File Suggestion
- Problem I Privatization of Roads in Berland
- Problem J Streets and Avenues in Berhattan
- Problem K Video Posts
- Problem L Odd Federalization
- Problem M Algoland and Berland
瞎扯
又来打比赛了,发现自己菜得不行。
果然我是标准的普及组选手。(这个队名是啥意思?我也不知道,因为不知道取啥队名,就随机在键盘上敲Emmm)
这次队友很给力,把我不会的模拟和贪心全切掉了,并且每次翻译了正确的题意(我英语真垃圾)。(上次UESTC ACM Final的队友让我很绝望,既不会做题又给我翻译假题面)
然后我把剩下的送分题都切掉了。
于是被碾压了:
开始通读全题(提供pdf真良心,避免网卡耽误时间),我觉得很绝望,尤其是那个B,读得我很绝望,直接扔翻译里都弃了。
之后并不知道怎么做题,然后随机一道题,发现是水题是一道水题就直接切掉了。
之后就开始看榜,那个题通过的队多就做哪个。
佬表示这个不是正确的做法,正确的做法是每个人随机若干道题,先自己去做,不会的话然后扔给队友。
挂掉的话也可以扔队友。
但是我和我队友都挺菜的,这么搞可能完蛋了。
下来发现B,J都是送分题。
Problem A Find a Number
题目大意
问最小的满足各位数字之和为$s$并且能被$d$整除的正整数。
首先用bfs确定它的位数,每个状态记录通过尽量小的转移边转移的前驱。
然后做完了。
Code
1 /** 2 * Codeforces 3 * Problem#1070A 4 * Accepted 5 * Time: 108ms 6 * Memory: 24800k 7 * Author: yyf 8 */ 9 #include <iostream> 10 #include <cstdlib> 11 #include <cstring> 12 #include <cstdio> 13 #include <queue> 14 using namespace std; 15 typedef bool boolean; 16 17 const int N = 5005, D = 505; 18 #define pii pair<int, int> 19 #define fi first 20 #define sc second 21 22 int d, s; 23 int f[N][D]; 24 char lst[N][D]; 25 int lstr[N][D]; 26 boolean vis[N][D]; 27 28 pii trans(int s, int r, int dig) { 29 return pii(s + dig, (r * 10 + dig) % d); 30 } 31 32 inline void init() { 33 scanf("%d%d", &d, &s); 34 } 35 36 queue<pii> que; 37 boolean bfs() { 38 que.push(pii(0, 0)); 39 memset(f, 0x3f, sizeof(f)); 40 f[0][0] = 0, vis[0][0] = true; 41 while (!que.empty()) { 42 pii e = que.front(); 43 que.pop(); 44 45 for (int i = 0; i <= 9; i++) { 46 pii eu = trans(e.fi, e.sc, i); 47 if (eu.fi > s) 48 break; 49 if (vis[eu.fi][eu.sc]) 50 continue; 51 vis[eu.fi][eu.sc] = true; 52 lst[eu.fi][eu.sc] = i + '0'; 53 lstr[eu.fi][eu.sc] = e.sc; 54 f[eu.fi][eu.sc] = f[e.fi][e.sc] + 1; 55 que.push(eu); 56 } 57 } 58 return vis[s][0]; 59 } 60 61 void print(int s, int r) { 62 if (!s && !r) 63 return ; 64 int nr = lstr[s][r]; 65 print(s - lst[s][r] + '0', nr); 66 putchar(lst[s][r]); 67 } 68 69 70 inline void solve() { 71 if (bfs()) { 72 print(s, 0); 73 } else 74 puts("-1"); 75 } 76 77 int main() { 78 init(); 79 solve(); 80 return 0; 81 }