A.直接模拟。

#include<bits/stdc++.h>
using namespace std; int c,v0,v1,a,l; int main()
{
ios::sync_with_stdio();
cin >> c >> v0 >> v1 >> a >> l;
int ans = ,now = l,v = v0-a;
while()
{
ans++;
now -= l;
v += a;
if(v > v1) v = v1;
now += v;
if(now >= c) break;
}
cout << ans << endl;
return ;
}

B.相等弧长对应的圆周角相等。圆周角是对应圆心角的一半。

#include<bits/stdc++.h>
using namespace std; int n,a; int main()
{
ios::sync_with_stdio();
cin >> n >> a;
double t = 180.0/n;
int ans;
double minn = ;
for(int i = ;i <= n-;i++)
{
if(abs(i*t-a) < minn)
{
ans = i+;
minn = abs(i*t-a);
}
}
cout << "2 1 " << ans << endl;
return ;
}

D.统计数值大于等于位置的个数和数值小于位置的个数,以及每个偏差值的个数,每次向右移动的时候,可以O(1)更新答案,注意每次更新三个计数。

#include<bits/stdc++.h>
using namespace std; int n,a[],cnt[]; int main()
{
ios::sync_with_stdio();
cin >> n;
for(int i = ;i <= n;i++) cin >> a[i];
long long sum = ,cntl = ,cntr = ;
for(int i = ;i <= n;i++)
{
sum += abs(a[i]-i);
if(a[i] >= i)
{
cntl++;
cnt[a[i]-i]++;
}
else cntr++;
}
long long ans = sum;
int num = ;
for(int i = ;i < n;i++)
{
cntl -= cnt[i-];
cntr += cnt[i-];
sum = sum-cntl+cntr-abs(a[n-i+]-n-)+abs(a[n-i+]-);
if(a[n-i+]+i- < n) cnt[a[n-i+]+i-]++;
cntl++;
cntr--;
if(sum < ans)
{
ans = sum;
num = i;
}
}
cout << ans << " " << num << endl;
return ;
}

最新文章

  1. Bugtags 2016-10-17 更新内容
  2. 8、需求分析师要阅读的书籍 - IT软件人员书籍系列文章
  3. 【软件工程实践一】git使用心得
  4. A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list.
  5. 第三百五十一天 how can I 坚持
  6. 常用mysql命令大全
  7. struts中的helloword(1)
  8. SQLite的SQL语法
  9. Android-x86 4.4-r5 发布,PC 上的安卓系统
  10. Sipdroid实现SIP(三): 消息接收处理
  11. 转载:数位DP模板
  12. 老帖收藏,留供参考:SpringMvc2.5+Mybatis3.2.7
  13. Linux 文件/文件夹无法删除问题解决方案
  14. Fiddler-抓取手机app请求
  15. 20165220 mybash
  16. awk、sed、date命令使用
  17. Kotlin 对象表达式和对象声明
  18. IntelliJ IDEA mybatis-generator的使用
  19. |ERROR|ERROR: missing data for column &quot;createtime&quot; (seg3 slice1 192.168.66.23:40001 pid=33370)之mysql换行符或者空格引起的问题
  20. maven 学习

热门文章

  1. 小小知识点(四十九)——SCMA
  2. PTC热敏电阻的应用
  3. echarts圆饼图设置默认选中项并在中间显示文字
  4. 1z0-062 题库解析4
  5. Java 用集合实现简单的斗地主发牌
  6. transient简介
  7. 关于爬虫的日常复习(10)—— 实战:使用selenium模拟浏览器爬取淘宝美食
  8. Vmware Ubuntu18.04更换清华源
  9. 网络通信-基本概念:网络、IP地址、端口、socket
  10. Oracle GoldenGate for DB2