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

著名的淘宝客网站怎么免费建立自己网站

著名的淘宝客网站,怎么免费建立自己网站,网站开发方式包括,百度小程序制作平台Problem - C - Codeforces 题意: 思路: 思路很简单,只删除一种,直接枚举删除的是哪一种即可 但是回文子序列的判定我vp的时候写的很答辩,也不知道为什么当时要从中间往两边扫,纯纯自找麻烦 然后就越改越…

Problem - C - Codeforces

题意:

 

思路:

思路很简单,只删除一种,直接枚举删除的是哪一种即可

但是回文子序列的判定我vp的时候写的很答辩,也不知道为什么当时要从中间往两边扫,纯纯自找麻烦

然后就越改越复杂,两小时的时候才过C

所以有新想法的时候还是把new idea整合一下,再去写代码

直接从两边往中间扫就行了,然后把该删的都删掉

Code:

#include <bits/stdc++.h>#define int long longusing i64 = long long;using namespace std;const int N = 2e5 + 10;
const int M = 3e6 + 10;
const int P = 131;void solve() {int n;    string s;cin >> n >> s;s = " " + s;set<char> S;for (int i = 1; i <= n; i ++) {S.insert(s[i]);}int ans = 1e9;for(auto c: S) {int l = 1, r = n;int cnt = 0;while(l <= r) {if (s[l] == s[r]) {l ++;r --;}else if (s[l] == c) {cnt ++;l ++;}else if (s[r] == c) {cnt ++;r --;}else {cnt = 1e9;break;}}ans = min(ans, cnt);}if (ans == 1e9) {cout << -1 << "\n";}else {cout << ans << "\n";}
}
signed main(){ios::sync_with_stdio(false);cin.tie(nullptr);int t = 1;cin >> t;while(t --) {solve();}return 0;
}

 

Problem - D - Codeforces

题意:

思路:

构造题,看样例发现什么都看不出来

先去考虑特殊的情况

如果N = 2,那么

a * x + b * y = 0

x = - b

y = a 

如果N = 3

有三种情况,以一种举例:

x = - c

y = - c

z = a + b

当然这里的c和-c可以替换成b和-b,a和-a,所以是三种情况

然后考虑将特殊情况“组合”到一般情况中去

可以发现,如果n是奇数,那么就分组成3+2+2+2+....的形式

否则就可以是2+2+2+....的形式

这样就做完了

这道题的启发是:可以用特殊情况“组合”成一般情况进行考虑

Code:

#include <bits/stdc++.h>#define int long longusing i64 = long long;using namespace std;const int N = 2e5 + 10;
const int M = 3e6 + 10;
const int P = 131;int a[N], b[N];void solve() {int n;cin >> n;for (int i = 1; i <= n; i ++) {cin >> a[i];}if (n % 2 == 1) {if (a[1] + a[3]) {b[1] = -a[2];b[3] = -a[2];b[2] = a[1] + a[3];}else if (a[1] + a[2]) {b[1] = -a[3];b[2] = -a[3];b[3] = a[1] + a[2];}else if (a[2] + a[3]) {b[2] = -a[1];b[3] = -a[1];b[1] = a[2] + a[3];}for (int i = 4; i <= n; i += 2) {b[i] = -a[i + 1];b[i + 1] = a[i];}}else {for (int i = 1; i <= n; i += 2) {b[i] = -a[i + 1];b[i + 1] = a[i];}}for (int i = 1; i <= n; i ++) {cout << b[i] << " \n" [i == n];}
}
signed main(){ios::sync_with_stdio(false);cin.tie(nullptr);int t = 1;cin >> t;while(t --) {solve();}return 0;
}

http://www.yayakq.cn/news/933572/

相关文章:

  • 发布的手机网站是乱码软装设计公司加盟
  • 中国建设银行网站-个人客户全球最好的云服务器
  • 开锁都在什么网站做建网站 域名 空间
  • 杭州网站建设官方蓝韵网络哪个网站做团购要求低点
  • 网站建设工资怎么样windows中建wordpress
  • 一个网站需要多少钱亳州网站建设费用
  • wordpress 一小时建站花生壳做网站需要备案
  • 哈尔滨专业网站制作大连企业公司网站建设
  • h5网站设计网站建设html代码
  • 网站搭建论文项目
  • 重庆免费微网站建设水平线设计公司官网
  • 沈阳网站建设小志购物平台app
  • 提供深圳网站制作公司网站开发专业感想
  • 学校门户网站建设工作百度免费广告发布平台
  • 网站运营总监网站建设的意见
  • vs中的网站导航怎么做聚美优品一个专注于做特价的网站
  • 自己动手建设公司门户网站有域名如何建网站
  • 广州电信网站备案门户网站建设公司市场
  • 网站备案丢失wordpress采集微博
  • 帝国cms怎么做电影网站wordpress如何连接到数据库
  • 域名注册好了怎么做网站网站建设夬金手指排名壹柒
  • 洪梅镇仿做网站陕西住房建设部网站
  • 免费下载现成ppt网站江苏连云港网站设计公司
  • ps制作网站传播易网站开发方案
  • 购物型网站怎么快速被百度收录福州网站推广定制
  • 网站收录查询系统wordpress建完目录404
  • 河南民基建设工程有限公司网站营销策划书范文案例
  • 长沙建站找有为太极环境遵公司邮箱怎么登陆
  • 免费个人网站搭建ru后缀的网站
  • 企业网站建设参考文献可以做夫妻的游戏视频网站