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),问组 ...
随机推荐
- IE浏览器打不开解决的方法
windows 7和windows 8上的IE浏览器打不开.非常可能是权限问题,解决的方法: 点击"開始"-"执行",输入"regedit" ...
- Android使用procrank和dumpsys meminfo 、top分析内存占用情况
如果你想查看所有进程的内存使用情况,可以使用命令procrank.dumpsys meminfo查看,当然也只可以过滤出某个进程如:dumpsys meminfo | grep -i phone 先来 ...
- IO模型:同步、异步、阻塞、非阻塞
前言: 在Linux的网络编程中,同步IO(synchronous IO).异步IO(asynchronous IO).阻塞IO(blocking IO).非阻塞IO(non-blocking IO) ...
- ios NSAttributedString 具体解释
ios NSAttributedString 具体解释 NSAttributedString能够让我们使一个字符串显示的多样化,可是眼下到iOS 5为止,好像对它支持的不是非常好,由于显示起来不太方便 ...
- App反编译二次打包常见问题处理
1.二次打包时报错:Error retrieving parent for item: No resource found that matches the given name 如: D:\用户文件 ...
- 面向对象 委托变量和this的使用
委托方法: this的使用:
- pdf reference 格式具体说明
1. PDF概要 1.1. 图像模型 PDF能以平台无关.高效率的方式描叙复杂的文字.图形.排版. PDF 用图像模型来实现设备无关. 图像模型同意应用程序以抽象对象描叙文字.图像.图标.而不是通过详 ...
- 线程、SMP、微内核
- glGenLists返回0或None的原因
最近调用PyOpenGL做显示,想在程序启动时候调用Display List进行显示,但是glGenLists返回None,若在程序启动后调用则没有任何问题. 搜索谷歌后,给出的解释: This ca ...
- Ajax的简单实现(JQuary)
还是之前的例子,相对来说,用JQ就简单了很多,真的多,因为JQ直接把方法都写好了,直接调用就行了,,ԾㅂԾ,, php文件就不需要多做修改了,如下: <?php //改变Content-Type ...