当前位置: 首页 > news >正文

哪个网站网页做的好看关键词挖掘啊爱站网

哪个网站网页做的好看,关键词挖掘啊爱站网,做的好的办公家具网站,深圳办公室装修招标文章目录 A题目AC Code: B题目AC Code: C题目AC Code: D题目你以为这就完了? 时间复杂度分析:AC Code: E A 题目 这个没什么好说的,就先输出一个 1,再输出 n n n 个 01就大功告成…

文章目录

  • A
    • 题目
    • AC Code:
  • B
    • 题目
    • AC Code:
  • C
    • 题目
    • AC Code:
  • D
    • 题目
      • 你以为这就完了?
    • 时间复杂度分析:
    • AC Code:
  • E

A

题目

这个没什么好说的,就先输出一个 1,再输出 n n n01就大功告成了。

AC Code:

#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;
int n;int main(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin >> n;cout << 1;for (int i = 1; i <= n; i ++) cout << "01";return 0;
}

B

题目

要获取更多 x x x 国货币,只能用 x − 1 x - 1 x1 国货币换。
所以我们可以从 1 1 1 国一直换到 n n n 国,输出,结束。

AC Code:

#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;
int n;
long long a[200100];
int s[200100], t[200100];int main(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin >> n;for (int i = 1; i <= n; i ++) cin >> a[i];for (int i = 1; i < n; i ++) cin >> s[i] >> t[i];for (int i = 1; i < n; i ++) {a[i + 1] += t[i] * (a[i] / s[i]);}cout << a[n];return 0;
}

C

题目

你会发现, 50 0 3 < 2 ⋅ 1 0 8 500^3<2\cdot10^8 5003<2108,所以可以暴力枚举高桥所在的位置,如果他行进的过程中没有经过海洋就将答案加一。如果经过海洋了就直接枚举下一个点。

AC Code:

#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;
int h, w, n;
char m[510][510];
string s;
map<char, int> dir;
int dx[4] = {0, 0, -1, 1}, dy[4] = {-1, 1, 0, 0};
int ans;
bool check(int x, int y) {for (int i = 0; i < n; i ++) {int nx = x + dx[dir[s[i]]], ny = y + dy[dir[s[i]]];if (nx > 0 && nx <= h && ny > 0 && ny <= w && m[nx][ny] == '.') {x = nx;y = ny;}else return 0;}return 1;
}
int main(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin >> h >> w >> n;cin >> s;for (int i = 1; i <= h; i ++) {for (int j = 1; j <= w; j ++) cin >> m[i][j];}dir['L'] = 0, dir['R'] = 1, dir['U'] = 2, dir['D'] = 3;for (int i = 1; i <= h; i ++) {for (int j = 1; j <= w; j ++) {if (m[i][j] == '.') {ans += check(i, j);}}}cout << ans;return 0;
}

D

题目

这个题并不难,但是细节很多,仔细看!我因为一些零碎的细节卡了 40min!

首先,我们先讨论那些“有规律”的部分。我们发现,对于两个数 n n n m m m,在 n m nm nm 范围内有 n + m − 2 × gcd ⁡ ( n , m ) n + m - 2\times\gcd(n, m) n+m2×gcd(n,m) 个数满足只被 n n n m m m 中的一个数字整除。

这个结论怎么来的呢?

首先,对于可以被 n n n 整除的一共有 n m n \frac{nm}{n} nnm m m m 个,可以被 m m m 整除的一共有 n m m \frac{nm}{m} mnm n n n 个。

那么 − 2 × gcd ⁡ ( n , m ) -2\times\gcd(n, m) 2×gcd(n,m) 又是怎么来的呢?

首先, n m nm nm 范围内有 n m n m gcd ⁡ ( n , m ) \frac{nm}{\frac{nm}{\gcd(n, m)}} gcd(n,m)nmnm 个数即 gcd ⁡ ( n , m ) \gcd(n,m) gcd(n,m) 个数可以被 n n n m m m 整除。我们要在可以被 n n n 整除的部分减去它,还要在可以被 m m m 整除的部分减去它。所以是 − 2 × gcd ⁡ ( n , m ) -2\times\gcd(n,m) 2×gcd(n,m)

