喵哈哈村的魔法考试 Round #3 (Div.2)
菜的抠脚
A
题解:判断能否构成一个三角形。
#include "iostream"
#include "algorithm"
#include "cmath"
using namespace std;
int main(){
int T,a[3];
cin>>T;
while(T--){
for(int i=0;i<3;i++) cin>>a[i];
sort(a,a+3);
if((a[0]+a[1]>a[2]) && (abs(a[0]-a[1])<a[2] )){
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
}
return 0;
}
B
题解:开始走T/length(order),然后再走T%length(order)
#include "iostream"
#include "algorithm"
#include "cstring"
using namespace std;
char s[5000+10];
int t,len;
void Walk(int &x,int &y,char s){
if(s=='E') x++;
else if(s=='W') x--;
else if(s=='N') y++;
else if(s=='S') y--;
}
int main(int argc, char const *argv[]) {
/* code */
int x,y;
x = y = 0;
while(std::cin >> s>> t){
int len = strlen(s);
for(int i=0;i<len;i++){
Walk(x,y,s[i]);
}
x = x*( t/len ); y = y*( t/len );
t %= len;
for(int i=0;i<t;i++) Walk(x,y,s[i]);
std::cout << x <<" "<< y << '\n';
x = y = 0;
}
return 0;
}
C
题解: 我也不清楚为什么要用随机数做。。。 因为qsc oj是并行系统,所以。。。。 初始化随机数种子srand(time(NULL))是错的,可以用C++ new申请新空间,新申请的空间地址是随机的,所以以随机地址作为随机数种子。因为随机嘛,总有脸黑的时候。。。
// 正常想法是随机,感觉上来说随机几次就能AC。但是随机种子,决定了你的随机数。
// Srand(time(NULL))是不行的,因为这个OJ采用的是并发测评的模式,所以你获取的TIME(null)种子是一样的。
// 这儿一个正确做法是,抓取定义字符的内存,这个内存地址是随机的,然后来随机就好了
#include "stdio.h"
#include "time.h"
#include "stdlib.h"
#include "iostream"
using namespace std;
// new的用法:
// 1. Elemtype * = new Elemtype
// 2. Elemtype * = new Elemtype( init ) 以圆括号中数值进行初始化
// 3. Elemtype * = new Elemtype [ number ] 开辟一个number大小的空间,开辟二维空间相类似
// delete的用法和new用法相对应,销毁时不需要初始化
int main(){
int *a=new int[5];
srand((unsigned long) a);
delete[] a;
printf("%d\n",(rand()&1)+1);
return 0;
}
D
题解:直接暴力所有可能,用到了海伦公式S=sqrt(p * (p-a) * (p-b) * (p-c)) p=(a+b+c)/2,没看到保留整数......g
#include "iostream"
#include "algorithm"
#include "cmath"
#include "cstdio"
using namespace std;
int main() {
/* code */
int n;
double num[200];
while (cin >> n) {
for (int i = 0; i < n; i++) {
cin >> num[i];
}
// 数据小,暴力所有可能
sort(num,num+n);
double p,s,M_s = -1;
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++)
for(int k=j+1;k<n;k++)
if( num[i]+num[j]>num[k] )
{
p = (num[i]+num[j]+num[k])/2.0;
s = sqrt(p*(p-num[i])*(p-num[j])*(p-num[k]));
M_s = max(s,M_s);
}
if( M_s==-1 ) std::cout << "-1" << '\n';
else printf("%.0lf\n", s);
}
return 0;
}
E
题解:直接查日历......
#include "iostream"
#include "algorithm"
#include "cstdio"
#include "string"
using namespace std;
int main(){
int t;
char str[1000];
// 注意星期5 6 是53天
int week[8]={0,52,52,52,52,53,53,52}; ?
int month[32];
for(int i=1;i<=31;i++){
if(i==30) month[i]=11;
else if(i==31) month[i]=7;
else month[i]=12;
}
while(cin>>t){
gets(str);
if(str[4]=='w') printf("%d\n",week[t]);
else printf("%d\n",month[t]);
}
return 0;
}
喵哈哈村的魔法考试 Round #3 (Div.2)的更多相关文章
- 喵哈哈村的魔法考试 Round #7 (Div.2) 题解
喵哈哈村的魔法考试 Round #7 (Div.2) 注意!后四道题来自于周日的hihocoder offer收割赛第九场. 我建了个群:欢迎加入qscoj交流群,群号码:540667432 大概作为 ...
- 喵哈哈村的魔法考试 Round #2 (Div.2) 题解
喵哈哈村的魔法考试 Round #2 (Div.2) 题解 A.喵哈哈村的战争 题解: 这道题就是for一遍,统计每个村子的战斗力的和,然后统计哪个村子的战斗力和大一点就好了. 唯一的坑点,就是这道题 ...
- 喵哈哈村的魔法考试 Round #1 (Div.2) 题解
喵哈哈村的魔法考试 Round #1 (Div.2) 题解 特别感谢出题人,qscqesze. 也特别感谢测题人Xiper和CS_LYJ1997. 没有他们的付出,就不会有这场比赛. A 喵哈哈村的魔 ...
- 喵哈哈村的魔法考试 Round #1 (Div.2) 题解&源码(A.水+暴力,B.dp+栈)
A.喵哈哈村的魔法石 发布时间: 2017年2月21日 20:05 最后更新: 2017年2月21日 20:06 时间限制: 1000ms 内存限制: 128M 描述 传说喵哈哈村有三种神 ...
- 喵哈哈村的魔法考试 Round #19 (Div.2) 题解
题解: 喵哈哈村的魔力源泉(1) 题解:签到题. 代码: #include<bits/stdc++.h> using namespace std; int main(){ long lon ...
- 喵哈哈村的魔法考试 Round #1 (Div.2)
比赛地址:http://qscoj.cn/contest/2/ 都是中文题,这里不在详述题意 A.喵哈哈村的魔法石 分析:暴力求解 #include<iostream> #include& ...
- 喵哈哈村的魔法考试 Round #1 (Div.2) ABCD
官方题解: http://www.cnblogs.com/qscqesze/p/6418555.html#3623453 喵哈哈村的魔法石 描述 传说喵哈哈村有三种神奇的魔法石:第一种魔法石叫做人铁石 ...
- 喵哈哈村的魔法考试 Round #4 (Div.2) 题解
有任何疑问,可以加我QQ:475517977进行讨论. A 喵哈哈村的嘟嘟熊魔法(1) 题解 这道题我们只要倒着来做就可以了,因为交换杯子是可逆的,我们倒着去模拟一遍就好了. 有个函数叫做swap(a ...
- 喵哈哈村的魔法考试 Round #20 (Div.2) 题解
题解: A 喵哈哈村的跳棋比赛 题解:其实我们要理解题意就好了,画画图看看这个题意.x<y,那么就交换:x>y,那么x=x%y. 如果我们经过很多次,或者y<=0了,那么就会无限循环 ...
- 喵哈哈村的魔法考试 Round #18 (Div.2) 题解
喵哈哈村的古怪石碑(一) 题解:暴力check一下是等比数列还是等差数列,然后输出答案即可.注意如果数据范围是1e9的话,就要快速幂了. 代码: #include <cstdio> #in ...
随机推荐
- 24 Point game
24 Point game 时间限制:3000 ms | 内存限制:65535 KB 难度:5 描述 There is a game which is called 24 Point game ...
- 哈理工 oj 2122 旅行(map + 最短路dij算法)
旅行 Time Limit: 1000 MS Memory Limit: 32768 K Total Submit: 18(6 users) Total Accepted: 3(3 users) Ra ...
- javascript学习笔记(一)-廖雪峰教程
一. 基础 1.for in,for of和forEach 遍历的是对象的属性,因为数组也是对象,其内部的元素的索引就是其属性值.用该方式遍历数组就是获取了数组中的每一个元素的索引值(从0開始). 而 ...
- HDOJ 题目3308 LCIS(线段树,区间查询,区间合并)
LCIS Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submi ...
- UVA - 11077 Find the Permutations (置换)
Sorting is one of the most usedoperations in real life, where Computer Science comes into act. It is ...
- FileCopy文件复制
package cn.com.filecopy; import java.io.FileInputStream; import java.io.FileNotFoundException; impor ...
- BZOJ 4259 FFT
思路: 为什么好多字符串的题都可以用FFT啊.... 我们其实是要判断$\Sigma (a[i]-b[i])^2*a[i]*b[i]==0$ 那就把a串翻转过来 把 上式展开 大力做几遍FFT就好啦~ ...
- tomcat 启动服务器日志小结
1.tomcat 启动服务配置: 目前主要有 ①把编译好war或者项目直接扔到webapps 目录下, 启动bin目录下的startup.bat 即可 ② 在conf目录下 修改 serve ...
- PHP开发笔记(二)PHP的json_encode和json_decode问题
解决PHP的json_encode问题之前,先了解一下PHP预定义常量http://php.net/manual/zh/json.constants.php. 用PHP的json_encode来处理中 ...
- Nagios Windows客户端NSClient++ 0.4.x安装配置
NSClient++ 0.3.x和NSClient++ 0.4.x的配置完全不一样,官方的文档也没有全部更新.我记录下自己的一些操作. 一.下载安装NSClient++ 1.到http://nsc ...