P4397 [JLOI2014] clever swallow posture

Source: Internet
Author: User

P4397 [JLOI2014] Smart Yan-Pose topic background
阴天傍晚车窗外未来有一个人在等待向左向右向前看爱要拐几个弯才来我遇见谁会有怎样的对白我等的人他在多远的未来我听见风来自地铁和人海我排着队拿着爱的号码牌
Title Description

People in the city always hold the number card, keep looking for, constantly match, but who does not know oneself wait for that person is who.

But the Yan posture is not the same, Stef know oneself waits for who, because Stef Mathematics study good! Stef found a magic algorithm: assuming that their number card is written on the number \ (s\), then the number of people on their own hands on the numbers of all positive sum must be equal to \ (s\).

So Stef always take the number card in the subway and the crowd to find numbers (Hello!) Is this really true? But she's busy singing green light, and I want to ask you to write a program that can quickly find all of your own people.

Input output Format input format:

Input contains \ (k\) group data. For each set of data, the input contains a number plate \ (s\).

Output format:

For each set of data, the output has two lines, the first line contains an integer \ (m\), which indicates that there are people such as \ (m\) .

The second line contains the corresponding number of \ (m\) , which represents all the other people's card.

Note: The number cards you output must be in ascending order.

Description

For \ (100\%\) data,\ (k \le 100\), \ (S \le 2 \times 10^9\)?? 。

Unique decomposition

\ (S=\prod p_i^{c^i}\)

Approximate and \ (\sigma (S) =\prod \sum_{i=0}^{c^i} p_i^i\)

You can then search directly for \ (c\) and \ (p\)

Note that some boundary conditions can be

Code:

#include <cstdio> #include <algorithm>const int n=1e7;int pri[n+10],ispri[n+10],cnt,k,tot,s[n];void init (        {for (int i=2;i<=n;i++) {if (!ispri[i]) pri[++cnt]=i;            for (int j=1;j<=cnt&&pri[j]*i<=n;j++) {ispri[pri[j]*i]=1;        if (i%pri[j]==0) break;    }}}bool Check (int p,int dep) {if (p<=n) return!ispri[p]&&p>=pri[dep];    for (int i=1;pri[i]<=46340&&pri[i]*pri[i]<=p;i++) if (p%pri[i]==0) return false; return true;}    void Dfs (int res,int dep,int num) {if (res==1) {S[++tot]=num;return;}    if (check (RES-1,DEP)) Dfs (1,DEP, (res-1) *num);    if (RES&LT;PRI[DEP]*PRI[DEP]) return;    DFS (Res,dep+1,num);    int PO=PRI[DEP]+1,HMI=PRI[DEP];            while (po<=res) {if (res%po!=0) {PO=PO*PRI[DEP]+1,HMI*=PRI[DEP];        Continue        } dfs (RES/PO,DEP+1,NUM*HMI);        if (po>46340) break;    PO=PO*PRI[DEP]+1,HMI*=PRI[DEP]; }}int Main () {init ();        while (scanf ("%d", &k)!=eof) {tot=0;        DFS (k,1,1);        Std::sort (S+1,s+1+tot);        Tot=std::unique (S+1,s+1+tot)-s-1;        printf ("%d\n", tot);        for (int i=1;i<=tot;i++) printf ("%d", s[i]);    if (tot) printf ("\ n"); } return 0;}

2018.10.10

P4397 [JLOI2014] clever swallow posture

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.