Codeforces Round #395 (Div. 2) A

Description

Comrade Dujikov is busy choosing artists for Timofey's birthday and is recieving calls from Taymyr from Ilia-alpinist.

Ilia-alpinist calls every n minutes, i.e. in minutes n2n3n and so on. Artists come to the comrade every m minutes, i.e. in minutes m2m3m and so on. The day is z minutes long, i.e. the day consists of minutes 1, 2, ..., z. How many artists should be killed so that there are no artists in the room when Ilia calls? Consider that a call and a talk with an artist take exactly one minute.

Input

The only string contains three integers — nm and z (1 ≤ n, m, z ≤ 104).

Output

Print single integer — the minimum number of artists that should be killed so that there are no artists in the room when Ilia calls.

Examples
input
1 1 10
output
10
input
1 2 5
output
2
input
2 3 9
output
1
Note

Taymyr is a place in the north of Russia.

In the first test the artists come each minute, as well as the calls, so we need to kill all of them.

In the second test we need to kill artists which come on the second and the fourth minutes.

In the third test — only the artist which comes on the sixth minute.

题意:问1-z内,n*1,n*2,n*3...m*1,m*2...它们相同的有多少个

解法:那就。。保存一下再记录就好了,其实可以直接算出来

复制代码
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    map<int,int>q,p;
    map<int,int>::iterator it;
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=1;i<=c;i++)
    {
        if(i*a>c) break;
        q[i*a]=1;
    }
    int sum=0;
    for(int i=1;i<=c;i++)
    {
        if(i*b>c) break;
        if(q[i*b]==1)
        {
            sum++;
        }
    }
    cout<<sum<<endl;
    return 0;
}
复制代码

 

posted @   樱花落舞  阅读(213)  评论(0编辑  收藏  举报
编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示