A题

题意:给定一串数列,t,t+s,t+s+1,t+2s,t+2s+1......问某一个数是否是数列当中的

题意:只需判断(x-t)与(x-t-1)能否整除s即可,注意起始时的判断

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
int t,s,x;
int main()
{
while(cin>>t>>s>>x)
{
int flag=;
if(x<=t+){
if(x==t)
flag=;
}else{
if((x-t)%s==){
flag=;
}else if((x-t-)%s==){
flag=;
}
}
if(flag) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return ;
}

B题

题意:给定科学技术法,求出这个数

分析:直接模拟即可

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
string s;
int main()
{
while(cin>>s)
{
int k;
for(int i=;i<s.length();i++){
if(s[i]=='e'){
k=i; break;
}
}
int sum=;
for(int i=k+;i<s.length()-;i++){
sum+=(s[i]-'');
sum*=;
}
sum+=s[s.length()-]-'';
// cout<<sum<<endl;
int len=k-;
int h=sum;
int cnt=;
if(sum==)
cnt=;
while(h){
h/=;
cnt++;
}
// cout<<cnt<<endl;
// cout<<len<<endl;
if(len==&&s[]==''&&sum==)
{
cout<<s[]<<endl;
continue;
}
if(sum<len){
cout<<s[];
for(int i=;i<sum+;i++)
cout<<s[i];
cout<<".";
for(int i=sum+;i<s.length()-cnt-;i++)
cout<<s[i];
cout<<endl;
}else if(sum==len){
cout<<s[];
for(int i=;i<s.length()-cnt-;i++)
cout<<s[i];
cout<<endl;
}else{
cout<<s[];
for(int i=;i<s.length()-cnt-;i++)
cout<<s[i];
for(int i=;i<sum-len;i++)
cout<<"";
cout<<endl;
}
}
return ;
}

C题:

题意:给定每条边上的权值,求树上两点之间的距离

分析:对于两个结点x和y。我们记录下x到y每一步的权值,直到x与y的值相等为止,注意数据范围比较大,用map记录比较好

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
map<long long ,long long> mp;
int main()
{
int q;
cin>>q;
while(q--)
{
int num;
cin>>num;
if(num==)
{
long long x,y,cost;
cin>>x>>y>>cost;
while(x!=y)
{
if(x>y)
{
mp[x]+=cost;
x/=;
}else{
mp[y]+=cost;
y/=;
}
}
}
else
{
long long x,y;
cin>>x>>y;
long long res=;
while(x!=y)
{
if(x>y)
{
res+=mp[x];
x/=;
}else
{
res+=mp[y];
y/=;
}
}
cout<<res<<endl;
}
}
return ;
}

Codeforces#362的更多相关文章

  1. CodeForces #362 div2 B. Barnicle

    题目链接: B. Barnicle 题意:给出科学计数法 转化成十进制的整数或小数 并输出. 思路:暑假训练赛见过了,当时大腿A掉了,并表示是道水题. 刷CF再次遇见,毫不留情WA了几次.比如: 0. ...

  2. Codeforces Round #362 (Div. 2) C. Lorenzo Von Matterhorn (类似LCA)

    题目链接:http://codeforces.com/problemset/problem/697/D 给你一个有规则的二叉树,大概有1e18个点. 有两种操作:1操作是将u到v上的路径加上w,2操作 ...

  3. #map+LCA# Codeforces Round #362 (Div. 2)-C. Lorenzo Von Matterhorn

    2018-03-16 http://codeforces.com/problemset/problem/697/C C. Lorenzo Von Matterhorn time limit per t ...

  4. 【转载】【树形DP】【数学期望】Codeforces Round #362 (Div. 2) D.Puzzles

    期望计算的套路: 1.定义:算出所有测试值的和,除以测试次数. 2.定义:算出所有值出现的概率与其乘积之和. 3.用前一步的期望,加上两者的期望距离,递推出来. 题意: 一个树,dfs遍历子树的顺序是 ...

  5. Codeforces Round #362 (Div. 2) A.B.C

    A. Pineapple Incident time limit per test 1 second memory limit per test 256 megabytes input standar ...

  6. Codeforces Round #362 (Div. 2)->B. Barnicle

    B. Barnicle time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  7. Codeforces Round #362 (Div. 2)->A. Pineapple Incident

    A. Pineapple Incident time limit per test 1 second memory limit per test 256 megabytes input standar ...

  8. Codeforces Round #362

    A - Pineapple Incident #pragma comment(linker, "/STACK:102c000000,102c000000") #include &l ...

  9. Codeforces Round #362(Div1) D Legen...(AC自动机+矩阵快速幂)

    题目大意: 给定一些开心串,每个串有一个开心值,构造一个串,每包含一次开心串就会获得一个开心值,求最大获得多少开心值. 题解: 首先先建立AC自动机.(建立fail指针的时候,对val要进行累加) 然 ...

随机推荐

  1. java解析XML获取城市代码

    运行前先导入dom4j架包,由于我们公司用的代理服务器所以下面我设置了代理ip,不需要的可直接忽略 package com.chengshidaima.tools; import java.io.Bu ...

  2. HDU 3732 Ahui Writes Word 多重背包优化01背包

    题目大意:有n个单词,m的耐心,每个单词有一定的价值,以及学习这个单词所消耗的耐心,耐心消耗完则,无法学习.问能学到的单词的最大价值为多少. 题目思路:很明显的01背包,但如果按常规的方法解决时间复杂 ...

  3. php杂乱

    //    //    if ( $_GET['action'] == 'search' ) {//        $_clean = array();//        $_clean['stype ...

  4. centos6.5 安装git

    1.安装编译git时需要的包 # yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel # yum ins ...

  5. JS-DOM操作应用高级(一)

    表格应用--tBodies  tHead  tFoot  rows  cells <title>无标题文档</title> <script> window.onlo ...

  6. Contest - 多校训练(985专场) Problem C: 985的方格难题

    题目链接:http://acm.zzuli.edu.cn/zzuliacm/problem.php?cid=1157&pid=2 Description 985走入了一个n * n的方格地图, ...

  7. java下发电子邮件demo

    在实际项目中会遇到需要使用邮件注册,或者是使用邮件找回密码等操作,需要使用到邮件发送功能. 其实邮件的发送主要是依赖于邮件协议,只要能实现邮件协议,那么发送邮件其实还是很容易的.这一步java类库已经 ...

  8. hdu_5738_Eureka(脑洞)

    题目链接:hdu_5738_Eureka 题意: 这题感觉说不清楚,坑点有点坑,一不小心就会推出错误的公式,然后最重要的是你还不知道你推错了 题解: 这里贴一个官方的题解 Eureka xjb推导一下 ...

  9. 【项目笔记】布局文件报错Suspicious size: this will make the view invisible, probably intended for layout_width

    写着写着就懵逼了,一直以为布局文件没写错啊,horizontal就是竖直啊,原来布局文件报错,不仅仅需要从报错的地方解决问题,还需要从其他地方去分析. 很明显是方向orientation选错了,应该写 ...

  10. iis7支持asp(访问页面,页面存在仍然提示404)

    1. win7下安装IIS时ASP一般被默认不选中的状态,因此需要打开IIS检查功能视图栏中是否存在ASP选项,若没有则需要从控制面板->程序和 功能->打开或关闭Windows功能-&g ...