当前位置:网站首页>Niuke white moon race 5 [problem solving mathematics field]
Niuke white moon race 5 [problem solving mathematics field]
2022-04-23 02:55:00 【Hui Xiaoge】
The mathematical field
https://ac.nowcoder.com/acm/contest/135#question
Catalog
- irrelevant (relationship)【 A class 】
- Range (range)【 Can't 】
- Water problem (water)【 Can't 】
- Factorial (factorial)【 thinking At the end of 0 The number of 】
- area (area)【 Can't 】
- round (circle)【n Points divide the circle into parts 】
- Exclusive or (xor)
- greatest common divisor (lcm)
- Section (interval)【 Difference 】
- Time (time)【 simulation 】
irrelevant (relationship)【 A class 】
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const int N=25;
LL l,r,n,a[N];
LL solve(LL x)
{
LL sum=0;
for(int i=1;i<(1<<n);i++)
{
LL temp=x,cnt=-1;
for(int j=0;j<n;j++)
{
if((i>>j)&1==1) temp/=a[j],cnt=cnt*(-1);
}
sum=sum+cnt*temp;
}
return x-sum;
}
int main(void)
{
cin>>l>>r>>n;
for(int i=0;i<n;i++) cin>>a[i];
cout<<solve(r)-solve(l-1);
return 0;
}
Range (range)【 Can't 】
Water problem (water)【 Can't 】
Factorial (factorial)【 thinking At the end of 0 The number of 】
2*5==10 2 The number of must be greater than 5 The number of . Therefore, it is to seek 5 The number of .
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
LL sum,n,cnt;
int main(void)
{
cin>>n;
for(int i=1;i<=n;i++)
{
int j=i;
while(j%5==0) cnt++,j/=5;
sum+=cnt;
}
cout<<sum;
return 0;
}
area (area)【 Can't 】
round (circle)【n Points divide the circle into parts 】
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
int main(void)
{
LL n;
while(cin>>n)
{
LL sum=0;
if(n>=4) sum+=n*(n-1)*(n-2)*(n-3)/4/3/2;
if(n>=2) sum+=n*(n-1)/2;
sum++;
cout<<sum<<endl;
}
return 0;
}
Exclusive or (xor)
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
LL n;
int main(void)
{
while(scanf("%lld",&n)!=-1) printf("%lld\n",n/3*2+n%3);
return 0;
}
greatest common divisor (lcm)
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
LL gcd(LL a,LL b){
return b?gcd(b,a%b):a;}
int main(void)
{
LL a,b; cin>>a>>b;
cout<<a/gcd(a,b)*b;
return 0;
}
Section (interval)【 Difference 】
#include<bits/stdc++.h>
using namespace std;
const int N=1e6*3+10;
typedef long long int LL;
LL n,m,x,a[N];
void add(int l,int r,int x)
{
a[l]+=x;
a[r+1]-=x;
}
int main(void)
{
cin>>n>>m;
for(int i=1;i<=n;i++) cin>>x,add(i,i,x);
while(m--)
{
LL op,l,r,p; cin>>op>>l>>r>>p;
if(op!=1) add(l,r,p);
else add(l,r,-p);
}
for(int i=1;i<=n;i++) a[i]+=a[i-1];
LL sum=0,l,r;
cin>>l>>r;
for(int i=l;i<=r;i++) sum+=a[i];
cout<<sum<<endl;
return 0;
}
Time (time)【 simulation 】
#include<bits/stdc++.h>
using namespace std;
bool check(int x,int y)
{
int a1=x/10,a2=x%10;
int b2=y/10,b1=y%10;
if(a1==b1&&a2==b2) return true;
return false;
}
int main(void)
{
string s; cin>>s;
int a,b;
a=stoi(s.substr(0,s.find(':')));
b=stoi(s.substr(s.find(':')+1));
int x=0,y=0;
for(int i=0,j=0;;j++)
{
if(j==60) j=0,i++;
if(i==a&&j==b) break;
if(check(i,j)) x=i,y=j;
}
printf("%d:%d\n",x,y);
x=0,y=0;
for(int i=a,j=b+1;;j++)
{
if(j==60) j=0,i++;
if(i==24) break;
if(check(i,j))
{
x=i,y=j;
break;
}
}
printf("%d:%d\n",x,y);
return 0;
}
版权声明
本文为[Hui Xiaoge]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220657494962.html
边栏推荐
- C语言 171. 最近回文数
- JS relearning
- [learn junit5 from official documents] [II] [writingtests] [learning notes]
- Chapter V project quality management of information system project manager summary
- Specific field information of MySQL export table (detailed operation of Navicat client)
- 《信息系统项目管理师总结》第七章 项目沟通管理
- TypeScript(1)
- L2-006 树的遍历(中后序确定二叉树&层序遍历)
- @Usage and difference between mapper and @ repository
- C language 171 Number of recent palindromes
猜你喜欢
ROP Emporium x86_64 7~8题
The input of El input input box is invalid, and error in data(): "referenceerror: El is not defined“
Flink stream processing engine system learning (III)
Huawei machine test question -- deformation of hj53 Yang Hui triangle
Windows MySQL 8 zip installation
First knowledge of C language ~ branch statements
Huashu "deep learning" and code implementation: 01 Linear Algebra: basic concepts + code implementation basic operations
Intelligent agricultural management model
JS learning notes
Interpretation of the future development of smart agriculture
随机推荐
php+mysql对下拉框搜索的内容修改
《信息系统项目管理师总结》第七章 项目沟通管理
基于多态的职工管理系统源码与一些理解
Windows MySQL 8 zip installation
Slave should be able to synchronize with the master in tests/integration/replication-psync.tcl
Flink learning (XI) watermark
Face longitude:
VirtualBox virtual machine (Oracle VM)
Win view port occupation command line
Essential qualities of advanced programmers
[learn junit5 from official documents] [II] [writingtests] [learning notes]
mysql function函数语法
MySQL / SQL Server判断表或临时表存在则删除
Specific field information of MySQL export table (detailed operation of Navicat client)
Airtrack cracking wireless network password (Dictionary running method)
Modify the content of MySQL + PHP drop-down box
grain rain
Linux redis - redis ha sentinel cluster construction details & redis master-slave deployment
学习正则表达式选项、断言
Kubernetes - Introduction to actual combat