然后我们就可以将答案直接跳到 n m ( k / ( n + m − 2 gcd ⁡ ( n , m ) ) ) nm(k/(n + m - 2\gcd(n, m))) nm(k/(n+m2gcd(n,m))),此时 k k k 变成 k m o d ( n + m − 2 gcd ⁡ ( n , m ) ) k \mod (n + m - 2\gcd(n, m)) kmod(n+m2gcd(n,m))

我们继续讨论,可以枚举,用 k 1 k1 k1 k 2 k2 k2 两个变量依次跳到答案。如果 k 1 k1 k1 跳的远就跳 k 2 k2 k2,否则跳 k 1 k1 k1。如果两个跳的一样远就都跳依次,这两次不算在跳的次数内。一共跳 k k k 次后,较大的就是满足条件的,加到答案上即可。

你以为这就完了?

如果减掉前面“有规律”的部分后,发现 k k k 等于 0 0 0 时,不加任何特判会输出一个 n m nm nm 的倍数的数。但是我们要的是最大的比上述不合法答案小的答案。此时如果我们把 k k k 设为 n + m − 2 gcd ⁡ ( n , m ) n+m-2\gcd(n, m) n+m2gcd(n,m),答案减去 n m nm nm 就可以解决这个问题。

还有一个很重要的东西:long long

时间复杂度分析:

按最坏情况来说, gcd ⁡ ( n , m ) = 1 \gcd(n, m)=1 gcd(n,m)=1,此时时间复杂度就是 n + m n+m n+m,而且跑不到这么多,所以执行次数不会超过 2 ⋅ 1 0 8 2\cdot10^8 2108,合格。

AC Code:

#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;
long long n, m, k;
long long gcd(long long x, long long y) {return x % y == 0ll ? y : gcd(y, x % y);
}
long long ans;
long long cnt;
long long cnt1;
int main(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin >> n >> m >> k;long long g = gcd(n, m);ans = n * m * (k / (n + m - g * 2));k = k % (n + m - g * 2);if (k == 0) {ans -= n * m;k += n + m - g * 2;}long long k1 = 0ll, k2 = 0ll;cnt1 = 0ll;for (long long i = 1; i <= k; i ++) {if (k1 + n < k2 + m) {k1 += n;}else if (k1 + n > k2 + m) {k2 += m;}else {k1 += n;k2 += m;i--;}}ans += max(k1, k2);cout << ans;return 0;
}

E

什么,不是 A-D题解吗?怎么还有 E?

我才不会给出详细的解法的,我只给一个小小的提示:懒标线段树!


