int main() { scanf("%d", &n); for(i=0;i<n*n;i++) scanf("%d", &arr[i]); calc_sums(arr, n, n); printf("%d", find3(n,n)); return 0; }
/* call downstream function with each path */ list_forall (p, plist) { TRY(calc_sums(p->priv)); TRY(calc_lon(p->priv)); TRY(bestpolygon(p->priv)); TRY(adjust_vertices(p->priv)); TRY(smooth(&p->priv->curve, p->sign, param->alphamax)); if (param->opticurve) { TRY(opticurve(p->priv, param->opttolerance)); p->priv->fcurve = &p->priv->ocurve; } else { p->priv->fcurve = &p->priv->curve; } privcurve_to_curve(p->priv->fcurve, &p->curve); if (progress->callback) { cn += p->priv->len; progress_update(cn/nn, progress); } }
/** * Verify hash sums of the file. * * @param info structure file path to process * @return zero on success, -1 on file error, -2 if hash sums are different */ static int verify_sums(struct file_info *info) { timedelta_t timer; int res = 0; errno = 0; /* initialize percents output */ init_percents(info); rhash_timer_start(&timer); if(calc_sums(info) < 0) { finish_percents(info, -1); return -1; } info->time = rhash_timer_stop(&timer); if(rhash_data.interrupted) { report_interrupted(); return 0; } if((opt.flags & OPT_EMBED_CRC) && find_embedded_crc32( info->print_path, &info->hc.embedded_crc32_be)) { info->hc.flags |= HC_HAS_EMBCRC32; assert(info->hc.hash_mask & RHASH_CRC32); } if(!hash_check_verify(&info->hc, info->rctx)) { res = -2; } finish_percents(info, res); if((opt.flags & OPT_SPEED) && info->sums_flags) { print_file_time_stats(info); } return res; }
/** * Calculate and print file hash sums using printf format. * * @param out a stream to print to * @param file the file to calculate sums for * @param print_path the path to print * @return 0 on success, -1 on fail */ int calculate_and_print_sums(FILE* out, file_t* file, const char *print_path) { struct file_info info; timedelta_t timer; int res = 0; memset(&info, 0, sizeof(info)); info.file = file; info.full_path = rsh_strdup(file->path); file_info_set_print_path(&info, print_path); info.size = 0; info.sums_flags = opt.sum_flags; if(file->mode & FILE_IFSTDIN) { print_path = "(stdin)"; } else { if(file->mode & FILE_IFDIR) return 0; /* don't handle directories */ info.size = file->size; /* total size, in bytes */ } /* initialize percents output */ init_percents(&info); rhash_timer_start(&timer); if(info.sums_flags) { /* calculate sums */ if(calc_sums(&info) < 0) { /* print error unless sharing access error occurred */ if(errno == EACCES) return 0; log_file_error(file->path); res = -1; } if(rhash_data.interrupted) { report_interrupted(); return 0; } } info.time = rhash_timer_stop(&timer); finish_percents(&info, res); if(opt.flags & OPT_EMBED_CRC) { /* rename the file */ rename_file_by_embeding_crc32(&info); } if((opt.mode & MODE_TORRENT) && !opt.bt_batch_file) { save_torrent(&info); } if((opt.mode & MODE_UPDATE) && opt.fmt == FMT_SFV) { /* updating SFV file: print SFV header line */ print_sfv_header_line(rhash_data.upd_fd, file, 0); if(opt.flags & OPT_VERBOSE) { print_sfv_header_line(rhash_data.log, file, 0); fflush(rhash_data.log); } rsh_file_cleanup(file); } if(rhash_data.print_list && res >= 0) { if (!opt.bt_batch_file) { print_line(out, rhash_data.print_list, &info); fflush(out); /* print calculated line to stderr or log-file if verbose */ if((opt.mode & MODE_UPDATE) && (opt.flags & OPT_VERBOSE)) { print_line(rhash_data.log, rhash_data.print_list, &info); fflush(rhash_data.log); } } if((opt.flags & OPT_SPEED) && info.sums_flags) { print_file_time_stats(&info); } } free(info.full_path); file_info_destroy(&info); return res; }