`
java-mans
  • 浏览: 11438096 次
文章分类
社区版块
存档分类
最新评论

CF #109 div2 D题 Colliders

 
阅读更多

这道题应该算是简单题了。不过我写的太暴力,超时了。。。

参考了别人的想法,先用最暴力的筛法,把每个数最小的质因子记录下来。然后开10W个set,每次操作,如果要插入一个数x,如果没有冲突,往里加的时候,对每个他的质因子p,将x插入set[p]中,判断冲突的方法也类似,对每个他的质因子,如果质因子的set不为空,说明有冲突,将set中的第一个元素输出即可,然后删除操作的时候则是set自带的erase操作。


/*
ID: sdj22251
PROG: subset
LANG: C++
*/
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <map>
#include <string>
#include <cstring>
#include <cmath>
#include <ctime>
#define MAXN 100005
#define INF 1000000000
#define eps 1e-7
#define L(x) x<<1
#define R(x) x<<1|1
#define mod 1000000007
using namespace std;
int p[MAXN];
int in[MAXN];
set<int>fk[MAXN];
void ready()
{
    p[1] = 1;
    for(int i = 2; i <= 100000; i++)
    {
        if(!p[i])
        {
            for(int j = i + i; j <= 100000; j += i)
                if(!p[j]) p[j] = i;
        }
    }
    for(int i = 2; i <= 100000; i++)
        if(!p[i]) p[i] = i;
}
int main()
{
    ready();
    int n, m, x;
    char ss[5];
    scanf("%d%d", &n, &m);
    while(m--)
    {
        scanf("%s%d", ss, &x);
        if(ss[0] == '+')
        {
            if(in[x])
            {
                printf("Already on\n");
            }
            else
            {
                int fg = 0;
                for(int t = x; t != 1 ; t /= p[t])
                    if(fk[p[t]].size() > 0)
                    {
                        fg = *fk[p[t]].begin();
                        break;
                    }
                if(fg) printf("Conflict with %d\n", fg);
                else
                {
                    for(int t = x; t != 1 ; t /= p[t])
                        fk[p[t]].insert(x);
                    printf("Success\n");
                    in[x] = 1;
                }

            }
        }
        else
        {
            if(!in[x]) printf("Already off\n");
            else
            {
                for(int t = x; t != 1 ; t /= p[t])
                    fk[p[t]].erase(x);
                printf("Success\n");
                in[x] = 0;
            }
        }
    }
    return 0;
}


分享到:
评论

相关推荐

    【Unity3D 插件】 2D平台动作游戏插件 Smart Platform Colliders 1.1.4.3.unitypackage

    Unity3D 插件 2D平台动作游戏插件 Smart Platform Colliders 1.1.4.3.unitypackage

    Navigation2D Pathfinding for 2D Games.unitypackage

    2. Go to Navigation2D, select Bake 3. Use NavMeshAgent2D to move Components: * Uses built in BoxCollider2D * Uses built in CircleCollider2D * Uses built in EdgeCollider2D * Uses built in ...

    PyPI 官网下载 | pygame_colliders-0.1.2-py3-none-any.whl

    资源来自pypi官网。 资源全名:pygame_colliders-0.1.2-py3-none-any.whl

    在未来的ep colliders上寻找类似轴突的粒子

    我们探索了通过子过程e-γ→e-a→e-γγ在未来的ep碰撞器上搜索轴突样粒子(ALP)的可能性。 对于LHeC及其高能升级产品FCC-eh,可获得有效质量为10 GeV &lt;Ma &lt;3 TeV的有效ALP-光子耦合gaγγ的灵敏度。...

    threex.colliders:处理碰撞体的 Three.js 游戏扩展

    3threex.colliders Threex.colliders 是。 它提供了一个对撞机系统。 每个THREE.Object3D可以附加到 AABB 的THREEx.Collider 。 如果时间允许,将添加球体。 然后将它们添加到THREEx.ColliderSystem和....

    Easy collider editor 2.5

    Easy collider editor is designed to facilitate the creation of 3D primitive colliders. By using primitive colliders instead of mesh colliders, rigidbodies can be added to gameobjects to allow for ...

    UnityAssets - Ferr2D Terrain Tool v1.0.9

    Ferr2D Terrain Tool lets you quickly create hand-crafted 2D/2.5D landscapes and levels! No tile-sets, no placing tons of objects, no manually tweaking piles of collider objects, just pick a terrain ...

    Technie Collider Creator 1.9

    The Technie Collider Creator lets you quickly create accurate colliders for the most awkwardly shaped objects. Simple, Intuitive Workflow Just select your object and start painting what you want ...

    Prefab Painter 2 2.6

    Prefab Painter 2 2.6版本 Features: - Place/Erase/Select objects - Precise place objects - Place decals - Align to Surface - Align to Stroke - Randomized scale - Randomized rotation - Paint on chosen ...

    SmoothMoves

    •Set colliders on bones to activate at specific keyframes •Set user triggers to activate sounds or other events •Animations use texture atlases to reduce draw calls •Create sprites for other props...

    Sensor Toolkit v1.6.5

    It's a convenient abstraction on top of Unity's basic sensing functionality, such as ray casts or trigger colliders, but with many advantages. It's lightweight, has advanced features and is ...

    Learning Unity Physics

    Chapter 2, Using Different Colliders for Interaction, focuses on colliders, their types in Unity3D, and how we can define the collision shape of objects in a scene. Chapter 3, Overview of Collision ...

    SensorToolkit 2 v2.5.13.unitypackage

    SensorToolkit 是对内置 Unity 函数(如 Raycasts、Overlaps 和 Trigger Colliders)的强大抽象。您可以向游戏对象添加独立的传感器组件,并根据需要对其进行配置。可以查询传感器以确定它们检测到的内容并提供其他...

    Dynamic Bone 1.20 制作ru摇臀摇头发尾巴摆动的方便插件

    导入包里有演示,模型导入装配什么的就不说了。...3.Colliders放入要进行碰撞的骨骼数组,该骨骼上要放上DynamicBoneCollider组建。 其他的参数都很简单,一看就知道怎么用了,这个插件东西不多但是效果不错,很好用。

    Python库 | type_valid-0.1.2-py3-none-any.whl

    python库,解压后可用。 资源全名:type_valid-0.1.2-py3-none-any.whl

    e + e-撞机处J /ψπ产生的与动量有关的胶子碎裂函数

    提出了在e + e-colliders上背靠背的J /ψ和π关联产生来检测胶子横向动量相关(TMD)断裂功能的方法。 此过程假定为TMD分解。 利用无旋子介子,可以定义非极化和线性极化的胶子TMD断裂功能。 发现在部分水平上强子...

    Unity插件Easy Collider Editor 4.1.zip

    By using primitive colliders instead of mesh colliders, rigidbodies can be added to gameobjects to allow for physics interactions. No more painfully adding primitive colliders and positioning and ...

    SmoothMoves 2.4.0

    - Use colliders and triggers to fire events in your code - Use multiple materials per character - Each bone creates a quad resulting in low vertex count - Produces a skinned mesh so you can use your ...

    高能电子对撞机在鹿角拓扑过程中的自旋和手性效应

    我们在高能e + e-colliders上对鹿角-拓扑过程e + e-→P + P-→(ℓ+ D0)(ℓ-D¯0)进行自旋和手性相关效应的模型独立研究 偏振光束。 通常,生产过程e + e-→P + P-不仅可以通过矢量玻色子V0的s通道交换而发生,...

Global site tag (gtag.js) - Google Analytics