51Nod——N1284 2 3 5 7的倍数
2024-08-31 19:00:39
https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1284
基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题
收藏
关注
给出一个数N,求1至N中,有多少个数不是2 3 5 7的倍数。 例如N = 10,只有1不是2 3 5 7的倍数。
Input
输入1个数N(1 <= N <= 10^18)。
Output
输出不是2 3 5 7的倍数的数共有多少。
Input示例
10
Output示例
1 容斥原理
#include <cstdio> #define LL long long using namespace std; LL n,tot; int main()
{
scanf("%lld",&n);
tot=(LL)n/+n/+n/+n/;
tot-=(LL)(n/+n/+n/+n/+n/+n/);
tot+=(LL)n/+n/+n/+n/;
tot-=(LL)(n/);
printf("%lld",n-tot);
return ;
}
最新文章
- CSS margin详解
- Spring Boot整合Activiti,查看流程图出现中文乱码问题
- cassandra 环境搭建
- 【USACO】beads
- LINQ之路 4:LINQ方法语法
- The Network Adapter could not establish the connection问题研究
- C盘清理大作战
- Exam 70-462 Administering Microsoft SQL Server 2012 Databases 复习帖
- [转] Transitions: Going from Shots to the Insulin Pump
- java泛型编程
- CDT+Eclipse代码自动提示
- javascript事件小结(事件处理程序方式)--javascript高级程序设计笔记
- HTML系列(八):表格
- ASP.NET MVC 5 学习教程:生成的代码详解
- Darwin Streaming Server 安装流程
- 软件性能测试技术树(二)----Linux服务器性能
- 系统重装助手教你如何在Microsoft Edge中恢复“关闭所有选项卡”警告
- python3 网页下拉框和悬浮框操作基础汇总
- JAVA记录-消息队列介绍
- android-------Android Studio使用MAT分析工具遇到的错误
热门文章
- Android学习笔记(23):列表项的容器—AdapterView的子类们
- selection-内容选中跟光标移动
- .Net数据操作案例
- 最短路 spfa, dijkstra, Floyd
- Entity Framework的原理及使用方式
- java种instanceof方法和getclass方法的区别
- vue2.0 transition用法
- 【hihocoder 1122】二分图二•二分图最大匹配之匈牙利算法
- ActiveMQ学习总结(3)——spring整合ActiveMQ
- 下载编译 Android wear 源代码,尝试制作可穿戴设备功能