Uva 数论&&计算几何 几个水题

题目链接:http://vjudge.net/vjudge/contest/view.action?cid=53840#problem/B  密码:.1

闲来无事,A几道基础数论+计算几何。可以看到,自己弱渣的本质,然后,知道自己的弱小而后勇。。。。。。

做UVA的题,特别是这种水题,让你感觉1.英语太硬伤2.输出格式太蛋疼3.自己太弱。。。

B题太无语,表示看了几遍题目+样例还是没有知道题目在说什么。。囧。搜了一下题意,随便看了人家的题解,才知道题目的意思。

说是,在b进制下,被乘数的最后一位为m,乘数为n。求被乘数的最小位数(假设被乘数为x),使得x*n=y,y为x的所有位向后移动一位。

比如十进制下:179487 * 4 = 717948  ans = 6;

通过这组样例,我们可以看到 给的是 10  7  4 而7 * 4 = 28, 28 % 10 = 8是y是最后一位,也是x的倒数第二位。以此类推,就可以求出ans了。。

Code:

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    int base, n, m;
    while(~scanf("%d %d %d", &base, &n, &m)){
        int ans = 1, x = n, y = 0;
        while(x * m + y != n){
            int tmp = x * m + y;
            y = tmp / base;
            x = tmp % base;
            ans ++;
        }//代码很短,思路很明确。英语很DT.
        printf("%d\n", ans);
    }
    return 0;
}


C就是一个求n!的最后非0数。模板题。。

D题就是gcd的一个小小应用。。各种PE.才发现多了一个空格。。。。。。

E题就是求一个循环节的。。。现在看来没给数据范围。。。囧。。。开了1e5 + 5,AC。。。

F题更DT,a 20bit unsigned number != 20位,眼挫了。。。。一位是20位。然后就比较纠结。。意思是就n!在m进制下的末尾0个数和位数。。。

G分解质因数。。。。

I题又是考验英语水平的题目,比较纠结。。。看了人家的题解。。盗了一张图。。。

很优美。。。。不过,输出应该是所有圆的周长。。。

Code:

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

const double PI = acos(-1);
const double eps = 0.000001;

int main(){
    int T;
    bool flag = false;
    scanf("%d", &T);
    while(T --){
        double b, h, r, y;
        scanf("%lf %lf", &b, &h);
        double ans = 0;
        while(1){
            y = atan(2 * h / b);
            r = tan(y / 2) * b / 2;
            if(r <= eps) break;
            ans += 2 * PI * r;
            b = b - 2 * r * b / h;
            h = h - 2 * r;
        }
        if(flag) puts("");
        printf("%13.6lf\n", ans);
        flag = true;
    }
    return 0;
}

比较nx的输出方式。。。。表示,orz。。

J题是一个很有意思的题目。。一开始想到了肯定是有很有技巧性的解法。。

题目的意思就是给你一个台球桌,a b为其长和宽。。从中心开始,经过s秒后,碰撞了m次垂直边,n次水平边。。回到了中心。。为出发的角度和速度。。。。。。。。没思路。后来想到,计算几何都会有很巧妙的技巧。。肯定不会.....好吧。。

思路:撞到垂直边m,水平方向肯定走了m*a的单位长度。同理,垂直方向走了n*b的长度。。。可以求出其角度和速度。。

Code:

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

const double PI = acos(-1);
int main(){
    double a, b, s, m, n;
    while(~scanf("%lf %lf %lf %lf %lf", &a, &b, &s, &m, &n)){
        if(a + b + s + m + n == 0) break;
        double sp = a * m, cz = b * n ;
        double ans1 = atan(cz / sp), ans2;
        ans2 = sqrt(sp * sp+ cz * cz) / s;
        printf("%.2lf %.2lf\n", ans1 / PI * 180, ans2);
    }
    return 0;
}



K题,莫名其妙的WA了依次后,各种加精度+一个小bug,提交AC。。。。后来发现是那个小bug错了。。。好吧,又脑残了那么一会儿。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值