1005 ——CaoHaha's staff
来源:互联网 发布:淘宝店铺网名昵称大全 编辑:程序博客网 时间:2024/05/29 18:25
CaoHaha's staff
官方题解:
比赛的时候没有找出来,或者说是找错了,反正每次找规律都找不到,
菜啊啊啊啊啊啊啊
先讲一下自己的思路吧!
先画一个八条边组成的面积为4 的正方形为基础,然后每次都扩展一个面积为2 的正方形。
然后错了,正确的思路是扩展一个 梯形 。
正确思路:
点击打开链接
#pragma comment(linker, "/STACK:1024000000,1024000000")#include<string>#include<cstdio>#include<cstring>#include<cmath>#include<iostream>#include<queue>#include<stack>#include<vector>#include<algorithm>//#include <bits/stdc++.h>#define maxn 10010using namespace std;int a[10]={0,4,4,6,6,7,8,8,8};int main(){ int T; int n; scanf("%d",&T); while(T--) { scanf("%d",&n); if(n<=8) { printf("%d\n",a[n]); continue; } int x=floor(sqrt(n/2)); int cnt=x*x*2; if(cnt==n) printf("%d\n",4*x); else if(cnt+x-0.5>=n) printf("%d\n",4*x+1); else if(cnt+x*2>=n) printf("%d\n",4*x+2); else if(cnt+3*x+0.5>=n) printf("%d\n",4*x+3); else printf("%d\n",4*x+4); } return 0;}
阅读全文
0 0
- 1005 ——CaoHaha's staff
- 2017ccpc网络赛——CaoHaha's staff
- 几何图形找规律——CaoHaha's staff
- CCPC2017网络赛1005 CaoHaha's staff——找规律
- HDU CCPC 1005 CaoHaha's staff
- 2017ccpc网赛-1005-CaoHaha's staff
- ccpc预选赛-1005CaoHaha's staff
- CaoHaha's staff
- HDU_6154 CaoHaha's staff
- CaoHaha's staff
- HDU6154-CaoHaha's staff
- hdu-CaoHaha's staff
- hdu6154 CaoHaha's staff
- HDU 6154 CaoHaha's staff
- CaoHaha's staff(hdoj6154)
- Hdu 6154 CaoHaha's staff
- HDU 6154 CaoHaha's staff
- HDU 6154 CaoHaha's staff
- JS中的浏览器对象
- JavaScript文档DOM增删操作
- web前端面试题
- maven配置错误,提示java_home is set to an invalid directory.
- 网络赛,HDU6153《KMP》
- 1005 ——CaoHaha's staff
- effective C++ 条款八解读
- 总结
- HDU
- 【ADO】浅识“EOF与BOF”
- MOOC清华《面向对象程序设计》第3章编程题第1题:重载函数运算符以封装排序算法
- ES6之-字符串的新特性
- HDU
- 人生苦短,少打游戏