constint MAXN = 2E5 + 5; constint MOD = 1E9 + 7; int n, m;
LL get(LL val){ LL tmp = val % 10000; if (val >= 0) return val - tmp; else return val - tmp - (tmp == 0 ? 0 : 10000); } //返回小于等于的第一个能模10000的数
voidsolve(int testNum){ // type your code here string aa, bb, rr; LL a = 0, b = 0, r = 0; cin >> aa >> bb >> rr; int cnta = 4, cntb = 4, cntr = 4; bool taga = 0, tagb = 0, tagr = 0; for (int i = 0; i < aa.size(); i++) { if (taga) cnta--; if (aa[i] != '.') a = a * 10 + aa[i] - '0'; else taga = 1; } while (cnta) a *= 10, cnta--;
for (int i = 0; i < bb.size(); i++) { if (tagb) cntb--; if (bb[i] != '.') b = b * 10 + bb[i] - '0'; else tagb = 1; } while (cntb) b *= 10, cntb--;
for (int i = 0; i < rr.size(); i++) { if (tagr) cntr--; if (rr[i] != '.') r = r * 10 + rr[i] - '0'; else tagr = 1; } while (cntr) r *= 10, cntr--; LL ans = 0; for (LL y = get(b - r); y <= get(b + r); y += 10000) { LL res = r * r - (y - b) * (y - b); if (res > 0) { LL tmp = sqrt(res); LL k1 = get(-tmp + a) - 100000, k2 = get(tmp + a) + 1000000; while ((k1 - a) * (k1 - a) > res) k1+=10000; while ((k2 - a) * (k2 - a) > res) k2-=10000; ans += (k2 - k1) / 10000 + 1; } elseif (res == 0 && a % 10000 == 0) ans++; } cout << ans; }
signedmain(){ int testCase = 1; for (int i = 1; i <= testCase; i++) solve(i); return0; }
int n, m; vector<pair<int, int>> g[MAXN]; array<int, MAXN> dis, inq, self;
voidspfa(int st){ for (int i = 1; i <= n; i++) dis[i] = 1e9, inq[i] = false; queue<int> q; q.push(st), inq[st] = true; dis[st] = 0; while (!q.empty()) { int cur = q.front(); q.pop(); inq[cur] = false; for (auto& e : g[cur]) { int to = e.first, w = e.second; if (dis[to] > dis[cur] + w) { dis[to] = dis[cur] + w; if (!inq[to]) { q.push(to); inq[to] = true; } } } } int ans = 1e9; for (int i = 1; i <= n; i++) { for (auto & e : g[i]) { if (e.first == st) { ans = min(ans, dis[i] + e.second); } } } if (ans != 1e9) cout << ans << "\n"; elsecout << "-1\n"; }
signedmain(){ boost; cin >> n >> m; for (int i = 1; i <= m; i++) { int u, v, w; cin >> u >> v >> w; g[u].push_back({v, w}); } for (int i = 1; i <= n; i++) spfa(i); return0; }
intmain(){ boost; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; mn = *min_element(a.begin() + 1, a.begin() + n + 1); for (int i = 1; i <= n; i++) { for (int j = 1; j <= sqrt(a[i]); j++) { if (a[i] % j == 0) divs.push_back(j), divs.push_back(a[i] / j); } } sort(divs.begin(), divs.end()); auto ed = unique(divs.begin(), divs.end()); int ans = 0; for (auto it = divs.begin(); it != ed; ++it) { if (*it >= mn) continue; vector<int> vec; for (int i = 1; i <= n; i++) if (a[i] % (*it) == 0) vec.push_back(a[i]); if (vec.size() <= 1) continue; int gcd = vec.front(); for (int i = 1; i < vec.size(); i++) gcd = __gcd(gcd, vec[i]); if (gcd == *it) ans++; } cout << ans + 1 << "\n"; return0; }