“东信杯”广西大学第一届程序设计竞赛(同步赛)(未完待更)
A
https://ac.nowcoder.com/acm/contest/283/A
#include<stdio.h> int main() { for(int i=0;i<90;i++) printf("Ninety for GXU, First for gxuacm\n"); return 0; }
C
https://ac.nowcoder.com/acm/contest/283/C
#include <bits/stdc++.h> using namespace std; int T; char s[220]; int check(char a, char b) { if(a == b) return 1; else if(abs(a - b) == 2) return 1; return 0; } int main() { scanf("%d", &T); while(T --) { int n; scanf("%d%s", &n, s); bool flag = true; if(n % 2 != 0) { flag = false; break; } int L = 0, R = n - 1; while(L <= R) { if(!check(s[L], s[R])) { flag = false; break; } L ++; R --; } if(flag) printf("1\n"); else printf("0\n"); } return 0; }
D
https://ac.nowcoder.com/acm/contest/view-submission?submissionId=37539035
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int T; long long N, M; long long x[maxn]; int main() { scanf("%d", &T); while(T --) { int cnt = 0; scanf("%lld%lld", &N, &M); long long maxx = max(N, M), minn = min(N, M); while(minn) { x[cnt ++] = maxx / minn; maxx %= minn; if(maxx < minn) swap(maxx, minn); } bool flag = true; int pos = cnt - 2; while(1) { if(pos < 0) { flag = true; break; } if(pos == 0) { if(x[pos] == 1) { flag = false; break; } } if(x[pos] == 1) pos -= 2; else pos --; } if(flag) printf("wula\n"); else printf("mmp\n"); } return 0; }
F
https://ac.nowcoder.com/acm/contest/283/F
#include <bits/stdc++.h> using namespace std; const int maxn = (1 << 15) + 10; int n, T; long long mp[20][20]; long long dp[maxn]; int main() { scanf("%d", &T); while(T --) { scanf("%d", &n); for(int i = 0; i < n; i ++) { for(int j = 0; j < n; j ++) scanf("%lld", &mp[i][j]); } for(int i = 0; i < (1 << n); i ++) { int cnt = 0; for(int j = 0; j < n; j ++) if(i & (1 << j)) cnt ++; long long maxx = 0; for(int j = 0; j < n; j ++) { if(i & (1 << j)) { maxx = max(maxx, dp[i ^ (1 << j)] + mp[j][cnt - 1]); } } dp[i] = maxx; } printf("%lld\n", dp[(1 << n) - 1]); } return 0; }
H
https://ac.nowcoder.com/acm/contest/283/H
#include <cstdio> #include <string> #include <map> #include <queue> #include <stack> #include <cstring> #include <iostream> #include <algorithm> using namespace std; const long long mod = 1e9 + 7; long long INF = 1e18; const int Node = 50000 + 10; const int Edge = 100000 + 10; int n, m, s, t; long long dis[Node]; int h[Node], a[Edge], b[Edge], nx[Edge], edgeCount; long long c[Edge]; void add(int aa, int bb, long long cc) { a[edgeCount] = aa; b[edgeCount] = bb; c[edgeCount] = cc; nx[edgeCount] = h[aa]; h[aa] = edgeCount; edgeCount++; } void init() { edgeCount = 0; for (int i = 1; i <= n; i++) { dis[i] = INF; h[i] = -1; } dis[s] = 0; } void input() { for (int i = 1; i <= m; i++) { int aa, bb; long long cc; scanf("%d%d%lld", &aa, &bb, &cc); for (long long i = 0; ; i++) { if (1LL * (1 << i) == cc) { cc = i; break; } } add(aa, bb, cc); // cout << aa << " !!! " << bb << " " << cc << endl; } } void dijkstra() { priority_queue<pair<long long, int>> q; q.push(make_pair(0, s)); while (!q.empty()) { pair<long long, int> tp = q.top(); q.pop(); int d = -tp.first; int v = tp.second; for (int i = h[v]; i != -1; i = nx[i]) { if (dis[v] + c[i] < dis[b[i]]) { dis[b[i]] = dis[v] + c[i]; q.push(make_pair(-dis[b[i]], b[i])); } } } } long long qp(long long x, long long y) { long long res = 1; x = x % mod; while (y) { if (y % 2 == 1) { res = res * x % mod; y--; } x = x * x % mod; y /= 2; } return res; } int main() { scanf("%d%d%d%d", &n, &m, &s, &t); init(); input(); dijkstra(); if (dis[t] == INF) { printf("-1\n"); } else { cout << qp(2LL, dis[t]) << endl; } return 0; }
我鸭力很大呐!!! 要再努力一点呢
下周考 PAT 今天开始复习了 有点紧脏
今天开始 be 主的二十天减肥计划