版本比较
模拟赛代码
标题
增加 1 行删除 1 行
11T2.cpp模拟赛代码正文
增加 61 行删除 76 行
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787945678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364```cpp#include<bits/stdc++.h>using namespace std;map<int, int>mq;int fast(int a, int b) { int ans = 1; while (b) { if (b & 1) ans *= a; a *= a; b >>= 1; } return ans;}int fx[500005], xhj[500005];int main() { freopen("loop.in", "r", stdin); freopen("loop.out", "w", stdout); int t; cin >> t; while (t--) { int a, n; cin >> a >> n; int s2 = 0, s5 = 0; int s = n; while (s % 2 == 0) { s /= 2; s2++; } while (s % 5 == 0) { s /= 5; s5++; } if (s == 1) { if (s2 > s5) { a *= fast(5, s2 - s5); }else { a *= fast(2, s5 - s2); } int lena = 0, x = a; while (x > 0) { x /= 10; lena++; } cout << "0."; for (int i = 1; i <= max(s2, s5) - lena; i++) cout << 0; cout << a << "\n"; }else { int lf = max(s2, s5), len = 0; a *= 10; for (int i = 1; i <= lf; i++) { fx[i] = a / n; a %= n; a *= 10; } for (int i = 1; i <= 500000; i++) { if (mq[a]) break; len++; xhj[i] = a / n; mq[a] = a; a %= n; a *= 10; } mq.clear(); int jl = lf; while (fx[jl] == xhj[len] && jl > 0 && len > 0) { jl--; len--; } cout << "0."; for (int i = 1; i <= jl; i++) { cout << fx[i]; } cout << "("; for (int i = jl + 1; i <= lf; i++) cout << fx[i]; for (int i = 1; i <= len; i++) cout << xhj[i]; cout << ")\n"; } }}```const int N = 3010;const int inf = 0x3f3f3f3f;int n, m, f[N];struct Node{ int l, r;}no[N];bool vis[N];//初始状态int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); freopen("spring.in", "r", stdin); freopen("spring.out", "w", stdout); cin >> n >> m; for(int i = 1; i <= n; ++i){ cin >> no[i].l >> no[i].r; for(int j = no[i].l; j <= no[i].r; ++j){ vis[j] = true; } } memset(f, inf, sizeof(f)); n += 2; no[n - 1] = {0, 0}; no[n] = {m + 1, m + 1}; f[0] = 0; for(int i = 1; i <= m; ++i){//哪个点 if(vis[i]){ f[i] = f[i - 1]; continue; } for(int j = 1; j <= n; ++j){//使用哪个弹簧 if(no[j].r < i){//从左边扩展 int more = i - no[j].r; if(no[j].l - more - 1 < 1) f[i] = min(f[i], more); else f[i] = min(f[i], f[no[j].l - more - 1] + more); // cout << i << " " << j << " " << f[i] << " " << more << endl; } } } cout << f[m] << endl; return 0;}/*T1 spring 超级弹簧考虑f[i]表示覆盖i最少使用的次数到一个点时枚举所有弹簧覆盖n<=3000...按左端点排序后贪心 不对 一定用最近的吗 - 事实上不一定中英一定要互译-----------2026年NOICA联盟-NOIP模拟赛(十七)-DIV2----------8:05 不是下发文件炸了只能用Div1的了8:29 T2搞定了,但没有大样例,再说8:41 T3有点思路但不确定正确性,先开T48:45 不是现在大样例上去了...等一会测一下T2吧9:10 T1思路很巧妙,这是怎么想到的9:28 T2没取模气笑了9:29 T2没毛病li(喜)9:59 T3 OK了,兵贵神速啊 验证一下复杂度 时间没问题11:04 T4答案稍小,祭11:21 T4极限数据跑了10s,气死我了,不过至少得到72pts了,好耶11:43 T4优化到6.3s了,就差一点(bushi) 5.7s了
预计分数: 100 + 100 + 100 + 72 = 372*/