Atcoder Regular 099 暴力区间扩张 n/dig(n)极值打表 团分割背包
2024-09-03 04:45:36
C
直接把第一次加在哪里for一遍即可
/*Huyyt*/
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
const int mod = 1e9 + , gakki = + + + + 1e9;
const int MAXN = 2e5 + , MAXM = 2e5 + , N = 2e5 + ;
const int MAXQ = ;
/*int to[MAXM << 1], nxt[MAXM << 1], Head[MAXN], tot = 1;
inline void addedge(int u, int v)
{
to[++tot] = v;
nxt[tot] = Head[u];
Head[u] = tot;
}*/
inline void read(int &v)
{
v = ;
char c = ;
int p = ;
while (c < '' || c > '')
{
if (c == '-')
{
p = -;
}
c = getchar();
}
while (c >= '' && c <= '')
{
v = (v << ) + (v << ) + c - '';
c = getchar();
}
v *= p;
}
int num[];
int main()
{
int n;
int k;
int minn = INT_MAX;
int aim;
read(n), read(k);
for (int i = ; i <= n; i++)
{
read(num[i]);
if (num[i] < minn)
{
minn = num[i];
aim = i;
}
}
int ans = ;
ans = INT_MAX;
int anser = ;
for (int laim = max(, aim - k + ); laim <= aim; laim++)
{
int raim = min(n, laim + k - );
anser = ;
if ((laim - ) % (k - ))
{
anser++;
}
anser += (laim - ) / (k - );
if ((n - raim) % (k - ))
{
anser++;
}
anser += (n - raim) / (k - );
ans = min(ans, anser);
}
cout << ans << endl;
return ;
}
正解:
scanf("%d%d",&n,&k);
printf("%d\n",(n-)/(k-)+);
(直接(n-1)/(k-1)向上取整即可 感觉自己是个弱智
D
打表找规律
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
double Snuke(ll x)
{
ll tmp = , c = x;
while (c)
{
tmp += c % ;
c /= ;
}
return 1.0 * x / tmp;
}
int main()
{
int K;
cin >> K;
ll res = , x = ;
while (K--)
{
double t1, t2;
while (true)
{
t1 = Snuke(res + x), t2 = Snuke(res + x * );
if (t1 <= t2)
{
break;
}
x *= ;
}
res += x;
printf("%lld\n", res);
}
return ;
}
E
背包
最新文章
- R语言 三个函数sort();rank();order()
- Android Studio 打包签名发布New Key Store
- Oracle 安装后关于用户
- mac下用ruby安装sass &;&; webstorm下给scss文件添加watch
- UI特效--Android利用ViewFlipper实现屏幕切换动画效果
- 如何优化 Android Studio 启动、编译和运行速度?
- ASP.NET MVC概述
- 自动生成XML空节点格式的差异
- hibernate 插入数据时让数据库默认值生效
- 用python进行应用程序自动化测试(uiautomation)
- 【PAT】 B1006 换个格式输出整数
- byte[] 解析、转码二三事
- 安卓开发-设置RadioButton的点击效果
- robots.txt、humans.txt、.editorconfig、.gitignore、LICENSE.txt、README.md、CHANGLOG.md
- opencv-Python---动态人脸捕捉
- 删除N天前的备份文件脚本(windows)
- Java-性能调优实战(jps、jstack)
- [How to]使用自定义cell进行tableview的创建,适用于cell样式不发生变化的情况。
- hive自带的字符串函数
- BZOJ4654/UOJ223 [Noi2016]国王饮水记
热门文章
- SQL Server 等待统计信息基线收集
- &#39;caching_sha2_password&#39; cannot be loaded
- python学习之数据类型(int,bool,str)
- web题
- Analysis Methods in Neural Language Processing: A Survey
- MSSQL 索引
- C++练习 | 不使用头插法逆转单链表
- 从入门到自闭之Python名称空间
- k8s 1.9安装
- Codeforces 1221E. Game With String