Codeforces 快速竞技#4
快速竞技#4
A–Duff and Meat588A
= =这题不知道怎么写题解了。。
直接上code……….
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const double eps=1e-5;
const double pi=acos(-1.0);
const int mod=1e8+7;
const LL INF=0x3f3f3f3f;
const int N=1e3+10;
int main()
{
int n;
int x,a,b;
x=INF;
scanf("%d",&n);
int ans=0;
for(int i=0;i<n;i++)
{
scanf("%d%d",&a,&b);
if(b<x)
x=b;
ans+=a*x;
}
printf("%d\n",ans);
return 0;
}
B——-Duff in Love588A
lovely number.:不能整除一个a^2(a>1)。
给出一个N(<=10^12),在他的因子里,求一个最大的lovely number.
思路:
不含平方因子就是说一种因子只能存在一个,所以说分解质因子然后一种因子取一个就好了。
学到一波:分解质因数;可以求所有质因数哟~~~
for(LL i=2;i*i<=n;i++)
{
if(n%i==0){
ans*=i;
while(n%i==0)
n/=i;
}
if(n==1)
break;
}
code………..
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const double eps=1e-5;
const double pi=acos(-1.0);
const int mod=1e8+7;
const LL INF=0x3f3f3f3f;
const int N=1e6+10;
int d[N];
int main()
{
int u,v;
LL n;
LL ans=1;
scanf("%I64d",&n);
for(LL i=2;i*i<=n;i++)
{
if(n%i==0){
ans*=i;
while(n%i==0)
n/=i;
}
if(n==1)
break;
}
if(n>1)
ans*=n;
printf("%I64d\n",ans);
return 0;
}
F: 584C - Marina and Vasya
题意:
求一个字符串和s1,s2有t个不同;
思路:
直接搞;还是蛮清楚的构造。
code…………..
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const double eps=1e-5;
const double pi=acos(-1.0);
const int mod=1e8+7;
const LL INF=0x3f3f3f3f;
const int N=1e5+10;
char s1[N],s2[N],ans[N];
bool status[N];
char kill(char a,char b)
{
for(int i='a';i<='z';i++)
{
if(i!=a&&i!=b)
return i;
}
}
int main()
{
int n,t,sum;
scanf("%d%d",&n,&t);
scanf("%s%s",s1,s2);
sum=0;
memset(status,0,sizeof(status));
for(int i=0;i<n;i++)
{
if(s1[i]!=s2[i])
sum++;
else
status[i]=1;
}
if(sum==t)
{
for(int i=0;i<n;i++)
{
if(status[i])
ans[i]=s1[i];
else
ans[i]=kill(s1[i],s2[i]);
}
}
else if(sum<t){ //补齐t-sum;
int cnt=0;
for(int i=0;i<n;i++)
{
if(status[i])
{
if(cnt<(t-sum))
{
ans[i]=kill(s1[i],s2[i]);
cnt++;
}
else
ans[i]=s1[i];
}
else
ans[i]=kill(s1[i],s2[i]);
}
}
else{ //不同的多了t-sum
int cnt1=0,cnt2=0; //把两个串都补齐,可能补不齐,所以最后还要判断。
for(int i=0;i<n;i++)
{
if(status[i])
ans[i]=s1[i];
else
{
if(cnt1<(sum-t))
{
ans[i]=s1[i];
cnt1++;
}
else if(cnt2<(sum-t))
{
ans[i]=s2[i];
cnt2++;
}
else
ans[i]=kill(s1[i],s2[i]);
}
}
}
int sum1=0,sum2=0;
for(int i=0;i<n;i++)
{
if(s1[i]!=ans[i])
sum1++;
if(s2[i]!=ans[i])
sum2++;
}
if(sum1!=t||sum2!=t)
{
puts("-1");
return 0;
}
ans[n]='\0';
printf("%s",ans);
return 0;
}
Codeforces 快速竞技#4的更多相关文章
- 某神奇的cf跳转插件
// ==UserScript== // @name Codeforces快速跳转菜单 // @namespace http://tampermonkey.net/ // @version 2019. ...
- CodeForces 450B (矩阵快速幂模板题+负数取模)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=51919 题目大意:斐波那契数列推导.给定前f1,f2,推出指定第N ...
- codeforces magic five --快速幂模
题目链接:http://codeforces.com/contest/327/problem/C 首先先算出一个周期里面的值,保存在ans里面,就是平常的快速幂模m做法. 然后要计算一个公式,比如有k ...
- codeforces 677C C. Vanya and Label(组合数学+快速幂)
题目链接: C. Vanya and Label time limit per test 1 second memory limit per test 256 megabytes input stan ...
- Educational Codeforces Round 13 D. Iterated Linear Function (矩阵快速幂)
题目链接:http://codeforces.com/problemset/problem/678/D 简单的矩阵快速幂模版题 矩阵是这样的: #include <bits/stdc++.h&g ...
- Codeforces Round #257 (Div. 2) B. Jzzhu and Sequences (矩阵快速幂)
题目链接:http://codeforces.com/problemset/problem/450/B 题意很好懂,矩阵快速幂模版题. /* | 1, -1 | | fn | | 1, 0 | | f ...
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
- Codeforces Round #536 (Div. 2) F 矩阵快速幂 + bsgs(新坑) + exgcd(新坑) + 欧拉降幂
https://codeforces.com/contest/1106/problem/F 题意 数列公式为\(f_i=(f^{b_1}_{i-1}*f^{b_2}_{i-2}*...*f^{b_k} ...
- Educational Codeforces Round 60 D dp + 矩阵快速幂
https://codeforces.com/contest/1117/problem/D 题意 有n个特殊宝石(n<=1e18),每个特殊宝石可以分解成m个普通宝石(m<=100),问组 ...
随机推荐
- Android6.0权限管理以及使用权限该注意的地方
Android 6.0 Marshmallow首次增加了执行时权限管理,这对用户来说,能够更好的了解.控 制 app 涉及到的权限.然而对开发人员来说却是一件比較蛋疼的事情.须要兼容适配,并保证程序功 ...
- 【自用】OI计划安排表一轮
网络流√ 上下界最大流√ 线性规划转费用流√ RMQ优化建图√ 单纯形√ 字符串相关 hash√ 扩展KMP 回文自己主动机 数据结构 平衡树 启示式合并 替罪羊树 LCT 树套树 KD-Tree 二 ...
- SolidEdge如何绘制变化半径倒圆角
1 在要变化半径的边上打一些点 2 点击倒角命令的参数对话框,选择可变半径 3 选择倒角的直线,右击确认,再依次点击关键点,修改倒角数值,修改之后按回车,继续下一个点,直到结束.
- (转) SYSTEM_HANDLE_INFORMATION中ObjectTypeIndex的定义
typedef struct _SYSTEM_HANDLE_TABLE_ENTRY_INFO{ USHORT UniqueProcessId; USHORT CreatorBackTraceIndex ...
- Gas Station,转化为求最大序列的解法,和更简单简单的Jump解法。——贪心、转化
Gas Station There are N gas stations along a circular route, where the amount of gas at station i is ...
- 卸载 linux http
当我们想卸载httpd 的时候,使用rpm -qa httpd 的时候,我们发现有很多的依赖包.我们耐心的想一个一个的卸载的时候(使用rpm -e httpd-*),还会进入死循环.解决的办法是:使用 ...
- 【转载】分布式RPC框架性能大比拼
dubbo.motan.rpcx.gRPC.thrift的性能比较 Dubbo 是阿里巴巴公司开源的一个Java高性能优秀的服务框架,使得应用可通过高性能的 RPC 实现服务的输出和输入功能,可以和 ...
- POJ--2284--That Nice Euler Circuit【平面图欧拉公式】
链接:id=2284">http://poj.org/problem?id=2284 题意:一个自己主动绘图的机器在纸上(无限大)绘图,笔尖从不离开纸,有n个指令,每一个指令是一个坐标 ...
- 例子:两个表根据productID合并
- Flume接收器组的指数退避上限
指数退避 agent.sinkgroups.sg1.sinks=k1,k2,k3agent.sinkgroups.sg1.processor.type=failoveragent.sinkgroups ...