uva 12012 Detection of Extraterrestrial

类型:KMP[经典]

题目:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3163

思路:枚举前缀,不断更新当前max值

字符串为周期串的条件是n % (n - next[n]) = 0

子串个数x为1时特殊考虑

数据: aba

答案:3 0 0

参考:http://blog.csdn.net/allenjy123/article/details/6629885

// uva 12012
// wa ac
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

#define FOR(i,a,b) for(i = (a); i < (b); ++i)
#define FORE(i,a,b) for(i = (a); i <= (b); ++i)
#define FORDE(i,a,b) for(i = (a); i >= (b); --i)
#define CLR(a,b) memset(a,b,sizeof(a))

const int MAXN = 1010;

char st[MAXN], sp[MAXN];
int n, len, m;
int p[MAXN], ans[MAXN];

void next() {
    int k = 0, i;
    p[1] = 0;
    FORE(i, 2, m) {
        while(k > 0 && sp[i] != sp[k + 1])
            k = p[k];
        if(sp[k + 1] == sp[i])
            k = k + 1;
        p[i] = k;
    }
}

void solve() {
    int i, j, k;

    FORE(i, 1, len) {
        strcpy(sp + 1, st + i);
        m = strlen(sp + 1);
        CLR(p, 0);
        next();
        FORE(j, 1, m) {
            int x = j - p[j];
            //!!!
            if(j % x == 0) {
                int tmp = j / x;
                //!!!
                FORE(k, 1, tmp)
                    ans[k] = max(ans[k], j - (tmp % k) * x);
            }
        }
    }
}

int main() {
    int i, T;
    int cas = 1;

    scanf("%d", &T);
    while(T--) {
        scanf("%s", st + 1);
        len = strlen(st + 1);
        CLR(ans, 0);
        solve();
        printf("Case #%d:", cas++);
        FORE(i, 1, len)
            (i == 1) ? printf(" %d", len) : printf(" %d", ans[i]);
        printf("\n");
    }
    return 0;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的QUAC大气校正IDL代码示例: ``` ;************************************************************* ;* QUAC Atmospheric Correction ;* ;* Inputs: ;* - radiance_data: input radiance data ;* - solar_zenith_angle: solar zenith angle data ;* - sensor_zenith_angle: sensor zenith angle data ;* - relative_azimuth_angle: relative azimuth angle data ;* ;* Outputs: ;* - reflectance_data: output reflectance data ;* ;* Author: Your Name ;* Date: Today's date ;************************************************************* PRO quac_atmos_correction, radiance_data, solar_zenith_angle, sensor_zenith_angle, relative_azimuth_angle, reflectance_data ; Constants pi = !dpi deg2rad = pi / 180.0 rad2deg = 180.0 / pi earth_sun_distance = 1.0 ; assume Earth-Sun distance is 1 AU ; Atmospheric parameters p = 1013.0 ; pressure (mb) wv = 1.0 ; water vapor (g/cm^2) oz = 0.3 ; ozone (atm-cm) ; Angles in radians solar_zenith_angle = solar_zenith_angle * deg2rad sensor_zenith_angle = sensor_zenith_angle * deg2rad relative_azimuth_angle = relative_azimuth_angle * deg2rad ; Calculate extraterrestrial irradiance declination = 23.45 * sin( (2.0 * pi * (284.0 + day_of_year)) / 365.0 ) cos_theta = sin(solar_zenith_angle) * sin(latitude) * cos(declination) - sin(solar_zenith_angle) * cos(latitude) * sin(declination) * cos(solar_time) + cos(solar_zenith_angle) * cos(latitude) * cos(declination) * cos(solar_time) + cos(solar_zenith_angle) * sin(latitude) * sin(declination) * cos(solar_time) extraterrestrial_irradiance = 1366.1 * cos_theta / earth_sun_distance ; Calculate atmospheric transmittance tau_r = exp( -0.015 * solar_zenith_angle^0.4 ) tau_a = exp( -0.00287 * p / cos(solar_zenith_angle) ) tau_w = exp( -0.0002 * wv * (1.0 / cos(solar_zenith_angle) - 0.2) ) tau_o = exp( -oz * 0.01 * (1.0 / cos(solar_zenith_angle) + 0.15 * (solar_zenith_angle / pi)^1.3) ) atmospheric_transmittance = tau_r * tau_a * tau_w * tau_o ; Calculate spherical albedo spherical_albedo = 0.025 + 0.25 * exp( -1.5 * (relative_azimuth_angle / pi)^2 ) ; Atmospheric correction reflectance_data = radiance_data / (extraterrestrial_irradiance * atmospheric_transmittance) - spherical_albedo * (1.0 - atmospheric_transmittance) END ``` 这是一个简单的代码示例,实际使用时可能需要根据数据格式和所需输出的内容进行修改。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值