当前位置:网站首页>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
边栏推荐
- Modification du contenu de la recherche dans la boîte déroulante par PHP + MySQL
- Win view port occupation command line
- First day of rhcsa
- Difference between relative path and absolute path (often asked in interview)
- Chapter VI project information management system summary
- ROP Emporium x86_ 64 7 ~ 8 questions
- Codeforces round 784 (Div. 4) (a - H)
- [hcip] detailed explanation of six LSAS commonly used by OSPF
- Codeforces Round #784 (Div. 4) (A - H)题解
- Specific field information of MySQL export table (detailed operation of Navicat client)
猜你喜欢

Interpretation of the future development of smart agriculture

First knowledge of C language ~ branch statements

Flink stream processing engine system learning (II)

Domestic lightweight Kanban scrum agile project management tool

Rhcsa day 1 operation

Implementation of distributed scenario business operation log (based on redis lightweight)

ROP Emporium x86_64 7~8题

C language 171 Number of recent palindromes

The way to conquer C language

Six very 6 computer driver managers: what software is good for driver upgrade? Recommended by the best computer driver management software abroad
随机推荐
OCR识别PDF文件
Close the computer port
Specific field information of MySQL export table (detailed operation of Navicat client)
重大危险源企业如何保障年底前完成双预防机制数字化建设任务
JVM runtime data area (I)
Processes and threads
《信息系统项目管理师总结》第四章 项目成本管理
The express project changes the jade template to art template
Chapter VI project information management system summary
Log4j knowledge point record
Kubernetes - detailed explanation of pod
工业互联网+危化安全生产综合管理平台怎样建
Six very 6 computer driver managers: what software is good for driver upgrade? Recommended by the best computer driver management software abroad
Step principle of logical regression in machine learning
Implementation of distributed scenario business operation log (based on redis lightweight)
《信息系统项目管理师总结》第六章 项目人力资源管理
[wechat applet] set the bottom menu (tabbar) for the applet
@Usage and difference between mapper and @ repository
Interim summary (Introduction + application layer + transportation layer)
Linux redis - redis database caching service