zoukankan      html  css  js  c++  java
  • 上午小测1「木板」

    上午小测1「木板」

    题目大意

    题干

    分析

    简单推论

    老数学题了,直接开搞:

    [设 ;BE = x,CE = n - x, CF = y, angle AEF = 90^{circ} ]

    [ecause Delta ABE sim Delta ECF ]

    [ herefore frac{AB}{BE} = frac{EC}{CF} ]

    [ herefore frac{n}{x} = frac{n - x}{y} ]

    [ herefore y = frac {nx-x^2}{n} = x - frac{x^2}{n} ]

    [ecause xin mathbb{Z};且;yin mathbb{Z} ]

    [ herefore n|x^2 ]

    [设;n=p_1^{a_1} imes p_2^{a_2} imes p_3^{a_3} imes cdots p_i^{a_i}(p_iin mathbb{P}) ]

    [ herefore x_{min} = p_1^{left lceil frac{a_1}{2} ight ceil} imes p_2^{left lceil frac{a_2}{2} ight ceil} imes p_3^{left lceil frac{a_3}{2} ight ceil} imes cdots imes p_i^{left lceil frac{a_i}{2} ight ceil}(p_iin mathbb{P}) ]

    [设; kin mathbb{Z} ]

    [ecause kx_{min} < n ]

    [ herefore k < frac{n}{x_{min}} ]

    [易得; ans = k - 1 ]


    进一步计算

    • 如何求 (x_{min})

    会发现,每个质因子次幂是向上取整的,当次幂是奇数的时候,有一个 (p_i) 是必须选取的,剩下的选一半即可。

    [设; n=2^3 imes 3^2 imes 5^1 ]

    [x_{min} = 2^2 imes 3^1 imes 5^1 ]

    [有; 2^1; 和; 5^1; 是必选的 ]

    [设; i (i ^ 2leq n; 且; i^2|n), b = 2^1 imes 5^1 ]

    [ecause i_{max} = 2^1 imes 3^1 ]

    [ herefore b = frac{n}{i^2_{max}} ]

    [ herefore x_{min} = i_{max}b = frac{n}{i_{max}} ]

    [ecause k < frac{n}{x_{min}} ]

    [ herefore k < i_{max} ]

    [ecause ans = k - 1 ]

    [ herefore ans = i_{max} - 1 ]

    [ herefore ans = ans imes 8(正方形,四个角,直角在两边) ]

    [证毕 ]

    代码

    #include <cstdio>
    #include <cstring>
    #include <iostream>
    #include <algorithm>
    
    #define int long long
    
    using namespace std;
    
    const int maxn = 1e5 + 50, INF = 0x3f3f3f3f;
    
    inline int read () {
    	register int x = 0, w = 1;
    	register char ch = getchar ();
    	for (; ch < '0' || ch > '9'; ch = getchar ()) if (ch == '-') w = -1;
    	for (; ch >= '0' && ch <= '9'; ch = getchar ()) x = x * 10 + ch - '0';
    	return x * w;
    }
    
    inline void write (register int x) {
    	if (x / 10) write (x / 10);
    	putchar (x % 10 + '0');
    }
    
    int n, ans;
    
    signed main () {
    	freopen ("tri.in", "r", stdin);
    	freopen ("tri.out", "w", stdout);
    	while (1) {
    		n = read();
    		if (n == 0) break;
    		for (register int i = 1; i * i <= n; i ++) {
    			if (n % (i * i) == 0) ans = (i - 1) * 8;
    		}
    		printf ("%lld
    ", ans);
    	}
    	return 0;
    }
    
  • 相关阅读:
    openfire 介绍安装使用
    android rabbitMQ
    转:socket编程在windows和linux下的区别
    socklen_t在windows和linux平台下的头文件定义
    libevent入门教程
    libevent安装
    《RabbitMQ in action》
    RabbitMQ安装和配置
    node.js模块之http模块
    node.js模块之Buffer模块
  • 原文地址:https://www.cnblogs.com/Rubyonly233/p/13890236.html
Copyright © 2011-2022 走看看