码迷,mamicode.com
首页 > 其他好文 > 详细

少女折寿中

时间:2017-08-08 23:00:05      阅读:382      评论:0      收藏:0      [点我收藏+]

标签:stat   get   getc   prot   word   优化   eof   long   turn   

 

 

 

 

/*
        快速乘法        
*/
#include <cstdio>
#include <iostream>

void read (long long &now)
{
    register char word = getchar ();
    for (now = 0; !isdigit (word); word = getchar ());
    for (; isdigit (word); )
    {
        now = (now << 1) + (now << 3) + word - 0;
        word = getchar ();
    }
}

long long Mod = 10000;
    
struct Mul
{
    protected : long long x;
        
    public : long long operator * (Mul now) const
    {
        long long res = 0, pos = this->x;
        
        pos = pos % Mod;
        now.x = now.x % Mod;
        
        for (; now.x; now.x >>= 1)
        {
            if (now.x & 1)
                res = (res + pos) % Mod;
            pos = (pos + pos) % Mod;
        }
        return res;
    }
    
    public : long long operator = (const int &now)
    {
        x = now;
    }
};
    
Mul A, B;
    
int main ()
{
    long long a, b;
    read (a);
    read (b);
    A = a;
    B = b;
    printf ("%lld", A * B);
}

 

 

 

/*
        O(1)快速乘
*/
#include <cstdio> 

long long Mod = 100;

struct Int
{
    long long x;
    
    long long operator * (Int now) const
    {
        long long res = (this->x * now.x - (long long)((long 

long)this->x / Mod * now.x + 1.0e-8) * Mod);
        return res < 0 ? res + Mod : res;
    }
};

int main ()
{
    Int a, b;
    a.x = 200;
    b.x = 3;
    printf ("%lld", a * b);

}

 

 

 

/*
        IO读入优化
*/
#include <iostream>
#include <cstdio>
/*
void read (int &now)
{
    register char word = getchar ();
    for (now = 0; !std :: isdigit (word); word = getchar ());
    for (; std :: isdigit (word); now = now * 10 + word - ‘0‘, word = getchar ());
}*/

inline char getcha ()
{
    static char buf[100000], *pos_1 = buf, *pos_2 = buf;
    return pos_1 == pos_2 && (pos_2 = (pos_1 = buf) + fread (buf, 1, 100000, stdin), pos_1 == pos_2) ? EOF : *pos_1 ++;
}
inline int read (int &now)
{
    register char word = getcha ();
    for (now = 0; !std :: isdigit (word); word = getcha ());
    for (; isdigit (word); now = now * 10 + word - 0, word = getcha ());
}

int main (int argc, char *argv[])
{
    freopen ("1.in", "r", stdin);
    int N;
    read (N);
    read (N);
    read (N);
    printf ("%d", N);

    return 0;
}

 

少女折寿中

标签:stat   get   getc   prot   word   优化   eof   long   turn   

原文地址:http://www.cnblogs.com/ZlycerQan/p/7309231.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!