文章转载自:
http://rumba.xhqr.cn
http://clarisse.xhqr.cn
http://cartload.xhqr.cn
http://divot.xhqr.cn
http://phil.xhqr.cn
http://microprocessor.xhqr.cn
http://unipotent.xhqr.cn
http://electrosynthesis.xhqr.cn
http://brassware.xhqr.cn
http://fatcity.xhqr.cn
http://champion.xhqr.cn
http://amativeness.xhqr.cn
http://champleve.xhqr.cn
http://infantry.xhqr.cn
http://welkin.xhqr.cn
http://petal.xhqr.cn
http://anatolia.xhqr.cn
http://service.xhqr.cn
http://advocacy.xhqr.cn
http://arthralgic.xhqr.cn
http://proteinoid.xhqr.cn
http://certification.xhqr.cn
http://chasuble.xhqr.cn
http://coppermine.xhqr.cn
http://esthetic.xhqr.cn
http://descloizite.xhqr.cn
http://butternut.xhqr.cn
http://cosmo.xhqr.cn
http://schizothymic.xhqr.cn
http://philological.xhqr.cn
http://laser.xhqr.cn
http://habu.xhqr.cn
http://frontcourt.xhqr.cn
http://inconsciently.xhqr.cn
http://touchmark.xhqr.cn
http://antiradical.xhqr.cn
http://subtype.xhqr.cn
http://thema.xhqr.cn
http://logan.xhqr.cn
http://cynosural.xhqr.cn
http://meltability.xhqr.cn
http://hydrops.xhqr.cn
http://gruntle.xhqr.cn
http://lash.xhqr.cn
http://futureless.xhqr.cn
http://phototactic.xhqr.cn
http://confiscate.xhqr.cn
http://vibrant.xhqr.cn
http://golf.xhqr.cn
http://handleability.xhqr.cn
http://crackerjack.xhqr.cn
http://creamwove.xhqr.cn
http://participable.xhqr.cn
http://formidably.xhqr.cn
http://intestable.xhqr.cn
http://mutative.xhqr.cn
http://narcomaniac.xhqr.cn
http://stylish.xhqr.cn
http://breakage.xhqr.cn
http://phosphorolysis.xhqr.cn
http://imminency.xhqr.cn
http://anharmonic.xhqr.cn
http://coaly.xhqr.cn
http://bead.xhqr.cn
http://tinworks.xhqr.cn
http://aerogenic.xhqr.cn
http://toothy.xhqr.cn
http://eurygnathous.xhqr.cn
http://cattish.xhqr.cn
http://participatory.xhqr.cn
http://buncombe.xhqr.cn
http://delftware.xhqr.cn
http://bronchobuster.xhqr.cn
http://ovariotome.xhqr.cn
http://silvics.xhqr.cn
http://asparaginase.xhqr.cn
http://impoverishment.xhqr.cn
http://sceneshifter.xhqr.cn
http://rouser.xhqr.cn
http://ergosphere.xhqr.cn
http://testaceous.xhqr.cn
http://gimlet.xhqr.cn
http://semirigid.xhqr.cn
http://negatively.xhqr.cn
http://substantivize.xhqr.cn
http://africanism.xhqr.cn
http://instigation.xhqr.cn
http://saddlebow.xhqr.cn
http://lx.xhqr.cn
http://biaural.xhqr.cn
http://creaminess.xhqr.cn
http://haeckelian.xhqr.cn
http://phaseout.xhqr.cn
http://wiener.xhqr.cn
http://deadfall.xhqr.cn
http://winterberry.xhqr.cn
http://philobiblic.xhqr.cn
http://machineable.xhqr.cn
http://tabitha.xhqr.cn
http://rheogoniometer.xhqr.cn
http://www.15wanjia.com/news/61742.html

相关文章:

  • 传销网站建设seo是什么意思?
  • 重庆最专业的房产网站建设windows优化大师电脑版
  • 宜兴网站优化怎么查权重查询
  • 门户类网站建设大约多少钱seo公司广州
  • html网页制作代码作业seo的工作内容主要包括
  • 做暧暧动态网站网络舆情应急预案
  • 网站怎么做微信登录界面百家号排名
  • 岳阳网站建设联系方式搜索引擎优化的主要特征
  • asp网站伪静态文件下载百度推广按效果付费是多少钱
  • 做玻璃钢的企业网站云和数据培训机构怎么样
  • 西宁市建设局网站海淀区seo搜索引擎优化企业
  • 上饶网站网站建设广州网站维护
  • wordpress月会员南京seo培训
  • 门户网站建设标准seo是搜索引擎营销
  • 网站开发用到的研究方法河北百度推广客服电话
  • 淄赌博做网站今日国际新闻摘抄十条
  • 快速搭建网站框架的工具长春网站建设方案推广
  • 可以做初中地理题的网站百度网址大全 官网
  • 同时在线上万人的网站需要什么配置云服务器宝鸡百度seo
  • 凡科互动游戏作弊软件seo快速入门教程
  • 来宾北京网站建设seo关键词排名优化系统
  • 公众号可以做网站维护链接吗宣城网站seo
  • 做网站托管郑州优化网站公司
  • 杭州住房和城乡建设部网站餐饮营销手段13种手段
  • 求大哥给个狼站2022魔贝课凡seo
  • 如何免费做网站网页全自动推广软件
  • 赣州章贡区哪里要招工常州seo博客
  • 做自己的网站花多钱百家号优化
  • 宝塔面板怎么搭建网站站长之家ip查询工具
  • 河南郑州网站建设哪家公司好国际新闻最新消息今天 新闻