Codeforces Round #739 (Div. 3)
# | 题目 | 分数 | 是否AC |
---|---|---|---|
A | Dislike of Threes | 800 | ✅ |
B | Who’s Opposite? | 800 | ✅ |
C | Infinity Table | 800 | ✅ |
D | Make a Power of Two | 1300 | ✅ |
E | Polycarp and String Transformation | 1800 | ❌ |
F1 | Nearest Beautiful Number (easy version) | 1900 | ✅ |
F2 | Nearest Beautiful Number (hard version) | 2100 | ✅ |
A. Dislike of Threes
题目类型
题意
分析
时间复杂度
O ( 1000 ) O( 1000 ) O(1000)
代码
static int[] TB = new int[10010];
public static void solve() throws IOException {
pw.println(TB[nextInt()]);
}
public static void makeTB() {
int num = 1;
for (int i = 1; i < TB.length; i++) {
while (num % 10 == 3 || num % 3 == 0) num++;
TB[i] = num++;
}
}
B. Who’s Opposite?
题目类型
题意
分析
时间复杂度
O ( 1 ) O( 1 ) O(1)
代码
public static void solve() throws IOException {
int a = nextInt();
int b = nextInt();
int c = nextInt();
int sum = Math.abs(a - b) * 2;
if (sum < a || sum < b || sum < c) {
pw.println(-1);
return ;
}
if (c > sum / 2) pw.println(c - sum / 2);
else pw.println(c + sum / 2);
}