x+2y+3z=n非负整数解
2024-08-30 11:10:41
#include <iostream>
#include <string.h>
#include <stdio.h> using namespace std;
typedef long long LL; LL work(LL n)
{
LL ans = ;
for(int k = ; k <= n / ; k++)
ans += (n - * k) / + ;
return ans;
} int main()
{
LL n;
while(cin>>n)
cout<<work(n)<<endl;
return ;
}
#include <iostream>
#include <string.h>
#include <stdio.h> using namespace std;
typedef long long LL; LL work(LL n)
{
LL k = n / ;
LL t = (k + ) * n - * k * (k + ) / ;
LL ans = k + ;
if(k & ) t -= (k + ) / ;
else if(n & ) t -= (k / + );
else t -= k / ;
t >>= ;
return ans + t;
} int main()
{
LL n;
while(cin>>n)
cout << work(n) << endl;
return ;
}
最新文章
- Docker搭建Java Web运行环境
- 自我反思--table的简单数据分页
- flash cs6导入某些mp3不能的解决办法
- [uboot]E9-i.MX6Q-uboot移植
- python 循环定时器
- POI Excel导出样式设置
- ubuntu ll命令
- PL/SQL database character set(AL32UTF8) and Client character set(ZHS16GBK) are different
- 将 Android* x86 NDK 供 Eclipse* 而移植 NDK 演示示例应用程序
- python 数据驱动(ddt)
- LeetCode第[15]题(Java):3Sum 标签:Array
- 备忘录之 —— .bashrc(IC工具篇)
- 测者的性能测试手册:JVM的监控利器
- PageHelper 自动去掉排序参数问题
- Vmware Workstation添加centos 7系统网络问题(无IP情况)
- [luogu4005]小Y和地铁【搜索+树状数组】
- Maven教程3(依赖管理)
- php中cal_days_in_month不可用时的替代方法(计算一个月的天数)
- 力扣(LeetCode) 905. 按奇偶排序数组
- Spring源码解析 - ListableBeanFactory